Skip to content

Commit 990db69

Browse files
committed
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 <emil.l.velikov@gmail.com>
1 parent cc94b2b commit 990db69

8 files changed

Lines changed: 91 additions & 95 deletions

File tree

testsuite/testsuite.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ static const char *progname;
3434
static int oneshot;
3535
static const char options_short[] = "lhn";
3636
static const struct option options[] = {
37-
{ "list", no_argument, 0, 'l' },
38-
{ "help", no_argument, 0, 'h' },
39-
{ NULL, 0, 0, 0 },
37+
{ "list", no_argument, NULL, 'l' },
38+
{ "help", no_argument, NULL, 'h' },
39+
{},
4040
};
4141

4242
#define TEST_TIMEOUT_USEC 2 * USEC_PER_SEC

tools/depmod.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@ static const char *const default_cfg_paths[] = {
5252

5353
static const char cmdopts_s[] = "aAb:m:o:C:E:F:evnP:wVh";
5454
static const struct option cmdopts[] = {
55-
{ "all", no_argument, 0, 'a' },
56-
{ "quick", no_argument, 0, 'A' },
57-
{ "basedir", required_argument, 0, 'b' },
58-
{ "moduledir", required_argument, 0, 'm' },
59-
{ "outdir", required_argument, 0, 'o' },
60-
{ "config", required_argument, 0, 'C' },
61-
{ "symvers", required_argument, 0, 'E' },
62-
{ "filesyms", required_argument, 0, 'F' },
63-
{ "errsyms", no_argument, 0, 'e' },
64-
{ "verbose", no_argument, 0, 'v' },
65-
{ "show", no_argument, 0, 'n' },
66-
{ "dry-run", no_argument, 0, 'n' },
67-
{ "symbol-prefix", required_argument, 0, 'P' },
68-
{ "warn", no_argument, 0, 'w' },
69-
{ "version", no_argument, 0, 'V' },
70-
{ "help", no_argument, 0, 'h' },
55+
{ "all", no_argument, NULL, 'a' },
56+
{ "quick", no_argument, NULL, 'A' },
57+
{ "basedir", required_argument, NULL, 'b' },
58+
{ "moduledir", required_argument, NULL, 'm' },
59+
{ "outdir", required_argument, NULL, 'o' },
60+
{ "config", required_argument, NULL, 'C' },
61+
{ "symvers", required_argument, NULL, 'E' },
62+
{ "filesyms", required_argument, NULL, 'F' },
63+
{ "errsyms", no_argument, NULL, 'e' },
64+
{ "verbose", no_argument, NULL, 'v' },
65+
{ "show", no_argument, NULL, 'n' },
66+
{ "dry-run", no_argument, NULL, 'n' },
67+
{ "symbol-prefix", required_argument, NULL, 'P' },
68+
{ "warn", no_argument, NULL, 'w' },
69+
{ "version", no_argument, NULL, 'V' },
70+
{ "help", no_argument, NULL, 'h' },
7171
{},
7272
};
7373

tools/insmod.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818

1919
static const char cmdopts_s[] = "fsvVh";
2020
static const struct option cmdopts[] = {
21-
// clang-format off
22-
{ "force", no_argument, 0, 'f' },
23-
{ "force-modversion", no_argument, 0, 2 },
24-
{ "force-vermagic", no_argument, 0, 1 },
25-
{ "syslog", no_argument, 0, 's' },
26-
{ "verbose", no_argument, 0, 'v' },
27-
{ "version", no_argument, 0, 'V' },
28-
{ "help", no_argument, 0, 'h' },
29-
{ NULL, 0, 0, 0 },
30-
// clang-format on
21+
{ "force", no_argument, NULL, 'f' },
22+
{ "force-modversion", no_argument, NULL, 2 },
23+
{ "force-vermagic", no_argument, NULL, 1 },
24+
{ "syslog", no_argument, NULL, 's' },
25+
{ "verbose", no_argument, NULL, 'v' },
26+
{ "version", no_argument, NULL, 'V' },
27+
{ "help", no_argument, NULL, 'h' },
28+
{},
3129
};
3230

3331
static void help(void)

tools/lsmod.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717

1818
static const char cmdopts_s[] = "svVh";
1919
static const struct option cmdopts[] = {
20-
// clang-format off
21-
{ "syslog", no_argument, 0, 's' },
22-
{ "verbose", no_argument, 0, 'v' },
23-
{ "version", no_argument, 0, 'V' },
24-
{ "help", no_argument, 0, 'h' },
25-
{ NULL, 0, 0, 0 },
26-
// clang-format on
20+
{ "syslog", no_argument, NULL, 's' },
21+
{ "verbose", no_argument, NULL, 'v' },
22+
{ "version", no_argument, NULL, 'V' },
23+
{ "help", no_argument, NULL, 'h' },
24+
{},
2725
};
2826

2927
static void help(void)

tools/modinfo.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,19 @@ static int modinfo_alias_do(struct kmod_ctx *ctx, const char *alias)
308308

309309
static const char cmdopts_s[] = "adlpn0mF:k:b:Vh";
310310
static const struct option cmdopts[] = {
311-
{ "author", no_argument, 0, 'a' },
312-
{ "description", no_argument, 0, 'd' },
313-
{ "license", no_argument, 0, 'l' },
314-
{ "parameters", no_argument, 0, 'p' },
315-
{ "filename", no_argument, 0, 'n' },
316-
{ "null", no_argument, 0, '0' },
317-
{ "modname", no_argument, 0, 'm' },
318-
{ "field", required_argument, 0, 'F' },
319-
{ "set-version", required_argument, 0, 'k' },
320-
{ "basedir", required_argument, 0, 'b' },
321-
{ "version", no_argument, 0, 'V' },
322-
{ "help", no_argument, 0, 'h' },
323-
{ NULL, 0, 0, 0 },
311+
{ "author", no_argument, NULL, 'a' },
312+
{ "description", no_argument, NULL, 'd' },
313+
{ "license", no_argument, NULL, 'l' },
314+
{ "parameters", no_argument, NULL, 'p' },
315+
{ "filename", no_argument, NULL, 'n' },
316+
{ "null", no_argument, NULL, '0' },
317+
{ "modname", no_argument, NULL, 'm' },
318+
{ "field", required_argument, NULL, 'F' },
319+
{ "set-version", required_argument, NULL, 'k' },
320+
{ "basedir", required_argument, NULL, 'b' },
321+
{ "version", no_argument, NULL, 'V' },
322+
{ "help", no_argument, NULL, 'h' },
323+
{},
324324
};
325325

326326
static void help(void)

tools/modprobe.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,43 @@ static int quiet_inuse;
4848

4949
static const char cmdopts_s[] = "arw:RibfDcnC:d:S:sqvVh";
5050
static const struct option cmdopts[] = {
51-
{ "all", no_argument, 0, 'a' },
52-
53-
{ "remove", no_argument, 0, 'r' },
54-
{ "remove-dependencies", no_argument, 0, 7 },
55-
{ "remove-holders", no_argument, 0, 5 },
56-
{ "wait", required_argument, 0, 'w' },
57-
58-
{ "resolve-alias", no_argument, 0, 8 },
59-
{ "show-alias", no_argument, 0, 'R' },
60-
{ "first-time", no_argument, 0, 3 },
61-
{ "ignore-install", no_argument, 0, 'i' },
62-
{ "ignore-remove", no_argument, 0, 'i' },
63-
{ "use-blacklist", no_argument, 0, 'b' },
64-
{ "force", no_argument, 0, 'f' },
65-
{ "force-modversion", no_argument, 0, 2 },
66-
{ "force-vermagic", no_argument, 0, 1 },
67-
68-
{ "show-depends", no_argument, 0, 'D' },
69-
{ "showconfig", no_argument, 0, 9 },
70-
{ "show-config", no_argument, 0, 'c' },
71-
{ "show-modversions", no_argument, 0, 4 },
72-
{ "dump-modversions", no_argument, 0, 10 },
73-
{ "show-exports", no_argument, 0, 6 },
74-
75-
{ "dry-run", no_argument, 0, 'n' },
76-
{ "show", no_argument, 0, 11 },
77-
78-
{ "config", required_argument, 0, 'C' },
79-
{ "dirname", required_argument, 0, 'd' },
80-
{ "set-version", required_argument, 0, 'S' },
81-
82-
{ "syslog", no_argument, 0, 's' },
83-
{ "quiet", no_argument, 0, 'q' },
84-
{ "verbose", no_argument, 0, 'v' },
85-
{ "version", no_argument, 0, 'V' },
86-
{ "help", no_argument, 0, 'h' },
87-
{ NULL, 0, 0, 0 },
51+
{ "all", no_argument, NULL, 'a' },
52+
53+
{ "remove", no_argument, NULL, 'r' },
54+
{ "remove-dependencies", no_argument, NULL, 7 },
55+
{ "remove-holders", no_argument, NULL, 5 },
56+
{ "wait", required_argument, NULL, 'w' },
57+
58+
{ "resolve-alias", no_argument, NULL, 8 },
59+
{ "show-alias", no_argument, NULL, 'R' },
60+
{ "first-time", no_argument, NULL, 3 },
61+
{ "ignore-install", no_argument, NULL, 'i' },
62+
{ "ignore-remove", no_argument, NULL, 'i' },
63+
{ "use-blacklist", no_argument, NULL, 'b' },
64+
{ "force", no_argument, NULL, 'f' },
65+
{ "force-modversion", no_argument, NULL, 2 },
66+
{ "force-vermagic", no_argument, NULL, 1 },
67+
68+
{ "show-depends", no_argument, NULL, 'D' },
69+
{ "showconfig", no_argument, NULL, 9 },
70+
{ "show-config", no_argument, NULL, 'c' },
71+
{ "show-modversions", no_argument, NULL, 4 },
72+
{ "dump-modversions", no_argument, NULL, 10 },
73+
{ "show-exports", no_argument, NULL, 6 },
74+
75+
{ "dry-run", no_argument, NULL, 'n' },
76+
{ "show", no_argument, NULL, 11 },
77+
78+
{ "config", required_argument, NULL, 'C' },
79+
{ "dirname", required_argument, NULL, 'd' },
80+
{ "set-version", required_argument, NULL, 'S' },
81+
82+
{ "syslog", no_argument, NULL, 's' },
83+
{ "quiet", no_argument, NULL, 'q' },
84+
{ "verbose", no_argument, NULL, 'v' },
85+
{ "version", no_argument, NULL, 'V' },
86+
{ "help", no_argument, NULL, 'h' },
87+
{},
8888
};
8989

9090
static void help(void)

tools/rmmod.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
static const char cmdopts_s[] = "fsvVh";
2525
static const struct option cmdopts[] = {
2626
// clang-format off
27-
{ "force", no_argument, 0, 'f' },
28-
{ "syslog", no_argument, 0, 's' },
29-
{ "verbose", no_argument, 0, 'v' },
30-
{ "version", no_argument, 0, 'V' },
31-
{ "help", no_argument, 0, 'h' },
32-
{ NULL, 0, 0, 0 },
27+
{ "force", no_argument, NULL, 'f' },
28+
{ "syslog", no_argument, NULL, 's' },
29+
{ "verbose", no_argument, NULL, 'v' },
30+
{ "version", no_argument, NULL, 'V' },
31+
{ "help", no_argument, NULL, 'h' },
32+
{},
3333
// clang-format on
3434
};
3535

tools/static-nodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ static const struct static_nodes_format *const static_nodes_formats[] = {
4141

4242
static const char cmdopts_s[] = "o:f:h";
4343
static const struct option cmdopts[] = {
44-
{ "output", required_argument, 0, 'o' },
45-
{ "format", required_argument, 0, 'f' },
46-
{ "help", no_argument, 0, 'h' },
44+
{ "output", required_argument, NULL, 'o' },
45+
{ "format", required_argument, NULL, 'f' },
46+
{ "help", no_argument, NULL, 'h' },
4747
{},
4848
};
4949

0 commit comments

Comments
 (0)