On 07/17/2014 03:00 AM, Jim Meyering wrote: > On Wed, Jul 16, 2014 at 3:43 PM, Bernhard Voelker > <m...@bernhard-voelker.de> wrote: >> case 'h': >> (*usage_func) (EXIT_SUCCESS); >> + exit (EXIT_SUCCESS); > > Does that elicit a dead-code warning, when some static analysis > tool notices the statement after an always-"noreturn" function call?
Good point. Unfortunately, it's not possible to run the online coverity analysis too often, so I went with the following ... > What do you think about adding the noreturn attribute to the > declaration of the usage_func parameter? I added "_Noreturn" like this: diff --git a/lib/long-options.c b/lib/long-options.c index fa7d1cd..0af7c0d 100644 --- a/lib/long-options.c +++ b/lib/long-options.c @@ -46,7 +46,7 @@ parse_long_options (int argc, const char *command_name, const char *package, const char *version, - void (*usage_func) (int), + _Noreturn void (*usage_func) (int), /* const char *author1, ...*/ ...) { int c; diff --git a/lib/long-options.h b/lib/long-options.h index a44ae2e..18ad6d6 100644 --- a/lib/long-options.h +++ b/lib/long-options.h @@ -22,5 +22,5 @@ void parse_long_options (int _argc, const char *_command_name, const char *_package, const char *_version, - void (*_usage) (int), + _Noreturn void (*_usage) (int), /* const char *author1, ...*/ ...); but coverity seems to ignore it, and still complains about the fall-through. So I wonder if I shall go another loop with the initial exit() approach to see if there's a dead-code warning then. (Due to restrictions of the free coverity scan I have to wait another 24 hours for the next run.) Thank you both & have a nice day, Berny