NetworkBlockDevice / nbd

Network Block Device
GNU General Public License v2.0
459 stars 119 forks source link

A typo in the format string in error message in nbd-client.c #134

Closed Nable80 closed 2 years ago

Nable80 commented 2 years ago

https://github.com/NetworkBlockDevice/nbd/blob/9ed62752ae804546a01ce4694f1c35deebec2886/nbd-client.c#L1195-L1198

Percent sign is missing before the first format specifier, so instead of "E: size (%llu bytes) is not a multiple of blocksize (%d)!\n" it expands to "E: size (llu bytes) is not a multiple of blocksize (%d)!\n" and triggers a slightly obscure compiler warning:

nbd-client.c: In function 'main':
nbd-client.c:1196:33: warning: format '%d' expects argument of type 'int', but argument 3 has type 'u64' {aka 'long long unsigned int'} [-Wformat=]
 1196 |                 fprintf(stderr, "E: size (" PRIu64 " bytes) is not a multiple of blocksize (%d)!\n", force_size64, blocksize);
      |                                 ^~~~~~~~~~~                                                          ~~~~~~~~~~~~  
      |                                                                                                      |
      |                                                                                                      u64 {aka long long unsigned int}     
nbd-client.c:1196:94: note: format string is defined here      
 1196 |                 fprintf(stderr, "E: size (" PRIu64 " bytes) is not a multiple of blocksize (%d)!\n", force_size64, blocksize);
      |                                                                                             ~^
      |                                                                                              |
      |                                                                                              int
      |                                                                                             %lld

The fix seems to be trivial: "E: size (%" instead of "E: size ("

Maybe it was mentioned in the mailing list but I couldn't find any mentions of this issue there.

Nable80 commented 2 years ago

Thank you!