]> granicus.if.org Git - graphviz/commitdiff
handle unexpected getopt errors in nop
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 29 May 2021 17:45:32 +0000 (10:45 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Jun 2021 00:01:14 +0000 (17:01 -0700)
This case is never expected to be reachable. However, having a default case
helps catch when new options are introduced in the getopt call but not handled
in the switch. In a sense, this is a defensive coding measure. This also
squashes a -Wswitch-default compiler warning.

cmd/tools/nop.c

index 324c7df4eb26550b2c2ed9a0b8743df5d9644cd8..a36fd7a97dfae937f2f4f22d29329aab0ec379e1 100644 (file)
@@ -53,6 +53,9 @@ static void init(int argc, char *argv[])
                usage(1);
            }
            break;
+       default:
+           fprintf(stderr, "nop: unexpected error\n");
+           exit(EXIT_FAILURE);
        }
     }
     argv += optind;