Discussion:
[PATCH] argp: state that argp_error does not return
(too old to reply)
Pavel Raiskup
2017-09-08 06:36:04 UTC
Permalink
Raw Message
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
Paul Eggert
2017-09-08 07:03:51 UTC
Permalink
Raw Message
This change doesn't look right, since argp_error does return sometimes. How
about fixing the problem entirely in the caller instead?

Loading...