public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5] swapon03: Try to swapon() as many files until it fails
Date: Wed, 7 Jan 2026 08:53:54 +0100	[thread overview]
Message-ID: <20260107075354.GB727950@pevik> (raw)
In-Reply-To: <DFHHL0ST0J9B.VIZCKRYAK2TN@suse.com>

Hi all,

> > > > -	char cmd_buffer[256];
> > > > +	char cmd_buffer[FILENAME_MAX+28];

> > > I'm not sure if +28 is needed.

> > I described the reason in the commit message:

> > 	It was required to increase cmd_buffer size to avoid directive output
> >     may be truncated warning.

> > I get warning on smaller size:

> > swapon03.c:74:60: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4087 [-Wformat-truncation=]
> >    74 |         snprintf(cmd_buffer, sizeof(cmd_buffer), "grep -q '%s.*file' /proc/swaps", filename);
> >       |                                                            ^~
> > ......
> >    94 |                 check_and_swapoff(filename);
> >       |                                   ~~~~~~~~
> > In file included from /usr/include/stdio.h:970,
> >                  from swapon03.c:17:
> > In function ‘snprintf’,
> >     inlined from ‘check_and_swapoff’ at swapon03.c:74:2,
> >     inlined from ‘clean_swap’ at swapon03.c:94:3:
> > /usr/include/x86_64-linux-gnu/bits/stdio2.h:68:10: note: ‘__builtin___snprintf_chk’ output between 29 and 4124 bytes into a destination of size 4096
> >    68 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
> >       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    69 |                                    __glibc_objsize (__s), __fmt,
> >       |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    70 |                                    __va_arg_pack ());

> > Kind regards,
> > Petr

> Sorry, I missed the git comment. Can you also comment the source code
> please? So we don't guess what's going on in the buffer, based on
> git message.

FYI merged with just added FILENAME_MAX+28 in the commit message to be more
obvious.  With recent gcc we can have many fixes like this, I'm not sure if we
want to comment every -Wformat-truncation in the source code.

Thanks to all for a review.
I'll plan to do the rest of the test cleanup as we agreed.

Kind regards,
Petr

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

  reply	other threads:[~2026-01-07  7:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-22  9:44 [LTP] [PATCH v5] swapon03: Try to swapon() as many files until it fails Petr Vorel
2025-12-22 12:58 ` Li Wang via ltp
2026-01-05  7:14 ` Andrea Cervesato via ltp
2026-01-05  7:49   ` Petr Vorel
2026-01-06 11:57     ` Andrea Cervesato via ltp
2026-01-07  7:53       ` Petr Vorel [this message]
2026-01-07  9:08         ` Andrea Cervesato via ltp
2026-01-06 12:03 ` Cyril Hrubis

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=20260107075354.GB727950@pevik \
    --to=pvorel@suse.cz \
    --cc=andrea.cervesato@suse.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