[PATCH] libctf: eschew %zi format specifier

Tom Tromey tromey@adacore.com
Wed Jun 5 13:47:00 GMT 2019


>>>>> "Nick" == Nick Alcock <nick.alcock@oracle.com> writes:

Nick> Too many platforms don't support it, and we can always safely use %lu or
Nick> %li anyway, because the only uses are in debugging output.

Thanks for doing this.  I can confirm it fixes the warnings I sent in
that note.  It turns out there were more, because I'd only reported the
ones that occurred in a file with errors.  Full log appended.

The implicit function declaration one looks maybe bad.

Tom

make  all-am
make[1]: Entering directory '/home/tromey/gdb/build-mingw/libctf'
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-archive.o -MD -MP -MF .deps/ctf-archive.Tpo -c -o ctf-archive.o ../../binutils-gdb/libctf/ctf-archive.c
../../binutils-gdb/libctf/ctf-archive.c: In function 'arc_mmap_header':
../../binutils-gdb/libctf/ctf-archive.c:684:35: warning: unused parameter 'fd' [-Wunused-parameter]
 static void *arc_mmap_header (int fd, size_t headersz)
                               ~~~~^~
mv -f .deps/ctf-archive.Tpo .deps/ctf-archive.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-dump.o -MD -MP -MF .deps/ctf-dump.Tpo -c -o ctf-dump.o ../../binutils-gdb/libctf/ctf-dump.c
../../binutils-gdb/libctf/ctf-dump.c: In function 'ctf_dump_format_type':
../../binutils-gdb/libctf/ctf-dump.c:124:42: warning: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'ssize_t' {aka 'int'} [-Wformat=]
    if (asprintf (&bit, " %lx: %s (size %lx)", id, buf[0] == '\0' ?
                                        ~~^
                                        %x
    "(nameless)" : buf, ctf_type_size (fp, id)) < 0)
                        ~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/libctf/ctf-dump.c: In function 'ctf_dump_objts':
../../binutils-gdb/libctf/ctf-dump.c:214:27: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
    if (asprintf (&str, "%lx -> ", i) < 0)
                         ~~^       ~
                         %x
../../binutils-gdb/libctf/ctf-dump.c:219:31: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
    if (asprintf (&str, "%s (%lx) -> ", sym_name, i) < 0)
                             ~~^                  ~
                             %x
../../binutils-gdb/libctf/ctf-dump.c: In function 'ctf_dump_funcs':
../../binutils-gdb/libctf/ctf-dump.c:282:27: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
    if (asprintf (&bit, "%lx ", i) < 0)
                         ~~^    ~
                         %x
../../binutils-gdb/libctf/ctf-dump.c:287:31: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
    if (asprintf (&bit, "%s (%lx) ", sym_name, i) < 0)
                             ~~^               ~
                             %x
../../binutils-gdb/libctf/ctf-dump.c: In function 'ctf_dump_member':
../../binutils-gdb/libctf/ctf-dump.c:370:79: warning: format '%lx' expects argument of type 'long unsigned int', but argument 8 has type 'ssize_t' {aka 'int'} [-Wformat=]
   if (asprintf (&bit, "    [0x%lx] (ID 0x%lx) (kind %i) %s %s (aligned at 0x%lx",
                                                                             ~~^
                                                                             %x
../../binutils-gdb/libctf/ctf-dump.c:372:3:
   ctf_type_align (state->cdm_fp, id)) < 0)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                           
