nvmet: re-fix tracing strncpy() warning
authorArnd Bergmann <arnd@arndb.de>
Wed, 3 Jan 2024 15:56:55 +0000 (16:56 +0100)
committerKeith Busch <kbusch@kernel.org>
Fri, 5 Jan 2024 21:16:18 +0000 (13:16 -0800)
commit4ee7ffeb4ce50c80bc4504db6f39b25a2df6bcf4
tree26ef0f21721a32dac464f73644afb7dd8947c7dd
parentbafd590910d00327decb3937e77f6f11c3e80e4b
nvmet: re-fix tracing strncpy() warning

An earlier patch had tried to address a warning about a string copy with
missing zero termination:

drivers/nvme/target/trace.h:52:3: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]

The new version causes a different warning with some compiler versions, notably
gcc-9 and gcc-10, and also misses the zero padding that was apparently done
intentionally in the original code:

drivers/nvme/target/trace.h:56:2: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]

Change it to use strscpy_pad() with the original length, which will give
a properly padded and zero-terminated string as well as avoiding the warning.

Fixes: d86481e924a7 ("nvmet: use min of device_path and disk len")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/trace.h