Consult the array when determining whether a given option is followed by an argument or not instead of hard-coding those that do. The array holds both short and long option name, so one extra pitfall removed. Signed-off-by: Phil Sutter <phil@xxxxxx> --- src/main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index c3c7fe23baa37..d3491cda7f8db 100644 --- a/src/main.c +++ b/src/main.c @@ -325,6 +325,7 @@ static bool nft_options_check(int argc, char * const argv[]) { bool skip = false, nonoption = false; int pos = 0, i; + size_t j; for (i = 1; i < argc; i++) { pos += strlen(argv[i - 1]) + 1; @@ -341,16 +342,14 @@ static bool nft_options_check(int argc, char * const argv[]) nft_options_error(argc, argv, pos); return false; } - if (argv[i][1] == 'd' || - argv[i][1] == 'I' || - argv[i][1] == 'f' || - argv[i][1] == 'D' || - !strcmp(argv[i], "--debug") || - !strcmp(argv[i], "--includepath") || - !strcmp(argv[i], "--define") || - !strcmp(argv[i], "--file")) { - skip = true; - continue; + for (j = 0; j < NR_NFT_OPTIONS; j++) { + if (nft_options[j].arg && + (argv[i][1] == (char)nft_options[j].val || + (argv[i][1] == '-' && + !strcmp(argv[i] + 2, nft_options[j].name)))) { + skip = true; + break; + } } } -- 2.41.0