]> git.baikalelectronics.ru Git - kernel.git/commit
rhashtable: avoid -Wrestrict warning on overlapping sprintf output
authorArnd Bergmann <arnd@arndb.de>
Tue, 23 Mar 2021 13:03:32 +0000 (14:03 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Mar 2021 22:16:09 +0000 (15:16 -0700)
commitd6fc4f11ed69e07123eb3721656ea4f31f75d63c
tree63d515f89bec673f2ed9917820e966f32b05da45
parentdf35dbf9ca84fc2c7f397329b9bf87b864e4fd74
rhashtable: avoid -Wrestrict warning on overlapping sprintf output

sprintf() is declared with a restrict keyword to not allow input and
output to point to the same buffer:

lib/test_rhashtable.c: In function 'print_ht':
lib/test_rhashtable.c:504:4: error: 'sprintf' argument 3 overlaps destination object 'buff' [-Werror=restrict]
  504 |    sprintf(buff, "%s\nbucket[%d] -> ", buff, i);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/test_rhashtable.c:489:7: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  489 |  char buff[512] = "";
      |       ^~~~

Rework this function to remember the last offset instead to
avoid the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/test_rhashtable.c