diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2017-09-21 13:36:42 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2017-11-02 01:33:32 +0100 |
commit | cb2fcfc0a1da3cfac9094abf1d11c23653937395 (patch) | |
tree | 5885e3f6073020ba3b07db35ab2aef73b2726374 /nand-utils/nandtest.c | |
parent | 81fd176a6b4958147302ef900f2651c476a3d4e7 (diff) |
Add no-return attribute to usage() style functions
A common pattern in command line processing is having a usage()
function that prints out how to use the command line options and
then terminates.
The function is typically used inside a switch block for command
line options like `-h' or unknown options. In a lot of places, the
break keyword is omitted, because the function exits anyway. However,
this triggers gcc warnings about implicit fall-through.
Rather than adding a phony "/* fall-through */" this patch flags the
usage() style function with a gcc attribute, indicating that they do
not return and removes further superfluous break statements.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'nand-utils/nandtest.c')
-rw-r--r-- | nand-utils/nandtest.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/nand-utils/nandtest.c b/nand-utils/nandtest.c index d5c7369..06dec25 100644 --- a/nand-utils/nandtest.c +++ b/nand-utils/nandtest.c @@ -17,7 +17,7 @@ #include "mtd/mtd-user.h" #include "common.h" -static void usage(int status) +static NORETURN void usage(int status) { fprintf(status ? stderr : stdout, "usage: %s [OPTIONS] <device>\n\n" @@ -184,14 +184,12 @@ int main(int argc, char **argv) switch (c) { case 'h': usage(EXIT_SUCCESS); - break; case 'V': common_print_version(); exit(EXIT_SUCCESS); break; case '?': usage(EXIT_FAILURE); - break; case 'm': markbad = 1; |