]> git.baikalelectronics.ru Git - kernel.git/commit
fm10k: avoid possible truncation of q_vector->name
authorJacob Keller <jacob.e.keller@intel.com>
Mon, 10 Jul 2017 20:23:06 +0000 (13:23 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Mon, 2 Oct 2017 14:46:57 +0000 (07:46 -0700)
commit50c391aab2c8e5d5d7042276c7f2e4b9a335bb8e
tree8f5d0521b15f0c4823ce5cedcfde67aa3e95a22e
parentbe3de849350659089ea3f7bcbd91bc92c40a1034
fm10k: avoid possible truncation of q_vector->name

New versions of GCC since version 7 began warning about possible
truncation of calls to snprintf. We can fix this and avoid false
positives. First, we should pass the full buffer size to snprintf,
because it guarantees a NULL character as part of its passed length, so
passing len-1 is simply wasting a byte of possible storage.

Second, if we make the ri and ti variables unsigned, the compiler is
able to correctly reason that the value never gets larger than 256, so
it doesn't need to warn about the full space required to print a signed
integer.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/fm10k/fm10k_pci.c