git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Tay Ray Chuan <rctay89@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Antoine Pelisse <apelisse@gmail.com>
Subject: Re: [PATCH 2/3] combine-diff: suppress a clang warning
Date: Sun, 3 Feb 2013 19:06:21 +0000	[thread overview]
Message-ID: <20130203190621.GT1342@serenity.lan> (raw)
In-Reply-To: <CALUzUxowrh53g50ZxkXSjLfOrSgX-YiZEB2MJXbLwxmwNB187A@mail.gmail.com>

On Mon, Feb 04, 2013 at 02:20:06AM +0800, Tay Ray Chuan wrote:
> On Sun, Feb 3, 2013 at 10:37 PM, John Keeping <john@keeping.me.uk> wrote:
> > When compiling combine-diff.c, clang 3.2 says:
> >
> >     combine-diff.c:1006:19: warning: adding 'int' to a string does not
> >             append to the string [-Wstring-plus-int]
> >                 prefix = COLONS + offset;
> >                          ~~~~~~~^~~~~~~~
> >     combine-diff.c:1006:19: note: use array indexing to silence this warning
> >                 prefix = COLONS + offset;
> >                                 ^
> >                          &      [       ]
> >
> > Suppress this by making the suggested change.
> >
> > Signed-off-by: John Keeping <john@keeping.me.uk>
> > ---
> >  combine-diff.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/combine-diff.c b/combine-diff.c
> > index bb1cc96..dba4748 100644
> > --- a/combine-diff.c
> > +++ b/combine-diff.c
> > @@ -1003,7 +1003,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
> >                 offset = strlen(COLONS) - num_parent;
> >                 if (offset < 0)
> >                         offset = 0;
> > -               prefix = COLONS + offset;
> > +               prefix = &COLONS[offset];
> >
> >                 /* Show the modes */
> >                 for (i = 0; i < num_parent; i++) {
> 
> Hmm, does
> 
>                prefix = (const char *) COLONS + offset;
> 
> suppress the warning?

It does, but it turns out that the following also suppresses the
warning:

-- >8 --

diff --git a/combine-diff.c b/combine-diff.c
index bb1cc96..a07d329 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -982,7 +982,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 	free(sline);
 }
 
-#define COLONS "::::::::::::::::::::::::::::::::"
+static const char COLONS[] = "::::::::::::::::::::::::::::::::";
 
 static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev)
 {

I think that's a nicer change than the original suggestion.


John

  reply	other threads:[~2013-02-03 19:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-03 14:37 [PATCH 0/3] Make Git compile warning-free with Clang John Keeping
2013-02-03 14:37 ` [PATCH 1/3] fix clang -Wtautological-compare with unsigned enum John Keeping
2013-02-03 19:38   ` Jonathan Nieder
2013-02-03 14:37 ` [PATCH 2/3] combine-diff: suppress a clang warning John Keeping
2013-02-03 18:20   ` Tay Ray Chuan
2013-02-03 19:06     ` John Keeping [this message]
2013-02-03 19:58   ` Junio C Hamano
2013-02-03 20:31     ` John Keeping
2013-02-03 21:07       ` Junio C Hamano
2013-02-03 23:15         ` John Keeping
2013-02-04  0:24           ` Junio C Hamano
2013-02-05 20:25             ` [PATCH] t4038: add tests for "diff --cc --raw <trees>" John Keeping
2013-02-05 20:48               ` Junio C Hamano
2013-02-05 21:39                 ` [PATCH v2] " John Keeping
2013-02-05 22:27                   ` Junio C Hamano
2013-02-07  4:12           ` [PATCH 2/3] combine-diff: suppress a clang warning Miles Bader
2013-02-07  8:41             ` John Keeping
2013-02-03 14:37 ` [PATCH 3/3] builtin/apply: tighten (dis)similarity index parsing John Keeping
2013-02-03 20:50   ` Junio C Hamano
2013-02-03 17:13 ` [PATCH 0/3] Make Git compile warning-free with Clang Antoine Pelisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130203190621.GT1342@serenity.lan \
    --to=john@keeping.me.uk \
    --cc=apelisse@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=rctay89@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).