fmap.c: Retype appropriate variables with bool
Use the bool type instead of an integer for appropriate variables, since
this represents their purpose much better.
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I323d40cabe9c580057d870e742b3b55942c78321
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/66896
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/+/71487
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/fmap.c b/fmap.c
index eafe80c..584ee11 100644
--- a/fmap.c
+++ b/fmap.c
@@ -35,6 +35,7 @@
*/
#include <ctype.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@@ -94,14 +95,14 @@
static ssize_t fmap_lsearch(const uint8_t *buf, size_t len)
{
ssize_t offset;
- bool fmap_found = 0;
+ bool fmap_found = false;
if (len < sizeof(struct fmap))
return -1;
for (offset = 0; offset <= (ssize_t)(len - sizeof(struct fmap)); offset++) {
if (is_valid_fmap((struct fmap *)&buf[offset])) {
- fmap_found = 1;
+ fmap_found = true;
break;
}
}
@@ -184,7 +185,9 @@
size_t rom_offset, size_t len, size_t min_stride)
{
size_t stride, fmap_len = 0;
- int ret = 1, fmap_found = 0, check_offset_0 = 1;
+ int ret = 1;
+ bool fmap_found = false;
+ bool check_offset_0 = true;
struct fmap *fmap;
const unsigned int chip_size = flashctx->chip->total_size * 1024;
const int sig_len = strlen(FMAP_SIGNATURE);
@@ -225,7 +228,7 @@
continue;
if (offset == 0 && !check_offset_0)
continue;
- check_offset_0 = 0;
+ check_offset_0 = false;
/* Read errors are considered non-fatal since we may
* encounter locked regions and want to continue. */
@@ -251,7 +254,7 @@
if (is_valid_fmap(fmap)) {
msg_gdbg("fmap found at offset 0x%06zx\n", offset);
- fmap_found = 1;
+ fmap_found = true;
break;
}
msg_gerr("fmap signature found at %zu but header is invalid.\n", offset);