1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

Fix -Wsign-compare trouble

Mostly by changing to `unsigned` types where applicable, sometimes
`signed` types, and casting as a last resort.

Change-Id: I08895543ffb7a48058bcf91ef6500ca113f2d305
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/30409
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
This commit is contained in:
Nico Huber 2018-12-23 20:03:35 +01:00
parent ef78de4a21
commit 519be66fc5
32 changed files with 116 additions and 107 deletions

View File

@ -126,7 +126,7 @@ int erase_block_82802ab(struct flashctx *flash, unsigned int page,
/* chunksize is 1 */
int write_82802ab(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len)
{
int i;
unsigned int i;
chipaddr dst = flash->virtual_memory + start;
for (i = 0; i < len; i++) {
@ -144,7 +144,7 @@ int unlock_28f004s5(struct flashctx *flash)
{
chipaddr bios = flash->virtual_memory;
uint8_t mcfg, bcfg, need_unlock = 0, can_unlock = 0;
int i;
unsigned int i;
/* Clear status register */
chip_writeb(flash, 0x50, bios);
@ -197,7 +197,7 @@ int unlock_lh28f008bjt(struct flashctx *flash)
chipaddr bios = flash->virtual_memory;
uint8_t mcfg, bcfg;
uint8_t need_unlock = 0, can_unlock = 0;
int i;
unsigned int i;
/* Wait if chip is busy */
wait_82802ab(flash);

View File

@ -463,9 +463,9 @@ static int at45db_fill_buffer1(struct flashctx *flash, const uint8_t *bytes, uns
}
/* Create a suitable buffer to store opcode, address and data chunks for buffer1. */
const int max_data_write = flash->mst->spi.max_data_write - 4;
const unsigned int max_chunk = (max_data_write > 0 && max_data_write <= page_size) ?
max_data_write : page_size;
const unsigned int max_data_write = flash->mst->spi.max_data_write;
const unsigned int max_chunk = max_data_write > 4 && max_data_write - 4 <= page_size ?
max_data_write - 4 : page_size;
uint8_t buf[4 + max_chunk];
buf[0] = AT45DB_BUFFER1_WRITE;

View File

@ -150,7 +150,7 @@ static int bitbang_spi_send_command(struct flashctx *flash,
const unsigned char *writearr,
unsigned char *readarr)
{
int i;
unsigned int i;
const struct bitbang_spi_master *master = flash->mst->spi.data;
/* FIXME: Run bitbang_spi_request_bus here or in programmer init?

View File

@ -373,7 +373,8 @@ void probe_superio_winbond(void)
static const struct winbond_chip *winbond_superio_chipdef(void)
{
int i, j;
int i;
unsigned int j;
for (i = 0; i < superio_count; i++) {
if (superios[i].vendor != SUPERIO_VENDOR_WINBOND)

View File

@ -76,7 +76,8 @@ static int buspirate_commbuf_grow(int bufsize)
static int buspirate_sendrecv(unsigned char *buf, unsigned int writecnt,
unsigned int readcnt)
{
int i, ret = 0;
unsigned int i;
int ret = 0;
msg_pspew("%s: write %i, read %i ", __func__, writecnt, readcnt);
if (!writecnt && !readcnt) {

View File

@ -34,7 +34,7 @@ static char *cb_vendor = NULL, *cb_model = NULL;
* -1 if IDs in the image do not match the IDs embedded in the current firmware,
* 0 if the IDs could not be found in the image or if they match correctly.
*/
int cb_check_image(const uint8_t *image, int size)
int cb_check_image(const uint8_t *image, unsigned int size)
{
const unsigned int *walk;
unsigned int mb_part_offset, mb_vendor_offset;
@ -138,10 +138,10 @@ static unsigned long compute_checksum(void *addr, unsigned long length)
((((char *)rec) + rec->size) <= (((char *)head) + sizeof(*head) + head->table_bytes)); \
rec = (struct lb_record *)(((char *)rec) + rec->size))
static int count_lb_records(struct lb_header *head)
static unsigned int count_lb_records(struct lb_header *head)
{
struct lb_record *rec;
int count;
unsigned int count;
count = 0;
for_each_lbrec(head, rec) {

View File

@ -507,7 +507,7 @@ int main(int argc, char *argv[])
for (j = 0; j < registered_master_count; j++) {
startchip = 0;
while (chipcount < ARRAY_SIZE(flashes)) {
while (chipcount < (int)ARRAY_SIZE(flashes)) {
startchip = probe_flash(&registered_masters[j], startchip, &flashes[chipcount], 0);
if (startchip == -1)
break;

View File

@ -474,7 +474,7 @@ static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf, unsigned
return 1;
int ret = dediprog_write(CMD_READ, value, idx, data_packet, sizeof(data_packet));
if (ret != sizeof(data_packet)) {
if (ret != (int)sizeof(data_packet)) {
msg_perr("Command Read SPI Bulk failed, %i %s!\n", ret, libusb_error_name(ret));
return 1;
}
@ -487,7 +487,7 @@ static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf, unsigned
/* Allocate bulk transfers. */
unsigned int i;
for (i = 0; i < min(DEDIPROG_ASYNC_TRANSFERS, count); ++i) {
for (i = 0; i < MIN(DEDIPROG_ASYNC_TRANSFERS, count); ++i) {
transfers[i] = libusb_alloc_transfer(0);
if (!transfers[i]) {
msg_perr("Allocating libusb transfer %i failed: %s!\n", i, libusb_error_name(ret));
@ -630,7 +630,7 @@ static int dediprog_spi_bulk_write(struct flashctx *flash, const uint8_t *buf, u
if (prepare_rw_cmd(flash, data_packet, count, dedi_spi_cmd, &value, &idx, start, 0))
return 1;
int ret = dediprog_write(CMD_WRITE, value, idx, data_packet, sizeof(data_packet));
if (ret != sizeof(data_packet)) {
if (ret != (int)sizeof(data_packet)) {
msg_perr("Command Write SPI Bulk failed, %s!\n", libusb_error_name(ret));
return 1;
}
@ -743,7 +743,7 @@ static int dediprog_spi_send_command(struct flashctx *flash,
value = 0;
}
ret = dediprog_write(CMD_TRANSCEIVE, value, idx, writearr, writecnt);
if (ret != writecnt) {
if (ret != (int)writecnt) {
msg_perr("Send SPI failed, expected %i, got %i %s!\n",
writecnt, ret, libusb_error_name(ret));
return 1;
@ -770,7 +770,7 @@ static int dediprog_spi_send_command(struct flashctx *flash,
ret = dediprog_read(CMD_TRANSCEIVE, value, idx, readarr, readcnt);
*/
ret = dediprog_read(CMD_TRANSCEIVE, 0, 0, readarr, readcnt);
if (ret != readcnt) {
if (ret != (int)readcnt) {
msg_perr("Receive SPI failed, expected %i, got %i %s!\n", readcnt, ret, libusb_error_name(ret));
return 1;
}
@ -804,7 +804,7 @@ static int dediprog_check_devicestring(void)
int sfnum;
int fw[3];
if (sscanf(buf, "SF%d V:%d.%d.%d ", &sfnum, &fw[0], &fw[1], &fw[2]) != 4 ||
sfnum != dediprog_devicetype) {
sfnum != (int)dediprog_devicetype) {
msg_perr("Unexpected firmware version string '%s'\n", buf);
return 1;
}

12
dmi.c
View File

@ -147,7 +147,7 @@ static char *dmi_string(const char *buf, uint8_t string_id, const char *limit)
static void dmi_chassis_type(uint8_t code)
{
int i;
unsigned int i;
code &= 0x7f; /* bits 6:0 are chassis type, 7th bit is the lock bit */
is_laptop = 2;
for (i = 0; i < ARRAY_SIZE(dmi_chassis_types); i++) {
@ -161,7 +161,7 @@ static void dmi_chassis_type(uint8_t code)
static void dmi_table(uint32_t base, uint16_t len, uint16_t num)
{
int i = 0, j = 0;
unsigned int i = 0, j = 0;
uint8_t *dmi_table_mem = physmap_ro("DMI Table", base, len);
if (dmi_table_mem == NULL) {
@ -346,7 +346,7 @@ static char *get_dmi_string(const char *string_name)
static int dmi_fill(void)
{
int i;
unsigned int i;
char *chassis_type;
msg_pdbg("Using External DMI decoder.\n");
@ -376,7 +376,7 @@ static int dmi_fill(void)
static int dmi_shutdown(void *data)
{
int i;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(dmi_strings); i++) {
free(dmi_strings[i].value);
dmi_strings[i].value = NULL;
@ -406,7 +406,7 @@ void dmi_init(void)
}
has_dmi_support = 1;
int i;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(dmi_strings); i++) {
msg_pdbg("DMI string %s: \"%s\"\n", dmi_strings[i].keyword,
(dmi_strings[i].value == NULL) ? "" : dmi_strings[i].value);
@ -463,7 +463,7 @@ static int dmi_compare(const char *value, const char *pattern)
int dmi_match(const char *pattern)
{
int i;
unsigned int i;
if (!has_dmi_support)
return 0;

View File

@ -58,8 +58,8 @@ static unsigned int emu_jedec_ce_60_size = 0;
static unsigned int emu_jedec_ce_c7_size = 0;
static unsigned char spi_blacklist[256];
static unsigned char spi_ignorelist[256];
static int spi_blacklist_size = 0;
static int spi_ignorelist_size = 0;
static unsigned int spi_blacklist_size = 0;
static unsigned int spi_ignorelist_size = 0;
static uint8_t emu_status = 0;
/* A legit complete SFDP table based on the MX25L6436E (rev. 1.8) datasheet. */
@ -151,7 +151,7 @@ int dummy_init(void)
{
char *bustext = NULL;
char *tmp = NULL;
int i;
unsigned int i;
#if EMULATE_SPI_CHIP
char *status = NULL;
#endif
@ -231,7 +231,7 @@ int dummy_init(void)
msg_pdbg("SPI blacklist is ");
for (i = 0; i < spi_blacklist_size; i++)
msg_pdbg("%02x ", spi_blacklist[i]);
msg_pdbg(", size %i\n", spi_blacklist_size);
msg_pdbg(", size %u\n", spi_blacklist_size);
}
free(tmp);
@ -267,7 +267,7 @@ int dummy_init(void)
msg_pdbg("SPI ignorelist is ");
for (i = 0; i < spi_ignorelist_size; i++)
msg_pdbg("%02x ", spi_ignorelist[i]);
msg_pdbg(", size %i\n", spi_ignorelist_size);
msg_pdbg(", size %u\n", spi_ignorelist_size);
}
free(tmp);
@ -819,7 +819,7 @@ static int dummy_spi_send_command(struct flashctx *flash, unsigned int writecnt,
const unsigned char *writearr,
unsigned char *readarr)
{
int i;
unsigned int i;
msg_pspew("%s:", __func__);

View File

@ -29,7 +29,7 @@
/* chunksize is 1 */
int write_en29lv640b(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len)
{
int i;
unsigned int i;
chipaddr bios = flash->virtual_memory;
chipaddr dst = flash->virtual_memory + start;

View File

@ -301,7 +301,11 @@ void print_supported_wiki(void);
/* helpers.c */
uint32_t address_to_bits(uint32_t addr);
int bitcount(unsigned long a);
unsigned int bitcount(unsigned long a);
#undef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int max(int a, int b);
int min(int a, int b);
char *strcat_realloc(char *dest, const char *src);

View File

@ -1253,7 +1253,7 @@ int read_buf_from_file(unsigned char *buf, unsigned long size,
ret = 1;
goto out;
}
if (image_stat.st_size != size) {
if (image_stat.st_size != (intmax_t)size) {
msg_gerr("Error: Image size (%jd B) doesn't match the flash chip's size (%lu B)!\n",
(intmax_t)image_stat.st_size, size);
ret = 1;

4
fmap.c
View File

@ -96,7 +96,7 @@ static off_t fmap_lsearch(const uint8_t *buf, size_t len)
off_t offset;
bool fmap_found = 0;
for (offset = 0; offset <= len - sizeof(struct fmap); offset++) {
for (offset = 0; offset <= (off_t)(len - sizeof(struct fmap)); offset++) {
if (is_valid_fmap((struct fmap *)&buf[offset])) {
fmap_found = 1;
break;
@ -178,7 +178,7 @@ _finalize_ret:
}
static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flashctx,
size_t rom_offset, size_t len, int min_stride)
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;

View File

@ -30,9 +30,9 @@ uint32_t address_to_bits(uint32_t addr)
return 32 - lzb;
}
int bitcount(unsigned long a)
unsigned int bitcount(unsigned long a)
{
int i = 0;
unsigned int i = 0;
for (; a != 0; a >>= 1)
if (a & 1)
i++;

View File

@ -35,10 +35,6 @@
#include "flash.h" /* for msg_* */
#include "programmer.h"
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
ssize_t ich_number_of_regions(const enum ich_chipset cs, const struct ich_desc_content *const cont)
{
switch (cs) {
@ -365,7 +361,7 @@ static void pprint_freg(const struct ich_desc_region *reg, uint32_t i)
void prettyprint_ich_descriptor_region(const enum ich_chipset cs, const struct ich_descriptors *const desc)
{
size_t i;
ssize_t i;
const ssize_t nr = ich_number_of_regions(cs, &desc->content);
msg_pdbg2("=== Region Section ===\n");
if (nr < 0) {
@ -374,18 +370,18 @@ void prettyprint_ich_descriptor_region(const enum ich_chipset cs, const struct i
return;
}
for (i = 0; i < nr; i++)
msg_pdbg2("FLREG%zu 0x%08x\n", i, desc->region.FLREGs[i]);
msg_pdbg2("FLREG%zd 0x%08x\n", i, desc->region.FLREGs[i]);
msg_pdbg2("\n");
msg_pdbg2("--- Details ---\n");
for (i = 0; i < nr; i++)
pprint_freg(&desc->region, i);
pprint_freg(&desc->region, (uint32_t)i);
msg_pdbg2("\n");
}
void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct ich_descriptors *const desc)
{
size_t i;
ssize_t i;
const ssize_t nm = ich_number_of_masters(cs, &desc->content);
msg_pdbg2("=== Master Section ===\n");
if (nm < 0) {
@ -394,7 +390,7 @@ void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct i
return;
}
for (i = 0; i < nm; i++)
msg_pdbg2("FLMSTR%zu 0x%08x\n", i + 1, desc->master.FLMSTRs[i]);
msg_pdbg2("FLMSTR%zd 0x%08x\n", i + 1, desc->master.FLMSTRs[i]);
msg_pdbg2("\n");
msg_pdbg2("--- Details ---\n");
@ -402,7 +398,7 @@ void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct i
const char *const master_names[] = {
"BIOS", "ME", "GbE", "unknown", "EC",
};
if (nm >= ARRAY_SIZE(master_names)) {
if (nm >= (ssize_t)ARRAY_SIZE(master_names)) {
msg_pdbg2("%s: number of masters too high (%d).\n", __func__,
desc->content.NM + 1);
return;
@ -423,7 +419,7 @@ void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct i
"BIOS", "ME", "GbE", "DE", "BMC", "IE",
};
/* NM starts at 1 instead of 0 for LBG */
if (nm > ARRAY_SIZE(master_names)) {
if (nm > (ssize_t)ARRAY_SIZE(master_names)) {
msg_pdbg2("%s: number of masters too high (%d).\n", __func__,
desc->content.NM);
return;
@ -446,14 +442,14 @@ void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct i
}
} else if (cs == CHIPSET_APOLLO_LAKE) {
const char *const master_names[] = { "BIOS", "TXE", };
if (nm > ARRAY_SIZE(master_names)) {
if (nm > (ssize_t)ARRAY_SIZE(master_names)) {
msg_pdbg2("%s: number of masters too high (%d).\n", __func__, desc->content.NM);
return;
}
msg_pdbg2(" FD IFWI TXE n/a Platf DevExp\n");
for (i = 0; i < nm; i++) {
size_t j;
ssize_t j;
msg_pdbg2("%-4s", master_names[i]);
for (j = 0; j < ich_number_of_regions(cs, &desc->content); j++)
msg_pdbg2(" %c%c ",
@ -799,7 +795,7 @@ void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_des
unsigned int i, max_count;
msg_pdbg2("=== Softstraps ===\n");
max_count = min(ARRAY_SIZE(desc->north.STRPs), desc->content.MSL);
max_count = MIN(ARRAY_SIZE(desc->north.STRPs), desc->content.MSL);
if (max_count < desc->content.MSL) {
msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n",
desc->content.MSL, max_count);
@ -811,7 +807,7 @@ void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_des
msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
msg_pdbg2("\n");
max_count = min(ARRAY_SIZE(desc->south.STRPs), desc->content.ISL);
max_count = MIN(ARRAY_SIZE(desc->south.STRPs), desc->content.ISL);
if (max_count < desc->content.ISL) {
msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n",
desc->content.ISL, max_count);
@ -965,8 +961,8 @@ static enum ich_chipset guess_ich_chipset(const struct ich_desc_content *const c
int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
enum ich_chipset *const cs, struct ich_descriptors *const desc)
{
size_t i, max_count;
uint8_t pch_bug_offset = 0;
ssize_t i, max_count;
size_t pch_bug_offset = 0;
if (dump == NULL || desc == NULL)
return ICH_RET_PARAM;
@ -1000,14 +996,14 @@ int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
/* region */
const ssize_t nr = ich_number_of_regions(*cs, &desc->content);
if (nr < 0 || len < getFRBA(&desc->content) + nr * 4)
if (nr < 0 || len < getFRBA(&desc->content) + (size_t)nr * 4)
return ICH_RET_OOB;
for (i = 0; i < nr; i++)
desc->region.FLREGs[i] = dump[(getFRBA(&desc->content) >> 2) + i];
/* master */
const ssize_t nm = ich_number_of_masters(*cs, &desc->content);
if (nm < 0 || len < getFMBA(&desc->content) + nm * 4)
if (nm < 0 || len < getFMBA(&desc->content) + (size_t)nm * 4)
return ICH_RET_OOB;
for (i = 0; i < nm; i++)
desc->master.FLMSTRs[i] = dump[(getFMBA(&desc->content) >> 2) + i];
@ -1034,7 +1030,7 @@ int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
return ICH_RET_OOB;
/* limit the range to be written */
max_count = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
max_count = MIN(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
for (i = 0; i < max_count; i++)
desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + i];
@ -1043,7 +1039,7 @@ int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
return ICH_RET_OOB;
/* limit the range to be written */
max_count = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
max_count = MIN(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
for (i = 0; i < max_count; i++)
desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + i];
@ -1134,7 +1130,7 @@ static uint32_t read_descriptor_reg(enum ich_chipset cs, uint8_t section, uint16
int read_ich_descriptors_via_fdo(enum ich_chipset cs, void *spibar, struct ich_descriptors *desc)
{
size_t i;
ssize_t i;
struct ich_desc_region *r = &desc->region;
/* Test if bit-fields are working as expected.
@ -1226,7 +1222,8 @@ int layout_from_ich_descriptors(struct ich_layout *const layout, const void *con
memset(layout, 0x00, sizeof(*layout));
ssize_t i, j;
for (i = 0, j = 0; i < min(ich_number_of_regions(cs, &desc.content), ARRAY_SIZE(regions)); ++i) {
const ssize_t nr = MIN(ich_number_of_regions(cs, &desc.content), (ssize_t)ARRAY_SIZE(regions));
for (i = 0, j = 0; i < nr; ++i) {
const chipoff_t base = ICH_FREG_BASE(desc.region.FLREGs[i]);
const chipoff_t limit = ICH_FREG_LIMIT(desc.region.FLREGs[i]);
if (limit <= base)

View File

@ -470,7 +470,7 @@ static struct {
static uint8_t lookup_spi_type(uint8_t opcode)
{
int a;
unsigned int a;
for (a = 0; a < ARRAY_SIZE(POSSIBLE_OPCODES); a++) {
if (POSSIBLE_OPCODES[a].opcode == opcode)
@ -1564,7 +1564,7 @@ static const char *const access_names[] = {
"locked", "read-only", "write-only", "read-write"
};
static enum ich_access_protection ich9_handle_frap(uint32_t frap, int i)
static enum ich_access_protection ich9_handle_frap(uint32_t frap, unsigned int i)
{
const int rwperms_unknown = ARRAY_SIZE(access_names);
static const char *const region_names[6] = {
@ -1595,23 +1595,23 @@ static enum ich_access_protection ich9_handle_frap(uint32_t frap, int i)
limit = ICH_FREG_LIMIT(freg);
if (base > limit || (freg == 0 && i > 0)) {
/* this FREG is disabled */
msg_pdbg2("0x%02X: 0x%08x FREG%i: %s region is unused.\n",
msg_pdbg2("0x%02X: 0x%08x FREG%u: %s region is unused.\n",
offset, freg, i, region_name);
return NO_PROT;
}
msg_pdbg("0x%02X: 0x%08x ", offset, freg);
if (rwperms == 0x3) {
msg_pdbg("FREG%i: %s region (0x%08x-0x%08x) is %s.\n", i,
msg_pdbg("FREG%u: %s region (0x%08x-0x%08x) is %s.\n", i,
region_name, base, limit, access_names[rwperms]);
return NO_PROT;
}
if (rwperms == rwperms_unknown) {
msg_pdbg("FREG%i: %s region (0x%08x-0x%08x) has unknown permissions.\n",
msg_pdbg("FREG%u: %s region (0x%08x-0x%08x) has unknown permissions.\n",
i, region_name, base, limit);
return NO_PROT;
}
msg_pinfo("FREG%i: %s region (0x%08x-0x%08x) is %s.\n", i,
msg_pinfo("FREG%u: %s region (0x%08x-0x%08x) is %s.\n", i,
region_name, base, limit, access_names[rwperms]);
return access_perms_to_protection[rwperms];
}
@ -1625,7 +1625,7 @@ static enum ich_access_protection ich9_handle_frap(uint32_t frap, int i)
#define ICH_PR_PERMS(pr) (((~((pr) >> PR_RP_OFF) & 1) << 0) | \
((~((pr) >> PR_WP_OFF) & 1) << 1))
static enum ich_access_protection ich9_handle_pr(const size_t reg_pr0, int i)
static enum ich_access_protection ich9_handle_pr(const size_t reg_pr0, unsigned int i)
{
uint8_t off = reg_pr0 + (i * 4);
uint32_t pr = mmio_readl(ich_spibar + off);
@ -1701,7 +1701,7 @@ static const struct opaque_master opaque_master_ich_hwseq = {
int ich_init_spi(void *spibar, enum ich_chipset ich_gen)
{
int i;
unsigned int i;
uint16_t tmp2;
uint32_t tmp;
char *arg;
@ -1786,7 +1786,7 @@ int ich_init_spi(void *spibar, enum ich_chipset ich_gen)
for (i = 0; i < 3; i++) {
int offs;
offs = 0x60 + (i * 4);
msg_pdbg("0x%02x: 0x%08x (PBR%d)\n", offs,
msg_pdbg("0x%02x: 0x%08x (PBR%u)\n", offs,
mmio_readl(ich_spibar + offs), i);
}
if (mmio_readw(ich_spibar) & (1 << 15)) {

View File

@ -327,7 +327,7 @@ static int it85xx_spi_send_command(struct flashctx *flash,
const unsigned char *writearr,
unsigned char *readarr)
{
int i;
unsigned int i;
it85xx_enter_scratch_rom();
/* Exit scratch ROM ONLY when programmer shuts down. Otherwise, the

View File

@ -281,7 +281,6 @@ static int it8716f_spi_send_command(struct flashctx *flash,
unsigned char *readarr)
{
uint8_t busy, writeenc;
int i;
do {
busy = INB(it8716f_flashport) & 0x80;
@ -330,6 +329,8 @@ static int it8716f_spi_send_command(struct flashctx *flash,
| ((readcnt & 0x3) << 2) | (writeenc), it8716f_flashport);
if (readcnt > 0) {
unsigned int i;
do {
busy = INB(it8716f_flashport) & 0x80;
} while (busy);

View File

@ -408,7 +408,8 @@ retry:
int write_jedec_1(struct flashctx *flash, const uint8_t *src, unsigned int start,
unsigned int len)
{
int i, failed = 0;
unsigned int i;
int failed = 0;
chipaddr dst = flash->virtual_memory + start;
chipaddr olddst;
unsigned int mask;
@ -430,7 +431,8 @@ int write_jedec_1(struct flashctx *flash, const uint8_t *src, unsigned int start
static int write_page_write_jedec_common(struct flashctx *flash, const uint8_t *src,
unsigned int start, unsigned int page_size)
{
int i, tried = 0, failed;
unsigned int i;
int tried = 0, failed;
const uint8_t *s = src;
chipaddr bios = flash->virtual_memory;
chipaddr dst = bios + start;

View File

@ -46,7 +46,8 @@ int read_romlayout(const char *name)
struct flashrom_layout *const layout = get_global_layout();
FILE *romlayout;
char tempstr[256], tempname[256];
int i, ret = 1;
unsigned int i;
int ret = 1;
romlayout = fopen(name, "r");
@ -154,7 +155,7 @@ static int find_romentry(struct flashrom_layout *const l, char *name)
*/
int process_include_args(struct flashrom_layout *l, const struct layout_include_args *const args)
{
int found = 0;
unsigned int found = 0;
const struct layout_include_args *tmp;
if (args == NULL)
@ -193,7 +194,7 @@ int process_include_args(struct flashrom_layout *l, const struct layout_include_
void layout_cleanup(struct layout_include_args **args)
{
struct flashrom_layout *const layout = get_global_layout();
int i;
unsigned int i;
struct layout_include_args *tmp;
while (*args) {
@ -216,7 +217,7 @@ int normalize_romentries(const struct flashctx *flash)
chipsize_t total_size = flash->chip->total_size * 1024;
int ret = 0;
int i;
unsigned int i;
for (i = 0; i < layout->num_entries; i++) {
if (layout->entries[i].start >= total_size || layout->entries[i].end >= total_size) {
msg_gwarn("Warning: Address range of region \"%s\" exceeds the current chip's "

View File

@ -209,7 +209,7 @@ static int pickit2_spi_send_command(struct flashctx *flash, unsigned int writecn
}
uint8_t buf[CMD_LENGTH] = {CMD_DOWNLOAD_DATA, writecnt};
int i = 2;
unsigned int i = 2;
for (; i < writecnt + 2; i++) {
buf[i] = writearr[i - 2];
}

19
print.c
View File

@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "flash.h"
#include "programmer.h"
@ -314,20 +315,20 @@ static int print_supported_chips(void)
#if CONFIG_INTERNAL == 1
static void print_supported_chipsets(void)
{
int i, chipsetcount = 0;
unsigned int i, chipsetcount = 0;
const struct penable *c = chipset_enables;
int maxvendorlen = strlen("Vendor") + 1;
int maxchipsetlen = strlen("Chipset") + 1;
size_t maxvendorlen = strlen("Vendor") + 1;
size_t maxchipsetlen = strlen("Chipset") + 1;
for (c = chipset_enables; c->vendor_name != NULL; c++) {
chipsetcount++;
maxvendorlen = max(maxvendorlen, strlen(c->vendor_name));
maxchipsetlen = max(maxchipsetlen, strlen(c->device_name));
maxvendorlen = MAX(maxvendorlen, strlen(c->vendor_name));
maxchipsetlen = MAX(maxchipsetlen, strlen(c->device_name));
}
maxvendorlen++;
maxchipsetlen++;
msg_ginfo("Supported chipsets (total: %d):\n\n", chipsetcount);
msg_ginfo("Supported chipsets (total: %u):\n\n", chipsetcount);
msg_ginfo("Vendor");
for (i = strlen("Vendor"); i < maxvendorlen; i++)
@ -354,12 +355,12 @@ static void print_supported_chipsets(void)
static void print_supported_boards_helper(const struct board_info *boards,
const char *devicetype)
{
int i;
unsigned int i;
unsigned int boardcount_good = 0, boardcount_bad = 0, boardcount_nt = 0;
const struct board_match *e = board_matches;
const struct board_info *b = boards;
int maxvendorlen = strlen("Vendor") + 1;
int maxboardlen = strlen("Board") + 1;
size_t maxvendorlen = strlen("Vendor") + 1;
size_t maxboardlen = strlen("Board") + 1;
for (b = boards; b->vendor != NULL; b++) {
maxvendorlen = max(maxvendorlen, strlen(b->vendor));

View File

@ -245,7 +245,7 @@ static void print_supported_boards_wiki_helper(const char *devicetype, int cols,
"<span id=\"%s_note%d\">%d. [[#%s_ref%d|&#x2191;]]</span>"
" <nowiki>%s</nowiki><br />\n", devicetype, num_notes, num_notes,
devicetype, num_notes, boards[i].note);
if (ret < 0 || ret >= sizeof(tmp)) {
if (ret < 0 || (unsigned int)ret >= sizeof(tmp)) {
fprintf(stderr, "Footnote text #%d of %s truncated (ret=%d, sizeof(tmp)=%zu)\n",
num_notes, devicetype, ret, sizeof(tmp));
}

View File

@ -304,7 +304,7 @@ void cleanup_cpu_msr(void);
/* cbtable.c */
int cb_parse_table(const char **vendor, const char **model);
int cb_check_image(const uint8_t *bios, int size);
int cb_check_image(const uint8_t *bios, unsigned int size);
/* dmi.c */
#if defined(__i386__) || defined(__x86_64__)

View File

@ -247,7 +247,7 @@ static int sb600_spi_send_command(struct flashctx *flash, unsigned int writecnt,
reset_internal_fifo_pointer();
msg_pspew("Filling FIFO: ");
int count;
unsigned int count;
for (count = 0; count < writecnt; count++) {
msg_pspew("[%02x]", writearr[count]);
mmio_writeb(writearr[count], sb600_spibar + 0xC);
@ -326,7 +326,7 @@ static int spi100_spi_send_command(struct flashctx *flash, unsigned int writecnt
mmio_writeb(readcnt, sb600_spibar + 0x4b);
msg_pspew("Filling buffer: ");
int count;
unsigned int count;
for (count = 0; count < writecnt; count++) {
msg_pspew("[%02x]", writearr[count]);
mmio_writeb(writearr[count], sb600_spibar + 0x80 + count);

View File

@ -480,10 +480,10 @@ int serialport_read_nonblock(unsigned char *c, unsigned int readcnt, unsigned in
}
#endif
int i;
int rd_bytes = 0;
unsigned int i;
unsigned int rd_bytes = 0;
for (i = 0; i < timeout; i++) {
msg_pspew("readcnt %d rd_bytes %d\n", readcnt, rd_bytes);
msg_pspew("readcnt %u rd_bytes %u\n", readcnt, rd_bytes);
#if IS_WINDOWS
ReadFile(sp_fd, c + rd_bytes, readcnt - rd_bytes, &rv, NULL);
msg_pspew("read %lu bytes\n", rv);
@ -560,10 +560,10 @@ int serialport_write_nonblock(const unsigned char *buf, unsigned int writecnt, u
}
#endif
int i;
int wr_bytes = 0;
unsigned int i;
unsigned int wr_bytes = 0;
for (i = 0; i < timeout; i++) {
msg_pspew("writecnt %d wr_bytes %d\n", writecnt, wr_bytes);
msg_pspew("writecnt %u wr_bytes %u\n", writecnt, wr_bytes);
#if IS_WINDOWS
WriteFile(sp_fd, buf + wr_bytes, writecnt - wr_bytes, &rv, NULL);
msg_pspew("wrote %lu bytes\n", rv);

View File

@ -71,8 +71,8 @@ static uint8_t *sp_write_n_buf;
static uint32_t sp_write_n_bytes = 0;
/* sp_streamed_* used for flow control checking */
static int sp_streamed_transmit_ops = 0;
static int sp_streamed_transmit_bytes = 0;
static unsigned int sp_streamed_transmit_ops = 0;
static unsigned int sp_streamed_transmit_bytes = 0;
/* sp_opbuf_usage used for counting the amount of
on-device operation buffer used */

View File

@ -75,7 +75,7 @@ int erase_sector_28sf040(struct flashctx *flash, unsigned int address,
/* chunksize is 1 */
int write_28sf040(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len)
{
int i;
unsigned int i;
chipaddr bios = flash->virtual_memory;
chipaddr dst = flash->virtual_memory + start;

View File

@ -21,7 +21,7 @@
#include "flash.h"
#include "chipdrivers.h"
static int check_sst_fwhub_block_lock(struct flashctx *flash, int offset)
static int check_sst_fwhub_block_lock(struct flashctx *flash, unsigned int offset)
{
chipaddr registers = flash->virtual_registers;
uint8_t blockstatus;
@ -47,7 +47,7 @@ static int check_sst_fwhub_block_lock(struct flashctx *flash, int offset)
return blockstatus & 0x1;
}
static int clear_sst_fwhub_block_lock(struct flashctx *flash, int offset)
static int clear_sst_fwhub_block_lock(struct flashctx *flash, unsigned int offset)
{
chipaddr registers = flash->virtual_registers;
uint8_t blockstatus;
@ -67,7 +67,7 @@ static int clear_sst_fwhub_block_lock(struct flashctx *flash, int offset)
int printlock_sst_fwhub(struct flashctx *flash)
{
int i;
unsigned int i;
for (i = 0; i < flash->chip->total_size * 1024; i += flash->chip->page_size)
check_sst_fwhub_block_lock(flash, i);
@ -77,7 +77,8 @@ int printlock_sst_fwhub(struct flashctx *flash)
int unlock_sst_fwhub(struct flashctx *flash)
{
int i, ret=0;
unsigned int i;
int ret = 0;
for (i = 0; i < flash->chip->total_size * 1024; i += flash->chip->page_size)
{

View File

@ -119,11 +119,11 @@ int usbblaster_spi_init(void)
static int send_write(unsigned int writecnt, const unsigned char *writearr)
{
int i;
uint8_t buf[BUF_SIZE];
memset(buf, 0, sizeof(buf));
while (writecnt) {
unsigned int i;
unsigned int n_write = min(writecnt, BUF_SIZE - 1);
msg_pspew("writing %d-byte packet\n", n_write);

View File

@ -115,7 +115,7 @@ static int wbsio_spi_send_command(struct flashctx *flash, unsigned int writecnt,
const unsigned char *writearr,
unsigned char *readarr)
{
int i;
unsigned int i;
uint8_t mode = 0;
msg_pspew("%s:", __func__);