This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] main: Don't add int to string
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Sun, 25 Jun 2017 08:02:20 -0400
- Subject: [binutils-gdb] main: Don't add int to string
- Authentication-results: sourceware.org; auth=none
*** TEST RESULTS FOR COMMIT cc75e0fdaeb179efc66ddd1cb1b6da40e6adacc1 ***
Author: Simon Marchi <simon.marchi@ericsson.com>
Branch: master
Commit: cc75e0fdaeb179efc66ddd1cb1b6da40e6adacc1
main: Don't add int to string
clang shows this warning:
/home/emaisin/src/binutils-gdb/gdb/main.c:227:56: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
char *tmp_sys_gdbinit = xstrdup (SYSTEM_GDBINIT + datadir_len);
~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/main.c:227:56: note: use array indexing to silence this warning
char *tmp_sys_gdbinit = xstrdup (SYSTEM_GDBINIT + datadir_len);
^
& [ ]
It's quite easy to get rid of it by using &foo[len] instead of foo + len.
I think this warning is relevant to keep enabled, because it can be an
easy mistake to do.
This warning is already discussed here in GCC bugzilla:
https://gcc.gnu.org/ml/gcc-patches/2017-06/msg00729.html
and a patch series for it was submitted very recently.
gdb/ChangeLog:
* main.c (get_init_files): Replace "SYSTEM_GDBINIT +
datadir_len" with "&SYSTEM_GDBINIT[datadir_len]".