git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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?
Previous: Jonathan NiederNext: Andi Kleen
Message 13 of 20 in “Add option to disable NORETURN”
  1. 1/3 Add option to disable NORETURNAndi Kleen, Jun 19, 2011
  2. 2/3 Add a lot of dummy returns to avoid warnings with NO_NORETURNAndi Kleen, Jun 19, 2011
  3. Junio C HamanoJun 20, 2011
  4. Andi KleenJun 20, 2011
  5. Junio C HamanoJun 20, 2011
  6. Andi KleenJun 20, 2011
  7. Jonathan NiederJun 20, 2011
  8. Andi KleenJun 20, 2011
  9. Jonathan NiederJun 20, 2011
  10. Jonathan NiederJun 20, 2011
  11. Andi KleenJun 21, 2011
  12. Jonathan NiederJun 21, 2011
  13. Junio C HamanoJun 20, 2011
  14. Andi KleenJun 21, 2011
  15. Junio C HamanoJun 20, 2011
  16. Andi KleenJun 20, 2011
  17. Junio C HamanoJun 20, 2011
  18. Andi KleenJun 20, 2011
  19. Junio C HamanoJun 21, 2011
  20. 3/3 Add profile feedback build to git v2Andi Kleen, Jun 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.