[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200130021648.GA32309@ubuntu-x2-xlarge-x86>
Date: Wed, 29 Jan 2020 19:16:48 -0700
From: Nathan Chancellor <natechancellor@...il.com>
To: Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc: Steven Rostedt <rostedt@...dmis.org>, linux-kernel@...r.kernel.org,
clang-built-linux@...glegroups.com
Subject: -Wfortify-source in kernel/printk/printk.c
Hi all,
After commit 6d485ff455e ("Improve static checks for sprintf and
__builtin___sprintf_chk") in clang [1], the following warning appears
when CONFIG_PRINTK is disabled (e.g. allnoconfig):
../kernel/printk/printk.c:2416:10: warning: 'sprintf' will always
overflow; destination buffer has size 0, but format string expands
to at least 33 [-Wfortify-source]
len = sprintf(text,
^
1 warning generated.
Specifically referring to
https://elixir.bootlin.com/linux/v5.5/source/kernel/printk/printk.c#L2416.
It isn't wrong, given that when CONFIG_PRINTK is disabled, text's length
is 0 (LOG_LINE_MAX and PREFIX_MAX are both zero). How should this
warning be dealt this? I am not familiar enough with the printk code to
say myself.
[1]: https://github.com/llvm/llvm-project/commit/6d485ff455ea2b37fef9e06e426dae6c1241b231
Cheers,
Nathan
Powered by blists - more mailing lists