aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-06-11 12:42:42 +0100
committerAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-06-11 16:26:28 +0100
commit55f65905d551d6793b254477bd45302974e5f4b0 (patch)
treefc28ea0a918f050f75a980725c0b18fef1c7eff1
parentc6fb42a68462729c4dfda59b8fc5f9c84c58b68b (diff)
downloadmodule-init-tools-55f65905d551d6793b254477bd45302974e5f4b0.tar.gz
Re-order options to make the code easier to check
options are listed in three places: 1. getopt (long) option array 2. getopt (short) option string 3. the switch statement which handles the options It's easier to check these lists for inconsistencies if all three lists are in the same order. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
-rw-r--r--depmod.c34
-rw-r--r--modprobe.c79
2 files changed, 57 insertions, 56 deletions
diff --git a/depmod.c b/depmod.c
index 68fcaee..25be46f 100644
--- a/depmod.c
+++ b/depmod.c
@@ -172,17 +172,17 @@ static void load_system_map(const char *filename)
static struct option options[] = { { "all", 0, NULL, 'a' },
{ "quick", 0, NULL, 'A' },
{ "basedir", 1, NULL, 'b' },
- { "errsyms", 0, NULL, 'e' },
+ { "config", 1, NULL, 'C' },
{ "filesyms", 1, NULL, 'F' },
- { "help", 0, NULL, 'h' },
- { "show", 0, NULL, 'n' },
- { "dry-run", 0, NULL, 'n' },
+ { "errsyms", 0, NULL, 'e' },
+ { "unresolved-error", 0, NULL, 'u' },
{ "quiet", 0, NULL, 'q' },
{ "root", 0, NULL, 'r' },
- { "unresolved-error", 0, NULL, 'u' },
{ "verbose", 0, NULL, 'v' },
+ { "show", 0, NULL, 'n' },
+ { "dry-run", 0, NULL, 'n' },
+ { "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
- { "config", 1, NULL, 'C' },
{ "warn", 1, NULL, 'w' },
{ "map", 0, NULL, 'm' },
{ NULL, 0, NULL, 0 } };
@@ -1186,18 +1186,21 @@ int main(int argc, char *argv[])
/* Don't print out any errors just yet, we might want to exec
backwards compat version. */
opterr = 0;
- while ((opt = getopt_long(argc, argv, "ab:ArehnqruvVF:C:wm", options, NULL))
+ while ((opt = getopt_long(argc, argv, "aAb:C:F:euqrrvnhVwm", options, NULL))
!= -1) {
switch (opt) {
case 'a':
all = 1;
break;
+ case 'A':
+ maybe_all = 1;
+ break;
case 'b':
basedir = optarg;
skipchars = strlen(basedir);
break;
- case 'A':
- maybe_all = 1;
+ case 'C':
+ config = optarg;
break;
case 'F':
system_map = optarg;
@@ -1205,23 +1208,20 @@ int main(int argc, char *argv[])
case 'e':
print_unknown = 1;
break;
- case 'v':
- verbose = 1;
- break;
case 'u':
case 'q':
case 'r':
break;
- case 'C':
- config = optarg;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'n':
+ doing_stdout = 1;
break;
case 'h':
print_usage(argv[0]);
exit(0);
break;
- case 'n':
- doing_stdout = 1;
- break;
case 'V':
printf("%s %s\n", PACKAGE, VERSION);
exit(0);
diff --git a/modprobe.c b/modprobe.c
index f84663f..872663e 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -1285,31 +1285,31 @@ static int handle_module(const char *modname,
return 0;
}
-static struct option options[] = { { "verbose", 0, NULL, 'v' },
- { "version", 0, NULL, 'V' },
+static struct option options[] = { { "version", 0, NULL, 'V' },
+ { "verbose", 0, NULL, 'v' },
+ { "quiet", 0, NULL, 'q' },
+ { "syslog", 0, NULL, 's' },
+ { "show", 0, NULL, 'n' },
+ { "dry-run", 0, NULL, 'n' },
+ { "show-depends", 0, NULL, 'D' },
+ { "dirname", 1, NULL, 'd' },
+ { "set-version", 1, NULL, 'S' },
{ "config", 1, NULL, 'C' },
{ "name", 1, NULL, 'o' },
{ "remove", 0, NULL, 'r' },
{ "wait", 0, NULL, 'w' },
{ "showconfig", 0, NULL, 'c' },
- { "quiet", 0, NULL, 'q' },
- { "show", 0, NULL, 'n' },
- { "dry-run", 0, NULL, 'n' },
- { "syslog", 0, NULL, 's' },
- { "type", 1, NULL, 't' },
{ "list", 0, NULL, 'l' },
+ { "type", 1, NULL, 't' },
{ "all", 0, NULL, 'a' },
{ "ignore-install", 0, NULL, 'i' },
{ "ignore-remove", 0, NULL, 'i' },
+ { "use-blacklist", 0, NULL, 'b' },
{ "force", 0, NULL, 'f' },
{ "force-vermagic", 0, NULL, 1 },
{ "force-modversion", 0, NULL, 2 },
- { "set-version", 1, NULL, 'S' },
- { "show-depends", 0, NULL, 'D' },
- { "dirname", 1, NULL, 'd' },
{ "first-time", 0, NULL, 3 },
{ "dump-modversions", 0, NULL, 4 },
- { "use-blacklist", 0, NULL, 'b' },
{ NULL, 0, NULL, 0 } };
int main(int argc, char *argv[])
@@ -1344,15 +1344,31 @@ int main(int argc, char *argv[])
argv = merge_args(getenv("MODPROBE_OPTIONS"), argv, &argc);
uname(&buf);
- while ((opt = getopt_long(argc, argv, "vVC:o:rnqQsclt:aifbwd:", options, NULL)) != -1){
+ while ((opt = getopt_long(argc, argv, "Vvqsnd:C:o:rwclt:aQibf", options, NULL)) != -1){
switch (opt) {
+ case 'V':
+ puts(PACKAGE " version " VERSION);
+ exit(0);
case 'v':
add_to_env_var("-v");
verbose = 1;
break;
- case 'V':
- puts(PACKAGE " version " VERSION);
- exit(0);
+ case 'q':
+ quiet = 1;
+ add_to_env_var("-q");
+ break;
+ case 's':
+ add_to_env_var("-s");
+ logging = 1;
+ break;
+ case 'n':
+ dry_run = 1;
+ break;
+
+ case 'd':
+ nofail_asprintf(&dirname, "%s/%s/%s", optarg,
+ MODULE_DIR, buf.release);
+ break;
case 'S':
strncpy(buf.release, optarg, sizeof(buf.release));
buf.release[sizeof(buf.release)-1] = '\0';
@@ -1362,10 +1378,6 @@ int main(int argc, char *argv[])
add_to_env_var("-C");
add_to_env_var(config);
break;
- case 'q':
- quiet = 1;
- add_to_env_var("-q");
- break;
case 'D':
dry_run = 1;
ignore_proc = 1;
@@ -1378,42 +1390,31 @@ int main(int argc, char *argv[])
case 'r':
remove = 1;
break;
+ case 'w':
+ flags &= ~O_NONBLOCK;
+ break;
case 'c':
dump_only = 1;
break;
- case 't':
- type = optarg;
- break;
case 'l':
list_only = 1;
break;
+ case 't':
+ type = optarg;
+ break;
case 'a':
all = 1;
error = warn;
break;
- case 'n':
- dry_run = 1;
- break;
- case 's':
- add_to_env_var("-s");
- logging = 1;
- break;
case 'i':
ignore_commands = 1;
break;
- case 'f':
- strip_vermagic = 1;
- strip_modversion = 1;
- break;
case 'b':
use_blacklist = 1;
break;
- case 'w':
- flags &= ~O_NONBLOCK;
- break;
- case 'd':
- nofail_asprintf(&dirname, "%s/%s/%s", optarg,
- MODULE_DIR, buf.release);
+ case 'f':
+ strip_vermagic = 1;
+ strip_modversion = 1;
break;
case 1:
strip_vermagic = 1;