| 391 | } |
| 392 | |
| 393 | static int process_remove(int argc, char *argv[], const char store_file[]) |
| 394 | { |
| 395 | const char *name = NULL; |
| 396 | const char *guid_str = NULL; |
| 397 | int opt; |
| 398 | while ((opt = getopt(argc, argv, "n:g:")) != -1) { |
| 399 | switch (opt) { |
| 400 | case 'n': |
| 401 | name = optarg; |
| 402 | break; |
| 403 | case 'g': |
| 404 | guid_str = optarg; |
| 405 | break; |
| 406 | |
| 407 | case '?': /* parsing error */ |
| 408 | print_sub_command_usage(argv[0]); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | if (name == NULL || guid_str == NULL) { |
| 413 | fprintf(stderr, "All options are required\n"); |
| 414 | print_sub_command_usage(argv[0]); |
| 415 | } |
| 416 | |
| 417 | EFI_GUID guid; |
| 418 | if (!parse_guid(guid_str, &guid)) { |
| 419 | fprintf(stderr, "Failed to parse GUID: %s\n", guid_str); |
| 420 | return EXIT_FAILURE; |
| 421 | } |
| 422 | |
| 423 | struct storage_t storage; |
| 424 | if (!storage_open(store_file, &storage, /*rw=*/true)) |
| 425 | return EXIT_FAILURE; |
| 426 | |
| 427 | int result = EXIT_SUCCESS; |
| 428 | |
| 429 | struct var_t *var = vs_find(&storage.vs, name, &guid); |
| 430 | if (var == NULL) { |
| 431 | result = EXIT_FAILURE; |
| 432 | fprintf(stderr, "Couldn't find variable \"%s:%s\"\n", |
| 433 | guid_str, name); |
| 434 | } else { |
| 435 | vs_delete(&storage.vs, var); |
| 436 | } |
| 437 | |
| 438 | storage_write_back(&storage); |
| 439 | return result; |
| 440 | } |
| 441 | |
| 442 | static void help_guids(FILE *f, const struct subcommand_t *info) |
| 443 | { |
nothing calls this directly
no test coverage detected