ornladios / ADIOS

The old ADIOS 1.x code repository. Look for ADIOS2 for new repo
https://csmd.ornl.gov/adios
Other
54 stars 40 forks source link

sprintf format code for long used when printing int64_t #155

Closed burlen closed 6 years ago

burlen commented 6 years ago

clang reports

../../ADIOS/src/core/adiost_callback_internal.c:212:55: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t'
      (aka 'unsigned long long') [-Wformat]
            sprintf(dims, "%s%c%lu", dims, delimiter, tmp->dimension.rank);
                               ~~~                    ^~~~~~~~~~~~~~~~~~~
                               %llu
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
../../ADIOS/src/core/adiost_callback_internal.c:222:69: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t'
      (aka 'unsigned long long') [-Wformat]
            sprintf(global_dims, "%s%c%lu", global_dims, delimiter, tmp->global_dimension.rank);
                                      ~~~                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                      %llu
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
../../ADIOS/src/core/adiost_callback_internal.c:232:73: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t'
      (aka 'unsigned long long') [-Wformat]
            sprintf(local_offsets, "%s%c%lu", local_offsets, delimiter, tmp->local_offset.rank);
                                        ~~~                             ^~~~~~~~~~~~~~~~~~~~~~
                                        %llu
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
3 warnings generated.

long is not always 64 bits, and unit64_t has it's own format code

#include <inttypes.h>
uint64_t t;
printf("%" PRIu64 "\n", t);
pnorbert commented 6 years ago

Thanks for the note. fixed in commit cff9709