Pass NULL, not 0, handle invalid --id better.
This commit is contained in:
parent
54c841f7b5
commit
4c544102c3
1 changed files with 5 additions and 4 deletions
|
@ -273,13 +273,13 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
for (i = 1; i < argc; ++i) {
|
for (i = 1; i < argc; ++i) {
|
||||||
if (!strcmp(argv[i], "--help")) {
|
if (!strcmp(argv[i], "--help")) {
|
||||||
return fail(0);
|
return fail(NULL);
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[i], "--root"))
|
else if (!strcmp(argv[i], "--root"))
|
||||||
root = TRUE;
|
root = TRUE;
|
||||||
else if (!strcmp(argv[i], "--id")) {
|
else if (!strcmp(argv[i], "--id")) {
|
||||||
if (++i == argc)
|
if (++i == argc)
|
||||||
return fail(0);
|
return fail(NULL);
|
||||||
if (argv[i][0] == '0' && argv[i][1] == 'x') {
|
if (argv[i][0] == '0' && argv[i][1] == 'x') {
|
||||||
/* hex */
|
/* hex */
|
||||||
userid = parse_hex(argv[i]+2);
|
userid = parse_hex(argv[i]+2);
|
||||||
|
@ -288,11 +288,12 @@ int main(int argc, char **argv)
|
||||||
/* decimal */
|
/* decimal */
|
||||||
userid = atoi(argv[i]);
|
userid = atoi(argv[i]);
|
||||||
}
|
}
|
||||||
break;
|
if (!userid)
|
||||||
|
return fail("Unable to parse argument to --id.");
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[i], "--display")) {
|
else if (!strcmp(argv[i], "--display")) {
|
||||||
if (++i == argc)
|
if (++i == argc)
|
||||||
return fail(0);
|
return fail(NULL);
|
||||||
dname = argv[i];
|
dname = argv[i];
|
||||||
}
|
}
|
||||||
else if (*argv[i] != '-')
|
else if (*argv[i] != '-')
|
||||||
|
|
Loading…
Reference in a new issue