bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] argp: state that argp_error does not return


From: Pavel Raiskup
Subject: [PATCH] argp: state that argp_error does not return
Date: Fri, 8 Sep 2017 08:36:04 +0200

Issue observed because the new GCC 7 -Wimplicit-fallthrough is
whining when useless 'break;' is not specified after argp_error
call.

* lib/argp.h (__argp_error): Declare as _Noreturn.
* lib/argp-help.c (__argp_error): Explicitly throw backtrace if
the function was about to return.
---
 lib/argp-help.c | 1 +
 lib/argp.h      | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/argp-help.c b/lib/argp-help.c
index ce9bab963..a95642eb8 100644
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -1804,6 +1804,7 @@ __argp_error (const struct argp_state *state, const char 
*fmt, ...)
 #endif
         }
     }
+  assert (0);
 }
 #ifdef weak_alias
 weak_alias (__argp_error, argp_error)
diff --git a/lib/argp.h b/lib/argp.h
index 2a7bf5c37..e84b24108 100644
--- a/lib/argp.h
+++ b/lib/argp.h
@@ -530,8 +530,8 @@ extern void __argp_usage (const struct argp_state *__state);
 extern void argp_error (const struct argp_state *__restrict __state,
                         const char *__restrict __fmt, ...)
      _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
-extern void __argp_error (const struct argp_state *__restrict __state,
-                          const char *__restrict __fmt, ...)
+extern _Noreturn void __argp_error (const struct argp_state *__restrict 
__state,
+                                    const char *__restrict __fmt, ...)
      _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
 
 /* Similar to the standard gnu error-reporting function error(), but will
-- 
2.13.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]