Re: [PATCH 2/3] Add a lot of dummy returns to avoid warnings with NO_NORETURN
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 20, 2011, 23:26 UTC
- Message-ID
- <7v1uyoaxu5.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20110620223705.GG32765@one.firstfloor.org>
Andi Kleen <andi@firstfloor.org> writes:
Show 5 quoted lines
>> Please remember to think for yourself. ;-) Junio generally gives good >> advice, but if you don't see the wisdom in it, that's the time to ask >> questions, not blindly do a wrong thing. > > To be honest it's still not clear to me what was wrong with patch (2).
For example.
diff --git a/builtin/commit.c b/builtin/commit.c
index 5286432..51ee2e5 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -962,6 +962,7 @@ static const char *find_author_by_nickname(const char *name)
return strbuf_detach(&buf, NULL);
}
die(_("No existing author found with '%s'"), name);
+ return NULL;
}When the above is applied and compiled without NO_NORETURN, the extra return may be optimized out by the compiler as your commit log messages said, but wouldn't it introduce a new warning:
builtin/commit.c: In function 'find_author_by_nickname': builtin/commit.c:965: error: will never be executed
under -Wunreachable-code?