]> git.baikalelectronics.ru Git - kernel.git/commit
x86/mce/dev-mcelog: Fix -Wstringop-truncation warning about strncpy()
authorTony Luck <tony.luck@intel.com>
Wed, 27 May 2020 18:28:08 +0000 (11:28 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 11 Jun 2020 13:19:17 +0000 (15:19 +0200)
commitece3d9aa92c39c4ea9e11650c5d6330a52c8eb12
tree422d31f2b461c6a7b49ceef0330895dba988c107
parent27ff0088ed282f6209f12254e3399c0e418eac80
x86/mce/dev-mcelog: Fix -Wstringop-truncation warning about strncpy()

The kbuild test robot reported this warning:

  arch/x86/kernel/cpu/mce/dev-mcelog.c: In function 'dev_mcelog_init_device':
  arch/x86/kernel/cpu/mce/dev-mcelog.c:346:2: warning: 'strncpy' output \
    truncated before terminating nul copying 12 bytes from a string of the \
    same length [-Wstringop-truncation]

This is accurate, but I don't care that the trailing NUL character isn't
copied. The string being copied is just a magic number signature so that
crash dump tools can be sure they are decoding the right blob of memory.

Use memcpy() instead of strncpy().

Fixes: 457c34245bd0 ("x86/mce/dev-mcelog: Dynamically allocate space for machine check records")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200527182808.27737-1-tony.luck@intel.com
arch/x86/kernel/cpu/mce/dev-mcelog.c