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)
commit4adec7f81df8e4fbf55f9d5ca98afa39f15b050f
tree63d515f89bec673f2ed9917820e966f32b05da45
parentb7fbc88692e60a4955ac54af0bcf7f2162761339
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