util/bucts: Fix compiler complaints shown with -Wextra

This fixes the following 2 complaints:

bucts.c: In function ‘main’:
error: unused parameter ‘envp’
error: ‘bucts_state’ may be used uninitialized in this function.

The bucts_state wasn't real, but the compiler couldn't tell, so use
one variable to check for modifications instead of two.

Signed-off-by: Martin Roth <martin@coreboot.org>
Change-Id: Iff1aae3441ec366d272e88b6b6634980d61cb8ea
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50846
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Martin Roth 2021-02-14 14:30:24 -07:00 committed by Patrick Georgi
parent a84414a0fe
commit 90a43067dd
1 changed files with 7 additions and 9 deletions

View File

@ -38,6 +38,7 @@ enum {
}; };
enum { enum {
BUCTS_UNINITIALIZED = -1,
BUCTS_UNSET = 0, BUCTS_UNSET = 0,
BUCTS_SET BUCTS_SET
}; };
@ -297,7 +298,7 @@ out:
return ret; return ret;
} }
int main(int argc, char *argv[], const char *envp[]) int main(int argc, char *argv[])
{ {
struct pci_access *pacc; struct pci_access *pacc;
struct pci_dev *dev, *sb = NULL; struct pci_dev *dev, *sb = NULL;
@ -306,8 +307,7 @@ int main(int argc, char *argv[], const char *envp[])
#endif #endif
int opt, option_index = 0; int opt, option_index = 0;
int print_state = 0; int print_state = 0;
int change_state = 0; int bucts_state = BUCTS_UNINITIALIZED;
int bucts_state;
static struct option long_options[] = { static struct option long_options[] = {
{"unset", 0, 0, 'u'}, {"unset", 0, 0, 'u'},
@ -329,7 +329,7 @@ int main(int argc, char *argv[], const char *envp[])
long_options, &option_index)) != EOF) { long_options, &option_index)) != EOF) {
switch (opt) { switch (opt) {
case 'u': case 'u':
if (change_state) { if (bucts_state != BUCTS_UNINITIALIZED) {
printf("Invalid setting: multiple set/unset arguments\n"); printf("Invalid setting: multiple set/unset arguments\n");
exit(1); exit(1);
} }
@ -338,10 +338,9 @@ int main(int argc, char *argv[], const char *envp[])
exit(1); exit(1);
} }
bucts_state = BUCTS_UNSET; bucts_state = BUCTS_UNSET;
change_state = 1;
break; break;
case 's': case 's':
if (change_state) { if (bucts_state != BUCTS_UNINITIALIZED) {
printf("Invalid setting: multiple set/unset arguments\n"); printf("Invalid setting: multiple set/unset arguments\n");
exit(1); exit(1);
} }
@ -350,10 +349,9 @@ int main(int argc, char *argv[], const char *envp[])
exit(1); exit(1);
} }
bucts_state = BUCTS_SET; bucts_state = BUCTS_SET;
change_state = 1;
break; break;
case 'p': case 'p':
if (change_state) { if (bucts_state != BUCTS_UNINITIALIZED) {
printf("Print and Set are mutually exclusive!\n"); printf("Print and Set are mutually exclusive!\n");
exit(1); exit(1);
} }
@ -418,7 +416,7 @@ int main(int argc, char *argv[], const char *envp[])
if (print_state) if (print_state)
print_status(rcba_addr, has_var_bb); print_status(rcba_addr, has_var_bb);
if (change_state) { if (bucts_state != BUCTS_UNINITIALIZED) {
set_bucts(rcba_addr, bucts_state); set_bucts(rcba_addr, bucts_state);
print_status(rcba_addr, has_var_bb); print_status(rcba_addr, has_var_bb);
} }