Commit 585cb1d4 authored by Ian Campbell's avatar Ian Campbell Committed by Andre Przywara
Browse files

Fix two warnings about implicit fallthrough.



In the first case:

    pio.c: In function ‘main’:
    pio.c:355:4: warning: this statement may fall through [-Wimplicit-fallthrough=]
        usage(0);
        ^~~~~~~~
    pio.c:356:3: note: here
       case 'm':
       ^~~~

The fallthrough is not intended because `usage()` never returns (it calls
`exit` unconditionally). Annotate as `noreturn` so the compiler realises this.

In the second case:

    fexc.c: In function ‘main’:
    fexc.c:312:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
       filename[1] = argv[optind+1]; /* out */
       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
    fexc.c:313:2: note: here
      case 1:
      ^~~~

The fallthrough appears to be intended (the two argument case is a superset of
the one argument case). Annotate with a comment which tells the compiler this
is intended.
Signed-off-by: default avatarIan Campbell <ijc@hellion.org.uk>
parent fbe2dee7
...@@ -310,6 +310,7 @@ show_usage: ...@@ -310,6 +310,7 @@ show_usage:
switch (argc - optind) { switch (argc - optind) {
case 2: case 2:
filename[1] = argv[optind+1]; /* out */ filename[1] = argv[optind+1]; /* out */
/* fall-through */
case 1: case 1:
if (strcmp(argv[optind], "-") != 0) if (strcmp(argv[optind], "-") != 0)
filename[0] = argv[optind]; /* in */ filename[0] = argv[optind]; /* in */
......
...@@ -165,7 +165,7 @@ static void print(const char *buf) ...@@ -165,7 +165,7 @@ static void print(const char *buf)
static const char *argv0; static const char *argv0;
static void usage(int rc ) static __attribute__((noreturn)) void usage(int rc )
{ {
fputs("sunxi-pio " VERSION "\n\n", stderr); fputs("sunxi-pio " VERSION "\n\n", stderr);
fprintf(stderr, "usage: %s -m|-i input [-o output] pin..\n", argv0); fprintf(stderr, "usage: %s -m|-i input [-o output] pin..\n", argv0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment