Bug 22495 - remote-sim.c should be built with -Wno-format-nonliteral
Summary: remote-sim.c should be built with -Wno-format-nonliteral
Status: CLOSED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: build (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-26 09:58 UTC by Pavel I. Kryukov
Modified: 2018-03-31 12:35 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel I. Kryukov 2017-11-26 09:58:41 UTC
Hi

remote-sim.c contains calls of `vfprintf_filtered` function with non-literal format. Clang is able to track that if '-Wformat-literal' warning is enabled, leading to compilation failure:

clang++-5.0 -x c++ -std=gnu++11 -g -O2   -I. -I. -I./common -I./config -DLOCALEDIR="\"/home/travis/build/pavelkryukov/gnu-binutils-clang/binutils-gdb/cross/mips/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/..  -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import   -DTUI=1  -I/usr/include/python2.7 -I/usr/include/python2.7 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wno-sign-compare -Wno-narrowing -Wno-mismatched-tags -Wformat-nonliteral -Werror -c -o remote-sim.o -MT remote-sim.o -MMD -MP -MF ./.deps/remote-sim.Tpo remote-sim.c
remote-sim.c:386:34: error: format string is not a string literal
      [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stdout, format, args);

As a workaround, we may add an exception for `remote-sim.c` in the same manner  as for `target-float.c`. I pushed a patch to master branch of this repository:

https://github.com/pavelkryukov/binutils-gdb.git
Comment 2 Simon Marchi 2018-01-02 04:45:46 UTC
The patch you linked doesn't seem related to remote-sim.c.
Comment 3 Pavel I. Kryukov 2018-01-09 09:45:42 UTC
My fault, sorry. However,  the same warning is triggered in remote-sim.c, so the same patch may be applied.
Comment 4 Pavel I. Kryukov 2018-01-17 15:14:10 UTC
Reopened as Clang is still unable to build the file
Comment 5 Pavel I. Kryukov 2018-02-20 15:14:55 UTC
Clang still refuses to build remote-sim.c, could anyone please take a look?

Command line:
> ./configure --target=mipsel-unknown-linux-gnu --with-system-zlib && make && make install

Clang command line and output:

clang++-5.0 -x c++ -std=gnu++11 -g -O2   -I. -I. -I./common -I./config -DLOCALEDIR="\"/home/travis/build/pavelkryukov/gnu-binutils-clang/binutils-gdb/cross/mips/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/..  -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import   -DTUI=1  -I/usr/include/python2.7 -I/usr/include/python2.7 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wno-sign-compare -Wno-narrowing -Wno-mismatched-tags -Wformat-nonliteral -Werror -c -o remote-sim.o -MT remote-sim.o -MMD -MP -MF ./.deps/remote-sim.Tpo remote-sim.c
remote-sim.c:386:34: error: format string is not a string literal
      [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stdout, format, args);
                                 ^~~~~~
remote-sim.c:395:34: error: format string is not a string literal
      [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stdout, format, ap);
                                 ^~~~~~
remote-sim.c:403:34: error: format string is not a string literal
      [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stderr, format, ap);
                                 ^~~~~~
remote-sim.c:414:11: error: format string is not a string literal
      [-Werror,-Wformat-nonliteral]
  verror (format, args);
          ^~~~~~
4 errors generated.
Comment 7 Pavel I. Kryukov 2018-02-20 18:38:47 UTC
Thanks!