Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/66870 )
Change subject: internal.c: Retype appropriate variables with bool ......................................................................
internal.c: Retype appropriate variables with bool
Use the bool type instead of an integer for the variables `force_laptop`, `not_a_laptop`, `force_boardenable` and `force_boardmismatch` since this represents their purpose much better.
Signed-off-by: Felix Singer felixsinger@posteo.net Change-Id: I159d789112d7a778744b59b45133df3928b8445e Reviewed-on: https://review.coreboot.org/c/flashrom/+/66870 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Anastasia Klimchuk aklm@chromium.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M include/programmer.h M internal.c 2 files changed, 34 insertions(+), 14 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
diff --git a/include/programmer.h b/include/programmer.h index 5331a12..776ac21 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -20,6 +20,7 @@ #ifndef __PROGRAMMER_H__ #define __PROGRAMMER_H__ 1
+#include <stdbool.h> #include <stdint.h>
#include "flash.h" /* for chipaddr and flashctx */ @@ -265,8 +266,8 @@ #if CONFIG_INTERNAL == 1 extern int is_laptop; extern int laptop_ok; -extern int force_boardenable; -extern int force_boardmismatch; +extern bool force_boardenable; +extern bool force_boardmismatch; void probe_superio(void); int register_superio(struct superio s); extern enum chipbustype internal_buses_supported; diff --git a/internal.c b/internal.c index 426730f..ce1debe 100644 --- a/internal.c +++ b/internal.c @@ -16,6 +16,7 @@
#include <strings.h> #include <string.h> +#include <stdbool.h> #include <stdlib.h> #include "flash.h" #include "programmer.h" @@ -29,8 +30,8 @@ int is_laptop = 0; int laptop_ok = 0;
-int force_boardenable = 0; -int force_boardmismatch = 0; +bool force_boardenable = false; +bool force_boardmismatch = false;
enum chipbustype internal_buses_supported = BUS_NONE;
@@ -117,21 +118,21 @@ };
static int get_params(const struct programmer_cfg *cfg, - int *boardenable, int *boardmismatch, - int *force_laptop, int *not_a_laptop, + bool *boardenable, bool *boardmismatch, + bool *force_laptop, bool *not_a_laptop, char **board_vendor, char **board_model) { char *arg;
/* default values. */ - *force_laptop = 0; - *not_a_laptop = 0; + *force_laptop = false; + *not_a_laptop = false; *board_vendor = NULL; *board_model = NULL;
arg = extract_programmer_param_str(cfg, "boardenable"); if (arg && !strcmp(arg,"force")) { - *boardenable = 1; + *boardenable = true; } else if (arg && !strlen(arg)) { msg_perr("Missing argument for boardenable.\n"); free(arg); @@ -145,7 +146,7 @@
arg = extract_programmer_param_str(cfg, "boardmismatch"); if (arg && !strcmp(arg,"force")) { - *boardmismatch = 1; + *boardmismatch = true; } else if (arg && !strlen(arg)) { msg_perr("Missing argument for boardmismatch.\n"); free(arg); @@ -159,9 +160,9 @@
arg = extract_programmer_param_str(cfg, "laptop"); if (arg && !strcmp(arg, "force_I_want_a_brick")) - *force_laptop = 1; + *force_laptop = true; else if (arg && !strcmp(arg, "this_is_not_a_laptop")) - *not_a_laptop = 1; + *not_a_laptop = true; else if (arg && !strlen(arg)) { msg_perr("Missing argument for laptop.\n"); free(arg); @@ -192,8 +193,8 @@ static int internal_init(const struct programmer_cfg *cfg) { int ret = 0; - int force_laptop; - int not_a_laptop; + bool force_laptop; + bool not_a_laptop; char *board_vendor; char *board_model; #if defined(__i386__) || defined(__x86_64__)