summaryrefslogtreecommitdiffstats
path: root/fmap.c
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2022-08-19 03:19:06 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2022-09-08 02:12:51 +0000
commit77f31f7f5a316479a86b18adc8d4fe882a0f331a (patch)
tree6a31eb6de751a97280b651ef373c0ee0d28cf429 /fmap.c
parentf74e438303a0aed7a423985057d7e59a5711ddcf (diff)
downloadflashrom-77f31f7f5a316479a86b18adc8d4fe882a0f331a.tar.gz
flashrom-77f31f7f5a316479a86b18adc8d4fe882a0f331a.tar.bz2
flashrom-77f31f7f5a316479a86b18adc8d4fe882a0f331a.zip
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>
Diffstat (limited to 'fmap.c')
-rw-r--r--fmap.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fmap.c b/fmap.c
index bd847bd0b..69824ea82 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 int is_valid_fmap(const struct fmap *fmap)
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 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash
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 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash
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 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash
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);