vergoh / vnstat

vnStat - a network traffic monitor for Linux and BSD
GNU General Public License v2.0
1.36k stars 120 forks source link

Use correct format length specifiers for 32-bit systems #199

Closed cgzones closed 3 years ago

cgzones commented 3 years ago
src/image.c: In function 'drawfiveminutes':
src/image.c:973:20: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
  973 |   printf("maxrx: %lu\n", datainfo.maxrx);
      |                  ~~^     ~~~~~~~~~~~~~~
      |                    |             |
      |                    |             uint64_t {aka long long unsigned int}
      |                    long unsigned int
      |                  %llu
src/image.c:974:20: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
  974 |   printf("maxtx: %lu\n", datainfo.maxtx);
      |                  ~~^     ~~~~~~~~~~~~~~
      |                    |             |
      |                    |             uint64_t {aka long long unsigned int}
      |                    long unsigned int
      |                  %llu
src/image.c:976:26: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
  976 |   printf("max divided: %lu\n", max);
      |                        ~~^     ~~~
      |                          |     |
      |                          |     uint64_t {aka long long unsigned int}
      |                          long unsigned int
      |                        %llu
src/image.c:977:26: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
  977 |   printf("scaleunit:   %lu\nstep: %d\n", scaleunit, step);
      |                        ~~^               ~~~~~~~~~
      |                          |               |
      |                          |               uint64_t {aka long long unsigned int}
      |                          long unsigned int
      |                        %llu
src/image.c:979:22: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
  979 |   printf("mintime: %lu\nmaxtime: %lu\n", (uint64_t)datainfo.mintime, (uint64_t)datainfo.maxtime);
      |                    ~~^                   ~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                      |                   |
      |                      long unsigned int   long long unsigned int
      |                    %llu
src/image.c:979:36: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=]
  979 |   printf("mintime: %lu\nmaxtime: %lu\n", (uint64_t)datainfo.mintime, (uint64_t)datainfo.maxtime);
      |                                  ~~^                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                    |                                 |
      |                                    long unsigned int                 long long unsigned int
      |                                  %llu
vergoh commented 3 years ago

Thanks. Those debug prints aren't likely to stay there for too many releases but I concluded on keeping those for a while at least since the graph in question would otherwise end up rather annoying to debug if someone manages to get it act strangely. Looks like I'm also missing a 32-bit system with a recent enough compiler since none of those I had produced warnings for these.