../../binutils-gdb/libctf/ctf-dump.c: In function 'ctf_dump_str':
../../binutils-gdb/libctf/ctf-dump.c:443:30: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Wformat=]
       if (asprintf (&str, "%lx: %s", s - fp->ctf_str[CTF_STRTAB_0].cts_strs,
                            ~~^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            %x
mv -f .deps/ctf-dump.Tpo .deps/ctf-dump.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-create.o -MD -MP -MF .deps/ctf-create.Tpo -c -o ctf-create.o ../../binutils-gdb/libctf/ctf-create.c
mv -f .deps/ctf-create.Tpo .deps/ctf-create.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-decl.o -MD -MP -MF .deps/ctf-decl.Tpo -c -o ctf-decl.o ../../binutils-gdb/libctf/ctf-decl.c
mv -f .deps/ctf-decl.Tpo .deps/ctf-decl.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-error.o -MD -MP -MF .deps/ctf-error.Tpo -c -o ctf-error.o ../../binutils-gdb/libctf/ctf-error.c
mv -f .deps/ctf-error.Tpo .deps/ctf-error.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-hash.o -MD -MP -MF .deps/ctf-hash.Tpo -c -o ctf-hash.o ../../binutils-gdb/libctf/ctf-hash.c
mv -f .deps/ctf-hash.Tpo .deps/ctf-hash.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-labels.o -MD -MP -MF .deps/ctf-labels.Tpo -c -o ctf-labels.o ../../binutils-gdb/libctf/ctf-labels.c
mv -f .deps/ctf-labels.Tpo .deps/ctf-labels.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-lookup.o -MD -MP -MF .deps/ctf-lookup.Tpo -c -o ctf-lookup.o ../../binutils-gdb/libctf/ctf-lookup.c
../../binutils-gdb/libctf/ctf-lookup.c: In function 'ctf_lookup_by_name':
../../binutils-gdb/libctf/ctf-lookup.c:156:29: warning: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
     fp->ctf_tmp_typeslice = strndup (p, (size_t) (q - p));
                             ^~~~~~~
../../binutils-gdb/libctf/ctf-lookup.c:156:29: warning: incompatible implicit declaration of built-in function 'strndup'
mv -f .deps/ctf-lookup.Tpo .deps/ctf-lookup.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-open.o -MD -MP -MF .deps/ctf-open.Tpo -c -o ctf-open.o ../../binutils-gdb/libctf/ctf-open.c
mv -f .deps/ctf-open.Tpo .deps/ctf-open.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-open-bfd.o -MD -MP -MF .deps/ctf-open-bfd.Tpo -c -o ctf-open-bfd.o ../../binutils-gdb/libctf/ctf-open-bfd.c
mv -f .deps/ctf-open-bfd.Tpo .deps/ctf-open-bfd.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-subr.o -MD -MP -MF .deps/ctf-subr.Tpo -c -o ctf-subr.o ../../binutils-gdb/libctf/ctf-subr.c
../../binutils-gdb/libctf/ctf-subr.c: In function 'ctf_data_protect':
../../binutils-gdb/libctf/ctf-subr.c:109:25: warning: unused parameter 'buf' [-Wunused-parameter]
 ctf_data_protect (void *buf, size_t size)
                   ~~~~~~^~~
../../binutils-gdb/libctf/ctf-subr.c:109:37: warning: unused parameter 'size' [-Wunused-parameter]
 ctf_data_protect (void *buf, size_t size)
                              ~~~~~~~^~~~
mv -f .deps/ctf-subr.Tpo .deps/ctf-subr.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-types.o -MD -MP -MF .deps/ctf-types.Tpo -c -o ctf-types.o ../../binutils-gdb/libctf/ctf-types.c
mv -f .deps/ctf-types.Tpo .deps/ctf-types.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-util.o -MD -MP -MF .deps/ctf-util.Tpo -c -o ctf-util.o ../../binutils-gdb/libctf/ctf-util.c
mv -f .deps/ctf-util.Tpo .deps/ctf-util.Po
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/libctf  -D_GNU_SOURCE -I../../binutils-gdb/libctf -I../../binutils-gdb/libctf/../include -I../../binutils-gdb/libctf/../bfd -I../bfd  -std=gnu99 -Wall -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -pedantic -Wno-long-long  -I../../binutils-gdb/libctf/../zlib -g -O2 -D__USE_MINGW_ACCESS -MT ctf-qsort_r.o -MD -MP -MF .deps/ctf-qsort_r.Tpo -c -o ctf-qsort_r.o ../../binutils-gdb/libctf/ctf-qsort_r.c
mv -f .deps/ctf-qsort_r.Tpo .deps/ctf-qsort_r.Po
rm -f libctf.a
i686-w64-mingw32-ar cru libctf.a ctf-archive.o ctf-dump.o ctf-create.o ctf-decl.o ctf-error.o ctf-hash.o ctf-labels.o ctf-lookup.o ctf-open.o ctf-open-bfd.o ctf-subr.o ctf-types.o ctf-util.o ctf-qsort_r.o 
i686-w64-mingw32-ranlib libctf.a
make[1]: Leaving directory '/home/tromey/gdb/build-mingw/libctf'



More information about the Binutils mailing list