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

Re: [PATCH] usage: add NORETURN to BUG() function definitions

From
Junio C Hamano <gitster@pobox.com>
Date
May 22, 2017, 01:43 UTC
Message-ID
<xmqqpof1psy7.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<4a5619af-d695-ab6c-e603-368e38827455@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 20 quoted lines
> Commit d8193743e0 ("usage.c: add BUG() function", 12-05-2017) added the
> BUG() functions and macros as a replacement for calls to die("BUG: ..").
> The use of NORETURN on the declarations (in git-compat-util.h) and the
> lack of NORETURN on the function definitions, however, leads sparse to
> complain thus:
>
>       SP usage.c
>   usage.c:220:6: error: symbol 'BUG_fl' redeclared with different type
>   (originally declared at git-compat-util.h:1074) - different modifiers
>
> In order to suppress the sparse error, add the NORETURN to the function
> definitions.
>
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>
> Hi Junio,
>
> This is built on 'next', which has now merged the 'jk/bug-to-abort'
> branch.
Thanks.  

I cannot seem to cause sparse (v0.5.0-207-g14964df) to complain the same way, though.

Show 31 quoted lines
>
> Thanks!
>
> ATB,
> Ramsay Jones
>
>  usage.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/usage.c b/usage.c
> index 7e6cb2028..1f63e033e 100644
> --- a/usage.c
> +++ b/usage.c
> @@ -217,7 +217,7 @@ static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_lis
>  }
>  
>  #ifdef HAVE_VARIADIC_MACROS
> -void BUG_fl(const char *file, int line, const char *fmt, ...)
> +NORETURN void BUG_fl(const char *file, int line, const char *fmt, ...)
>  {
>  	va_list ap;
>  	va_start(ap, fmt);
> @@ -225,7 +225,7 @@ void BUG_fl(const char *file, int line, const char *fmt, ...)
>  	va_end(ap);
>  }
>  #else
> -void BUG(const char *fmt, ...)
> +NORETURN void BUG(const char *fmt, ...)
>  {
>  	va_list ap;
>  	va_start(ap, fmt);
Previous: Ramsay JonesNext: Ramsay Jones
Message 2 of 9 in “usage: add NORETURN to BUG() function definitions”
  1. usage: add NORETURN to BUG() function definitionsRamsay Jones, May 21, 2017
  2. Junio C HamanoMay 22, 2017
  3. Ramsay JonesMay 22, 2017
  4. Junio C HamanoMay 22, 2017
  5. Junio C HamanoMay 22, 2017
  6. Ramsay JonesMay 22, 2017
  7. Junio C HamanoMay 23, 2017
  8. Ramsay JonesMay 23, 2017
  9. Jeff KingMay 22, 2017

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.