public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jeff King <peff@peff•net>
To: git@vger•kernel.org
Cc: Junio C Hamano <gitster@pobox•com>
Subject: [PATCH 2/2] do not check truth value of flex arrays
Date: Wed, 28 Jan 2015 12:58:50 -0500	[thread overview]
Message-ID: <20150128175850.GB8172@peff.net> (raw)
In-Reply-To: <20150128175314.GA13362@peff.net>

There is no point in checking "!ref->name" when ref is a
"struct ref". The name field is a flex-array, and there
always has a non-zero address. This is almost certainly not
hurting anything, but it does cause clang-3.6 to complain.

Signed-off-by: Jeff King <peff@peff•net>
---
Note that even if "ref" is NULL, this is still going to be
"0+offsetof(name)". So short of unsigned pointer wrap-around, I do not
think this check can ever do anything.

 remote-curl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/remote-curl.c b/remote-curl.c
index dd63bc2..515ac9b 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -760,7 +760,7 @@ static int fetch_git(struct discovery *heads,
 
 	for (i = 0; i < nr_heads; i++) {
 		struct ref *ref = to_fetch[i];
-		if (!ref->name || !*ref->name)
+		if (!*ref->name)
 			die("cannot fetch by sha1 over smart http");
 		packet_buf_write(&preamble, "%s %s\n",
 				 sha1_to_hex(ref->old_sha1), ref->name);
-- 
2.3.0.rc1.287.g761fd19

      parent reply	other threads:[~2015-01-28 21:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28 17:53 [PATCH 0/2] silence clang-3.6 warnings Jeff King
2015-01-28 17:57 ` [PATCH 1/2] read_and_strip_branch: fix typo'd address-of operator Jeff King
2015-01-28 20:42   ` Junio C Hamano
2015-01-28 22:57     ` Jeff King
2015-01-29  6:22       ` Junio C Hamano
2015-01-28 17:58 ` Jeff King [this message]

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=20150128175850.GB8172@peff.net \
    --to=peff@peff$(echo .)net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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