[LTP] [PATCH] inotify: clean up build and make check findings
Cyril Hrubis
chrubis@suse.cz
Fri Mar 6 12:28:57 CET 2026
Hi!
> For the -Wformat-truncation warning in inotify02.c, how about fixing it
> by adjusting the snprintf() call?
>
> For example:
> snprintf(fname3, BUF_SIZE, "%s.rename2", fname1);
> snprintf(fname3, BUF_SIZE, "%.*s.rename2", (int)(BUF_SIZE -
> sizeof(".rename2")), fname1);
>
> Also, regarding the make check warning about ENOSYS: if I revert the code,
> the warning will remain. Should this just be left as-is, or is there
> another way to handle it?
>
> inotify.h:36: WARNING: ENOSYS means 'invalid syscall nr' and nothing else
The easiest solution is to make fname2 and fname3 array larger:
diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c
index 314c1bd49..21a29676a 100644
--- a/testcases/kernel/syscalls/inotify/inotify02.c
+++ b/testcases/kernel/syscalls/inotify/inotify02.c
@@ -35,7 +35,7 @@
#define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16))
#define BUF_SIZE 256
-static char fname1[BUF_SIZE], fname2[BUF_SIZE], fname3[BUF_SIZE];
+static char fname1[BUF_SIZE], fname2[BUF_SIZE+32], fname3[BUF_SIZE + 32];
static int fd, fd_notify, reap_wd;
static int wd;
@@ -86,7 +86,7 @@ void verify_inotify(void)
test_cnt++;
SAFE_GETCWD(fname1, BUF_SIZE);
- snprintf(fname2, BUF_SIZE, "%s.rename1", fname1);
+ snprintf(fname2, sizeof(fname2), "%s.rename1", fname1);
SAFE_RENAME(fname1, fname2);
event_set[test_cnt].mask = IN_MOVE_SELF;
strcpy(event_set[test_cnt].name, "");
@@ -103,7 +103,7 @@ void verify_inotify(void)
* we can correct determine kernel bug which exist before
* 2.6.25. See comment below.
*/
- snprintf(fname3, BUF_SIZE, "%s.rename2", fname1);
+ snprintf(fname3, sizeof(fname3), "%s.rename2", fname1);
SAFE_RENAME(fname2, fname3);
SAFE_RENAME(fname3, fname1);
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list