From 4cfc1cd70a269c8a27f8d2ef0ac5e7eaebaae8b5 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 19 Nov 2021 08:06:23 +0100 Subject: [PATCH] Assert that long options are correctly set --- app/src/cli.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/cli.c b/app/src/cli.c index 1550c706..dabcaaf5 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -569,6 +569,10 @@ sc_getopt_adapter_create_longopts(void) { size_t out_idx = 0; for (size_t i = 0; i < ARRAY_LEN(options); ++i) { const struct sc_option *in = &options[i]; + + // If longopt_id is set, then longopt must be set + assert(!in->longopt_id || in->longopt); + if (!in->longopt) { // The longopts array must only contain long options continue;