tree: Retype variable `programmer_may_write` with bool
Use the bool type instead of an integer for the variable
`programmer_may_write`, since this represents its purpose much better.
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I69958527ae018a92f1c42734a7990d0c532dee0c
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/66885
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71483
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/chipset_enable.c b/chipset_enable.c
index 182410a..f781b16 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -26,6 +26,7 @@
#define _LARGEFILE64_SOURCE
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -1490,7 +1491,7 @@
if (err > 0) {
msg_pinfo("%d locks could not be disabled, disabling writes (reads may also fail).\n", err);
- programmer_may_write = 0;
+ programmer_may_write = false;
}
reg = 0x88;
diff --git a/flashrom.c b/flashrom.c
index 88a7402..f656872 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -56,7 +56,7 @@
unsigned long flashbase;
/* Is writing allowed with this programmer? */
-int programmer_may_write;
+bool programmer_may_write;
#define SHUTDOWN_MAXFN 32
static int shutdown_fn_count = 0;
@@ -158,7 +158,7 @@
/* Registering shutdown functions is now allowed. */
may_register_shutdown = true;
/* Default to allowing writes. Broken programmers set this to 0. */
- programmer_may_write = 1;
+ programmer_may_write = true;
programmer_param = param;
msg_pdbg("Initializing %s programmer\n", programmer->name);
diff --git a/gfxnvidia.c b/gfxnvidia.c
index e353684..faed11d 100644
--- a/gfxnvidia.c
+++ b/gfxnvidia.c
@@ -14,6 +14,7 @@
* GNU General Public License for more details.
*/
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "flash.h"
@@ -102,7 +103,7 @@
rpci_write_long(dev, 0x50, reg32);
/* Write/erase doesn't work. */
- programmer_may_write = 0;
+ programmer_may_write = false;
register_par_master(&par_master_gfxnvidia, BUS_PARALLEL);
return 0;
diff --git a/programmer.h b/programmer.h
index e033c69..24b37fb 100644
--- a/programmer.h
+++ b/programmer.h
@@ -292,7 +292,7 @@
};
// FIXME: These need to be local, not global
extern struct decode_sizes max_rom_decode;
-extern int programmer_may_write;
+extern bool programmer_may_write;
extern unsigned long flashbase;
unsigned int count_max_decode_exceedings(const struct flashctx *flash);
char *extract_programmer_param(const char *param_name);
diff --git a/sb600spi.c b/sb600spi.c
index b1d9c77..8664fa9 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -20,6 +20,7 @@
#if defined(__i386__) || defined(__x86_64__)
+#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include "flash.h"
@@ -516,7 +517,7 @@
}
if (!amd_imc_force)
- programmer_may_write = 0;
+ programmer_may_write = false;
msg_pinfo("Writes have been disabled for safety reasons because the presence of the IMC\n"
"was detected and it could interfere with accessing flash memory. Flashrom will\n"
"try to disable it temporarily but even then this might not be safe:\n"