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

Subsystems: the rest

STALE3434d

2 messages, 2 authors, 2017-05-22 · open the first message on its own page

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

From: Ramsay Jones <hidden>
Date: 2017-05-21 22:26:00

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 <redacted>
---

Hi Junio,

This is built on 'next', which has now merged the 'jk/bug-to-abort'
branch.

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);
-- 
2.13.0

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

From: Jeff King <hidden>
Date: 2017-05-22 11:19:28

On Sun, May 21, 2017 at 11:25:39PM +0100, Ramsay Jones wrote:
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 <redacted>
Thanks, I never ended up re-rolling the original, but from our previous
discussion this is obviously fine by me.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help