util/cbmem: Handle arguments more carefully

Check if all arguments are handled by getopt and if not print the usage.

Change-Id: Iccbb65ca768a62791af54afd9b7903495bc690af
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/27777
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Arthur Heymans 2018-08-01 17:21:32 +02:00 committed by Patrick Georgi
parent 4af5d9a94a
commit 8cd17eae2f
1 changed files with 5 additions and 0 deletions

View File

@ -1327,6 +1327,11 @@ int main(int argc, char** argv)
} }
} }
if (optind < argc) {
fprintf(stderr, "Error: Extra parameter found.\n");
print_usage(argv[0], 1);
}
mem_fd = open("/dev/mem", O_RDONLY, 0); mem_fd = open("/dev/mem", O_RDONLY, 0);
if (mem_fd < 0) { if (mem_fd < 0) {
fprintf(stderr, "Failed to gain memory access: %s\n", fprintf(stderr, "Failed to gain memory access: %s\n",