util/ectool: Handle arguments more carefully
Check if an argument is given and if not print the usage. Check if all arguments are handled by getopt and if not print the usage. Change-Id: I40dbd2a51d018eb549e9b2fa4365b3e4f9355bff Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/27778 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-by: Evgeny Zinoviev <me@ch1p.com>
This commit is contained in:
parent
8cd17eae2f
commit
cc7a411fc5
|
@ -90,6 +90,11 @@ int main(int argc, char *argv[])
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (argv[1] == NULL) {
|
||||
print_usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "vh?Vidqpw:z:",
|
||||
long_options, &option_index)) != EOF) {
|
||||
switch (opt) {
|
||||
|
@ -128,6 +133,12 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
fprintf(stderr, "Error: Extra parameter found.\n");
|
||||
print_usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (get_ports && get_ec_ports() != 0)
|
||||
fprintf(stderr, "Cannot get EC ports from /proc/ioports, "
|
||||
"fallback to default.");
|
||||
|
|
Loading…
Reference in New Issue