public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Jinseok Kim <always.starving0@gmail.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] inotify: clean up build and make check findings
Date: Fri, 6 Mar 2026 12:28:57 +0100	[thread overview]
Message-ID: <aaq6eVykSC-dSZHg@yuki.lan> (raw)
In-Reply-To: <20260306072008.3111-1-always.starving0@gmail.com>

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-03-06 11:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-01 16:57 [LTP] [PATCH] inotify: clean up build and make check findings Jinseok Kim
2026-03-03 15:46 ` Andrea Cervesato via ltp
2026-03-06  7:20   ` Jinseok Kim
2026-03-06 11:28     ` Cyril Hrubis [this message]
2026-03-09 14:48       ` Jinseok Kim
2026-03-13 16:05   ` [LTP] [PATCH v2 1/2] inotify: replace strcpy() with snprintf() Jinseok Kim
2026-03-13 16:05     ` [LTP] [PATCH v2 2/2] inotify: fix make check findings Jinseok Kim
2026-03-16 12:31       ` Andrea Cervesato via ltp
2026-03-16 12:30     ` [LTP] [PATCH v2 1/2] inotify: replace strcpy() with snprintf() Andrea Cervesato via ltp
2026-03-16 15:44       ` [LTP] [PATCH v3] " Jinseok Kim
2026-03-17  9:39         ` Andrea Cervesato via ltp
2026-03-17 17:00           ` Jinseok Kim
2026-03-18 13:40             ` Andrea Cervesato via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aaq6eVykSC-dSZHg@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=always.starving0@gmail.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox