Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/66896 )
Change subject: fmap.c: Retype appropriate variables with bool ......................................................................
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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66896 Reviewed-by: Anastasia Klimchuk aklm@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M fmap.c 1 file changed, 25 insertions(+), 5 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
diff --git a/fmap.c b/fmap.c index bd847bd..69824ea 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);