[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6eb2eab1-7a9c-4c07-a9b1-be6557247a4c@kernel.org>
Date: Wed, 1 Oct 2025 16:43:11 +0900
From: Damien Le Moal <dlemoal@...nel.org>
To: Johannes Thumshirn <johannes.thumshirn@....com>,
Jens Axboe <axboe@...nel.dk>
Cc: Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, linux-btrace@...r.kernel.org,
John Garry <john.g.garry@...cle.com>, Hannes Reinecke <hare@...e.de>,
Christoph Hellwig <hch@....de>, Naohiro Aota <naohiro.aota@....com>,
Shinichiro Kawasaki <shinichiro.kawasaki@....com>,
Chaitanya Kulkarni <chaitanyak@...dia.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>
Subject: Re: [PATCH blktrace v2 02/22] blkparse: fix compiler warning
On 9/26/25 00:04, Johannes Thumshirn wrote:
> GCC (15.2.1) warns on about the following string truncation in blkparse.c
>
> gcc -o blkparse.o -c -Wall -O2 -g -W -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 blkparse.c
> blkparse.c: In function ‘main’:
> blkparse.c:2103:68: warning: ‘):’ directive output may be truncated writing 2 bytes into a region of size between 1 and 41 [-Wformat-truncation=]
> 2103 | snprintf(line, sizeof(line) - 1, "CPU%d (%s):",
> | ^~
> In function ‘show_device_and_cpu_stats’,
> inlined from ‘show_stats’ at blkparse.c:3064:3,
> inlined from ‘main’ at blkparse.c:3386:3:
> blkparse.c:2103:25: note: ‘snprintf’ output between 9 and 49 bytes into a destination of size 47
> 2103 | snprintf(line, sizeof(line) - 1, "CPU%d (%s):",
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 2104 | j, get_dev_name(pdi, name, sizeof(name)));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gcc -Wall -O2 -g -W -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -o blkparse blkparse.o blkparse_fmt.o rbtree.o act_mask.o
>
> Add two more bytes to the string in order to mitigate the compiler warning.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@....com>
Reviewed-by: Damien Le Moal <dlemoal@...nel.org>
--
Damien Le Moal
Western Digital Research
Powered by blists - more mailing lists