]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Use consistent struct option declaration
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 2 Aug 2026 13:54:11 +0000 (14:54 +0100)
committerLucas De Marchi <ldemarchi@kernel.org>
Wed, 5 Aug 2026 15:49:45 +0000 (10:49 -0500)
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 <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/453
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
testsuite/testsuite.c
tools/depmod.c
tools/insmod.c
tools/lsmod.c
tools/modinfo.c
tools/modprobe.c
tools/rmmod.c
tools/static-nodes.c

index a55edbac58884e342da0b317c4e3e407259a2b29..87fcefd50c30c1f4674f094c66dad824d72d4381 100644 (file)
@@ -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
index b4f33865ecd96ecb75bd9eb979cf5260cf464e21..66fa37aa111cc1892be426b02022076e1869a682 100644 (file)
@@ -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' },
        {},
 };
 
index 38fcc713f3efe716d4752e621e3bae258475b4e7..17d3fc80cb24dfbcde3efd57ee2eeb87c4a73f27 100644 (file)
 
 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)
index f0b202d2e1dcc4aba3fdacfbf495d90e4a9772f7..a55097f51302240a86ca8357e8589c643f0d4b4c 100644 (file)
 
 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)
index d1e751ff0bbc1d32ed1a213b43ca40acb274729d..334e1a7fe122c7a2b4496a2825517d42710e5be4 100644 (file)
@@ -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)
index 413960cae0f39945a3f2d6509dc4a8c262ae2609..1f655c22f58cb0eddf058dcf3ba627a8278bb09b 100644 (file)
@@ -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)
index e4317f1b546396bdecd2675be3fecb58a480571b..d8504ea69a989670a714d9bf259daf0cf2d85cff 100644 (file)
 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
 };
 
index 005f0060bd1ce54b7433a8977f842f88aacb4e71..18c3d04e0e921fddff436a920f784fe1a64070d4 100644 (file)
@@ -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' },
        {},
 };