From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23143 invoked by alias); 21 Jun 2017 20:35:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 23033 invoked by uid 89); 21 Jun 2017 20:35:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Jun 2017 20:35:48 +0000 From: Sergio Durigan Junior To: Simon Marchi Cc: Subject: Re: [PATCH 4/4] main: Don't add int to string References: <1498076108-29914-1-git-send-email-simon.marchi@ericsson.com> <1498076108-29914-5-git-send-email-simon.marchi@ericsson.com> X-URL: https://sergiodj.net Date: Wed, 21 Jun 2017 20:35:00 -0000 In-Reply-To: <1498076108-29914-5-git-send-email-simon.marchi@ericsson.com> (Simon Marchi's message of "Wed, 21 Jun 2017 22:15:08 +0200") Message-ID: <878tklcc4e.fsf@sergiodj.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2017-06/txt/msg00610.txt.bz2 On Wednesday, June 21 2017, Simon Marchi wrote: > 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]". > --- > gdb/main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/main.c b/gdb/main.c > index df4b111..9813041 100644 > --- a/gdb/main.c > +++ b/gdb/main.c > @@ -224,7 +224,7 @@ get_init_files (const char **system_gdbinit, > { > /* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR > to gdb_datadir. */ > - char *tmp_sys_gdbinit = xstrdup (SYSTEM_GDBINIT + datadir_len); > + char *tmp_sys_gdbinit = xstrdup (&SYSTEM_GDBINIT[datadir_len]); > char *p; > > for (p = tmp_sys_gdbinit; IS_DIR_SEPARATOR (*p); ++p) > -- > 2.7.4 LGTM. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/