• Arnd Bergmann's avatar
    rhashtable: avoid -Wrestrict warning on overlapping sprintf output · 4adec7f8
    Arnd Bergmann authored
    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: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    4adec7f8
test_rhashtable.c 20 KB