From: Emil Velikov Date: Sun, 2 Aug 2026 13:54:11 +0000 (+0100) Subject: Use consistent struct option declaration X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce096eab3c2be53752f2a86924ae22f9f2b65dce;p=thirdparty%2Fkmod.git Use consistent struct option declaration The struct option::flag is of type "int *", so we should be using NULL instead of 0. In addition, the sentinel entry can be left completely empty. With those in place, we can drop most of the clang-format notations. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/453 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index a55edbac..87fcefd5 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -34,9 +34,9 @@ static const char *progname; static int oneshot; static const char options_short[] = "lhn"; static const struct option options[] = { - { "list", no_argument, 0, 'l' }, - { "help", no_argument, 0, 'h' }, - { NULL, 0, 0, 0 }, + { "list", no_argument, NULL, 'l' }, + { "help", no_argument, NULL, 'h' }, + {}, }; #define TEST_TIMEOUT_USEC 2 * USEC_PER_SEC diff --git a/tools/depmod.c b/tools/depmod.c index b4f33865..66fa37aa 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -52,22 +52,22 @@ static const char *const default_cfg_paths[] = { static const char cmdopts_s[] = "aAb:m:o:C:E:F:evnP:wVh"; static const struct option cmdopts[] = { - { "all", no_argument, 0, 'a' }, - { "quick", no_argument, 0, 'A' }, - { "basedir", required_argument, 0, 'b' }, - { "moduledir", required_argument, 0, 'm' }, - { "outdir", required_argument, 0, 'o' }, - { "config", required_argument, 0, 'C' }, - { "symvers", required_argument, 0, 'E' }, - { "filesyms", required_argument, 0, 'F' }, - { "errsyms", no_argument, 0, 'e' }, - { "verbose", no_argument, 0, 'v' }, - { "show", no_argument, 0, 'n' }, - { "dry-run", no_argument, 0, 'n' }, - { "symbol-prefix", required_argument, 0, 'P' }, - { "warn", no_argument, 0, 'w' }, - { "version", no_argument, 0, 'V' }, - { "help", no_argument, 0, 'h' }, + { "all", no_argument, NULL, 'a' }, + { "quick", no_argument, NULL, 'A' }, + { "basedir", required_argument, NULL, 'b' }, + { "moduledir", required_argument, NULL, 'm' }, + { "outdir", required_argument, NULL, 'o' }, + { "config", required_argument, NULL, 'C' }, + { "symvers", required_argument, NULL, 'E' }, + { "filesyms", required_argument, NULL, 'F' }, + { "errsyms", no_argument, NULL, 'e' }, + { "verbose", no_argument, NULL, 'v' }, + { "show", no_argument, NULL, 'n' }, + { "dry-run", no_argument, NULL, 'n' }, + { "symbol-prefix", required_argument, NULL, 'P' }, + { "warn", no_argument, NULL, 'w' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, {}, }; diff --git a/tools/insmod.c b/tools/insmod.c index 38fcc713..17d3fc80 100644 --- a/tools/insmod.c +++ b/tools/insmod.c @@ -18,16 +18,14 @@ static const char cmdopts_s[] = "fsvVh"; static const struct option cmdopts[] = { - // clang-format off - { "force", no_argument, 0, 'f' }, - { "force-modversion", no_argument, 0, 2 }, - { "force-vermagic", no_argument, 0, 1 }, - { "syslog", no_argument, 0, 's' }, - { "verbose", no_argument, 0, 'v' }, - { "version", no_argument, 0, 'V' }, - { "help", no_argument, 0, 'h' }, - { NULL, 0, 0, 0 }, - // clang-format on + { "force", no_argument, NULL, 'f' }, + { "force-modversion", no_argument, NULL, 2 }, + { "force-vermagic", no_argument, NULL, 1 }, + { "syslog", no_argument, NULL, 's' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + {}, }; static void help(void) diff --git a/tools/lsmod.c b/tools/lsmod.c index f0b202d2..a55097f5 100644 --- a/tools/lsmod.c +++ b/tools/lsmod.c @@ -17,13 +17,11 @@ static const char cmdopts_s[] = "svVh"; static const struct option cmdopts[] = { - // clang-format off - { "syslog", no_argument, 0, 's' }, - { "verbose", no_argument, 0, 'v' }, - { "version", no_argument, 0, 'V' }, - { "help", no_argument, 0, 'h' }, - { NULL, 0, 0, 0 }, - // clang-format on + { "syslog", no_argument, NULL, 's' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + {}, }; static void help(void) diff --git a/tools/modinfo.c b/tools/modinfo.c index d1e751ff..334e1a7f 100644 --- a/tools/modinfo.c +++ b/tools/modinfo.c @@ -308,19 +308,19 @@ static int modinfo_alias_do(struct kmod_ctx *ctx, const char *alias) static const char cmdopts_s[] = "adlpn0mF:k:b:Vh"; static const struct option cmdopts[] = { - { "author", no_argument, 0, 'a' }, - { "description", no_argument, 0, 'd' }, - { "license", no_argument, 0, 'l' }, - { "parameters", no_argument, 0, 'p' }, - { "filename", no_argument, 0, 'n' }, - { "null", no_argument, 0, '0' }, - { "modname", no_argument, 0, 'm' }, - { "field", required_argument, 0, 'F' }, - { "set-version", required_argument, 0, 'k' }, - { "basedir", required_argument, 0, 'b' }, - { "version", no_argument, 0, 'V' }, - { "help", no_argument, 0, 'h' }, - { NULL, 0, 0, 0 }, + { "author", no_argument, NULL, 'a' }, + { "description", no_argument, NULL, 'd' }, + { "license", no_argument, NULL, 'l' }, + { "parameters", no_argument, NULL, 'p' }, + { "filename", no_argument, NULL, 'n' }, + { "null", no_argument, NULL, '0' }, + { "modname", no_argument, NULL, 'm' }, + { "field", required_argument, NULL, 'F' }, + { "set-version", required_argument, NULL, 'k' }, + { "basedir", required_argument, NULL, 'b' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + {}, }; static void help(void) diff --git a/tools/modprobe.c b/tools/modprobe.c index 413960ca..1f655c22 100644 --- a/tools/modprobe.c +++ b/tools/modprobe.c @@ -48,43 +48,43 @@ static int quiet_inuse; static const char cmdopts_s[] = "arw:RibfDcnC:d:S:sqvVh"; static const struct option cmdopts[] = { - { "all", no_argument, 0, 'a' }, - - { "remove", no_argument, 0, 'r' }, - { "remove-dependencies", no_argument, 0, 7 }, - { "remove-holders", no_argument, 0, 5 }, - { "wait", required_argument, 0, 'w' }, - - { "resolve-alias", no_argument, 0, 8 }, - { "show-alias", no_argument, 0, 'R' }, - { "first-time", no_argument, 0, 3 }, - { "ignore-install", no_argument, 0, 'i' }, - { "ignore-remove", no_argument, 0, 'i' }, - { "use-blacklist", no_argument, 0, 'b' }, - { "force", no_argument, 0, 'f' }, - { "force-modversion", no_argument, 0, 2 }, - { "force-vermagic", no_argument, 0, 1 }, - - { "show-depends", no_argument, 0, 'D' }, - { "showconfig", no_argument, 0, 9 }, - { "show-config", no_argument, 0, 'c' }, - { "show-modversions", no_argument, 0, 4 }, - { "dump-modversions", no_argument, 0, 10 }, - { "show-exports", no_argument, 0, 6 }, - - { "dry-run", no_argument, 0, 'n' }, - { "show", no_argument, 0, 11 }, - - { "config", required_argument, 0, 'C' }, - { "dirname", required_argument, 0, 'd' }, - { "set-version", required_argument, 0, 'S' }, - - { "syslog", no_argument, 0, 's' }, - { "quiet", no_argument, 0, 'q' }, - { "verbose", no_argument, 0, 'v' }, - { "version", no_argument, 0, 'V' }, - { "help", no_argument, 0, 'h' }, - { NULL, 0, 0, 0 }, + { "all", no_argument, NULL, 'a' }, + + { "remove", no_argument, NULL, 'r' }, + { "remove-dependencies", no_argument, NULL, 7 }, + { "remove-holders", no_argument, NULL, 5 }, + { "wait", required_argument, NULL, 'w' }, + + { "resolve-alias", no_argument, NULL, 8 }, + { "show-alias", no_argument, NULL, 'R' }, + { "first-time", no_argument, NULL, 3 }, + { "ignore-install", no_argument, NULL, 'i' }, + { "ignore-remove", no_argument, NULL, 'i' }, + { "use-blacklist", no_argument, NULL, 'b' }, + { "force", no_argument, NULL, 'f' }, + { "force-modversion", no_argument, NULL, 2 }, + { "force-vermagic", no_argument, NULL, 1 }, + + { "show-depends", no_argument, NULL, 'D' }, + { "showconfig", no_argument, NULL, 9 }, + { "show-config", no_argument, NULL, 'c' }, + { "show-modversions", no_argument, NULL, 4 }, + { "dump-modversions", no_argument, NULL, 10 }, + { "show-exports", no_argument, NULL, 6 }, + + { "dry-run", no_argument, NULL, 'n' }, + { "show", no_argument, NULL, 11 }, + + { "config", required_argument, NULL, 'C' }, + { "dirname", required_argument, NULL, 'd' }, + { "set-version", required_argument, NULL, 'S' }, + + { "syslog", no_argument, NULL, 's' }, + { "quiet", no_argument, NULL, 'q' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + {}, }; static void help(void) diff --git a/tools/rmmod.c b/tools/rmmod.c index e4317f1b..d8504ea6 100644 --- a/tools/rmmod.c +++ b/tools/rmmod.c @@ -24,12 +24,12 @@ static const char cmdopts_s[] = "fsvVh"; static const struct option cmdopts[] = { // clang-format off - { "force", no_argument, 0, 'f' }, - { "syslog", no_argument, 0, 's' }, - { "verbose", no_argument, 0, 'v' }, - { "version", no_argument, 0, 'V' }, - { "help", no_argument, 0, 'h' }, - { NULL, 0, 0, 0 }, + { "force", no_argument, NULL, 'f' }, + { "syslog", no_argument, NULL, 's' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + {}, // clang-format on }; diff --git a/tools/static-nodes.c b/tools/static-nodes.c index 005f0060..18c3d04e 100644 --- a/tools/static-nodes.c +++ b/tools/static-nodes.c @@ -41,9 +41,9 @@ static const struct static_nodes_format *const static_nodes_formats[] = { static const char cmdopts_s[] = "o:f:h"; static const struct option cmdopts[] = { - { "output", required_argument, 0, 'o' }, - { "format", required_argument, 0, 'f' }, - { "help", no_argument, 0, 'h' }, + { "output", required_argument, NULL, 'o' }, + { "format", required_argument, NULL, 'f' }, + { "help", no_argument, NULL, 'h' }, {}, };