From cb2fcfc0a1da3cfac9094abf1d11c23653937395 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 21 Sep 2017 13:36:42 +0200 Subject: 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 --- nand-utils/nftl_format.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'nand-utils/nftl_format.c') diff --git a/nand-utils/nftl_format.c b/nand-utils/nftl_format.c index ec87604..c8b8b50 100644 --- a/nand-utils/nftl_format.c +++ b/nand-utils/nftl_format.c @@ -198,7 +198,7 @@ static int checkbbt(void) return (0); } -static void usage(int rc) +static NORETURN void usage(int rc) { fprintf(stderr, "Usage: %s [-ib] [ []]\n", PROGRAM_NAME); exit(rc); @@ -250,13 +250,11 @@ int main(int argc, char **argv) case 'h': case '?': usage(EXIT_SUCCESS); - break; case 'V': display_version(); break; default: usage(EXIT_FAILURE); - break; } } -- cgit v1.2.3