From e4b10b87ed18a4435722a29d6a235da15cf462f1 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 29 May 2021 10:45:32 -0700 Subject: [PATCH] handle unexpected getopt errors in nop 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/tools/nop.c b/cmd/tools/nop.c index 324c7df4e..a36fd7a97 100644 --- a/cmd/tools/nop.c +++ b/cmd/tools/nop.c @@ -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; -- 2.50.1