[PATCH 2/2] do not check truth value of flex arrays
- From
Jeff King <peff@peff.net>
- Date
- Jan 28, 2015, 17:58 UTC
- Message-ID
- <20150128175850.GB8172@peff.net>
- 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