[LTP] [PATCH v5] swapon03: Try to swapon() as many files until it fails
Andrea Cervesato
andrea.cervesato@suse.com
Tue Jan 6 12:57:32 CET 2026
Hi!
On Mon Jan 5, 2026 at 8:49 AM CET, Petr Vorel wrote:
> > Hi!
>
> > > - 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.
Besides that,
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list