Make empire, empsched and files catch extra operands

This also avoids a dead increment ap++ in src/client/main.c reported
by the Clang Static Analyzer.
This commit is contained in:
Markus Armbruster 2010-01-16 09:29:53 +01:00
parent fe0ef18e2b
commit 390841a40a
3 changed files with 17 additions and 0 deletions

View file

@ -138,6 +138,11 @@ main(int argc, char **argv)
} }
uname = pwd->pw_name; uname = pwd->pw_name;
} }
if (*ap) {
fprintf(stderr, "%s: extra operand %s\n", argv[0], *ap);
fprintf(stderr, "Try -h for help.\n");
exit(1);
}
getsose(); getsose();
if (auxfname && (auxfp = fopen(auxfname, "a")) == NULL) { if (auxfname && (auxfp = fopen(auxfname, "a")) == NULL) {

View file

@ -92,6 +92,12 @@ main(int argc, char *argv[])
} }
} }
if (argc - optind > 1) {
fprintf(stderr, "%s: extra operand %s\n", argv[0], argv[optind+1]);
fprintf(stderr, "Try -h for help.\n");
exit(1);
}
if (emp_config(config_file) < 0) if (emp_config(config_file) < 0)
exit(1); exit(1);

View file

@ -105,6 +105,12 @@ main(int argc, char *argv[])
} }
} }
if (argv[optind]) {
fprintf(stderr, "%s: does not take operands\n", argv[0]);
fprintf(stderr, "Try -h for help.\n");
exit(1);
}
empfile_init(); empfile_init();
if (emp_config(config_file) < 0) if (emp_config(config_file) < 0)
exit(1); exit(1);