mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
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>
This commit is contained in:
parent
f74e438303
commit
77f31f7f5a
13
fmap.c
13
fmap.c
@ -35,6 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.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)
|
static ssize_t fmap_lsearch(const uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t offset;
|
ssize_t offset;
|
||||||
bool fmap_found = 0;
|
bool fmap_found = false;
|
||||||
|
|
||||||
if (len < sizeof(struct fmap))
|
if (len < sizeof(struct fmap))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (offset = 0; offset <= (ssize_t)(len - sizeof(struct fmap)); offset++) {
|
for (offset = 0; offset <= (ssize_t)(len - sizeof(struct fmap)); offset++) {
|
||||||
if (is_valid_fmap((struct fmap *)&buf[offset])) {
|
if (is_valid_fmap((struct fmap *)&buf[offset])) {
|
||||||
fmap_found = 1;
|
fmap_found = true;
|
||||||
break;
|
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 rom_offset, size_t len, size_t min_stride)
|
||||||
{
|
{
|
||||||
size_t stride, fmap_len = 0;
|
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;
|
struct fmap *fmap;
|
||||||
const unsigned int chip_size = flashctx->chip->total_size * 1024;
|
const unsigned int chip_size = flashctx->chip->total_size * 1024;
|
||||||
const int sig_len = strlen(FMAP_SIGNATURE);
|
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;
|
continue;
|
||||||
if (offset == 0 && !check_offset_0)
|
if (offset == 0 && !check_offset_0)
|
||||||
continue;
|
continue;
|
||||||
check_offset_0 = 0;
|
check_offset_0 = false;
|
||||||
|
|
||||||
/* Read errors are considered non-fatal since we may
|
/* Read errors are considered non-fatal since we may
|
||||||
* encounter locked regions and want to continue. */
|
* 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)) {
|
if (is_valid_fmap(fmap)) {
|
||||||
msg_gdbg("fmap found at offset 0x%06zx\n", offset);
|
msg_gdbg("fmap found at offset 0x%06zx\n", offset);
|
||||||
fmap_found = 1;
|
fmap_found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
msg_gerr("fmap signature found at %zu but header is invalid.\n", offset);
|
msg_gerr("fmap signature found at %zu but header is invalid.\n", offset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user