summaryrefslogtreecommitdiffstats
path: root/dummyflasher.c
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2022-08-19 03:29:32 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2022-09-08 02:14:26 +0000
commitde2052849dc9aa9664e80a13163e87000b4efa40 (patch)
tree41d0e9d5c7ec5154f01f0a9090488eceeb5c759b /dummyflasher.c
parentb20a55adb790897ec0c1a861448d10c03a8dff8b (diff)
downloadflashrom-de2052849dc9aa9664e80a13163e87000b4efa40.tar.gz
flashrom-de2052849dc9aa9664e80a13163e87000b4efa40.tar.bz2
flashrom-de2052849dc9aa9664e80a13163e87000b4efa40.zip
dummyflasher.c: Retype appropriate variables and attributes with bool
Use the bool type instead of an integer for appropriate variables and attributes, since this represents their purpose much better. Signed-off-by: Felix Singer <felixsinger@posteo.net> Change-Id: I712b1ef7e1ad74d3e004dcf36c82898c88072c63 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66901 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 'dummyflasher.c')
-rw-r--r--dummyflasher.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/dummyflasher.c b/dummyflasher.c
index 07fcd7241..49a541b7e 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -15,6 +15,7 @@
#include <assert.h>
#include <string.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -48,8 +49,8 @@ struct emu_data {
* WRSR code on enabling WRSR_EXT2 for more chips. */
bool emu_wrsr_ext2;
bool emu_wrsr_ext3;
- int erase_to_zero;
- int emu_modified; /* is the image modified since reading it? */
+ bool erase_to_zero;
+ bool emu_modified; /* is the image modified since reading it? */
uint8_t emu_status[3];
uint8_t emu_status_len; /* number of emulated status registers */
/* If "freq" parameter is passed in from command line, commands will delay
@@ -183,7 +184,7 @@ static int dummy_opaque_write(struct flashctx *flash, const uint8_t *buf, unsign
struct emu_data *emu_data = flash->mst->opaque.data;
memcpy(emu_data->flashchip_contents + start, buf, len);
- emu_data->emu_modified = 1;
+ emu_data->emu_modified = true;
return 0;
}
@@ -193,7 +194,7 @@ static int dummy_opaque_erase(struct flashctx *flash, unsigned int blockaddr, un
struct emu_data *emu_data = flash->mst->opaque.data;
memset(emu_data->flashchip_contents + blockaddr, emu_data->erase_to_zero ? 0x00 : 0xff, blocklen);
- emu_data->emu_modified = 1;
+ emu_data->emu_modified = true;
return 0;
}
@@ -361,7 +362,7 @@ static int write_flash_data(struct emu_data *data, uint32_t start, uint32_t len,
}
memcpy(data->flashchip_contents + start, buf, len);
- data->emu_modified = 1;
+ data->emu_modified = true;
return 0;
}
@@ -375,7 +376,7 @@ static int erase_flash_data(struct emu_data *data, uint32_t start, uint32_t len)
/* FIXME: Maybe use ERASED_VALUE(flash) instead of 0xff ? */
memset(data->flashchip_contents + start, 0xff, len);
- data->emu_modified = 1;
+ data->emu_modified = true;
return 0;
}
@@ -1090,20 +1091,20 @@ static int init_data(const struct programmer_cfg *cfg,
}
if ((units > tmp) && (units < end)) {
- int units_valid = 0;
+ bool units_valid = false;
if (units < end - 3) {
;
} else if (units == end - 2) {
if (!strcasecmp(units, "hz"))
- units_valid = 1;
+ units_valid = true;
} else if (units == end - 3) {
if (!strcasecmp(units, "khz")) {
freq *= 1000;
- units_valid = 1;
+ units_valid = true;
} else if (!strcasecmp(units, "mhz")) {
freq *= 1000000;
- units_valid = 1;
+ units_valid = true;
}
}
@@ -1284,7 +1285,7 @@ static int init_data(const struct programmer_cfg *cfg,
}
if (!strcmp(tmp, "yes")) {
msg_pdbg("Emulated chip will erase to 0x00\n");
- data->erase_to_zero = 1;
+ data->erase_to_zero = true;
} else if (!strcmp(tmp, "no")) {
msg_pdbg("Emulated chip will erase to 0xff\n");
} else {