]> granicus.if.org Git - sysstat/commit
Fix GCC v10 warnings
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 3 May 2020 07:05:58 +0000 (09:05 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 3 May 2020 07:05:58 +0000 (09:05 +0200)
commite75673f820213771803ce7f24745346a39934d03
treecceeb2bfff983d44ecff0333dc2f7be73f378c3a
parent3cb2a0fd46a0abe72bf07b392ef783d40aef83e3
Fix GCC v10 warnings

GCC versions 9 and later complain more agressively, e.g.:

common.c: In function ‘get_wwnid_from_pretty’:
common.c:396:4: warning: ‘strncpy’ offset [275, 4095] from the object at ‘drd’ is out of the bounds of referenced subobject ‘d_name’ with type ‘char[256]’ at offset 19 [-Warray-bounds]
  396 |    strncpy(wwn_name, drd->d_name, sizeof(wwn_name));
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/dirent.h:61,
                 from common.c:32:
/usr/include/bits/dirent.h:33:10: note: subobject ‘d_name’ declared here
   33 |     char d_name[256];  /* We must not include limits.h! */
      |          ^~~~~~

or:

common.c: In function ‘get_persistent_name_path’:
common.c:876:37: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  876 |  snprintf(path, sizeof(path), "%s/%s",
      |                                     ^
common.c:876:2: note: ‘snprintf’ output 2 or more bytes (assuming 4097) into a destination of size 4096
  876 |  snprintf(path, sizeof(path), "%s/%s",
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  877 |    get_persistent_type_dir(persistent_name_type), name);
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch quiets GCC.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
common.c
ioconf.c