util/cbmem: Use correct integer types for loop indices

Make sure that the type of the loop index matches the type of the upper
bound. This fixes several -Wsign-compare warnings.

Change-Id: Iaa94ce93bc35d523bc782ad914bfd283606becac
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33850
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Jacob Garber 2019-06-27 16:02:32 -06:00 committed by Martin Roth
parent a88921e2b0
commit 414d5d8698
1 changed files with 8 additions and 16 deletions

View File

@ -543,9 +543,7 @@ static void print_norm(u64 v)
static const char *timestamp_name(uint32_t id)
{
int i;
for (i = 0; i < ARRAY_SIZE(timestamp_ids); i++) {
for (size_t i = 0; i < ARRAY_SIZE(timestamp_ids); i++) {
if (timestamp_ids[i].id == id)
return timestamp_ids[i].name;
}
@ -608,7 +606,6 @@ static int compare_timestamp_entries(const void *a, const void *b)
/* dump the timestamp table */
static void dump_timestamps(int mach_readable)
{
int i;
const struct timestamp_table *tst_p;
struct timestamp_table *sorted_tst_p;
size_t size;
@ -656,7 +653,7 @@ static void dump_timestamps(int mach_readable)
sizeof(struct timestamp_entry), compare_timestamp_entries);
total_time = 0;
for (i = 0; i < sorted_tst_p->num_entries; i++) {
for (uint32_t i = 0; i < sorted_tst_p->num_entries; i++) {
uint64_t stamp;
const struct timestamp_entry *tse = &sorted_tst_p->entries[i];
@ -685,7 +682,6 @@ static void dump_timestamps(int mach_readable)
/* dump the tcpa log table */
static void dump_tcpa_log(void)
{
int i, j;
const struct tcpa_table *tclt_p;
size_t size;
struct mapping tcpa_mapping;
@ -710,12 +706,12 @@ static void dump_tcpa_log(void)
printf("coreboot TCPA log:\n\n");
for (i = 0; i < tclt_p->num_entries; i++) {
for (uint16_t i = 0; i < tclt_p->num_entries; i++) {
const struct tcpa_entry *tce = &tclt_p->entries[i];
printf(" PCR-%u ", tce->pcr);
for (j = 0; j < tce->digest_length; j++)
for (uint32_t j = 0; j < tce->digest_length; j++)
printf("%02x", tce->digest[j]);
printf(" %s [%s]\n", tce->digest_type, tce->name);
@ -806,9 +802,8 @@ static void dump_console(int one_boot_only)
BANNER_REGEX("romstage"),
OVERFLOW_REGEX("ramstage"),
BANNER_REGEX("ramstage") };
int i;
for (i = 0; !cursor && i < ARRAY_SIZE(regex); i++) {
for (size_t i = 0; !cursor && i < ARRAY_SIZE(regex); i++) {
regex_t re;
regmatch_t match;
assert(!regcomp(&re, regex[i], 0));
@ -875,7 +870,6 @@ static void dump_cbmem_hex(void)
void rawdump(uint64_t base, uint64_t size)
{
int i;
const uint8_t *m;
struct mapping dump_mapping;
@ -883,7 +877,7 @@ void rawdump(uint64_t base, uint64_t size)
if (!m)
die("Unable to map rawdump memory\n");
for (i = 0 ; i < size; i++)
for (uint64_t i = 0 ; i < size; i++)
printf("%c", m[i]);
unmap_memory(&dump_mapping);
@ -937,12 +931,11 @@ static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE };
#define MAX_STAGEx 10
void cbmem_print_entry(int n, uint32_t id, uint64_t base, uint64_t size)
{
int i;
const char *name;
char stage_x[20];
name = NULL;
for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
for (size_t i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
if (cbmem_ids[i].id == id) {
name = cbmem_ids[i].name;
break;
@ -1390,11 +1383,10 @@ int main(int argc, char** argv)
parse_cbtable(baseaddr, cb_table_size);
#else
int j;
unsigned long long possible_base_addresses[] = { 0, 0xf0000 };
/* Find and parse coreboot table */
for (j = 0; j < ARRAY_SIZE(possible_base_addresses); j++) {
for (size_t j = 0; j < ARRAY_SIZE(possible_base_addresses); j++) {
if (!parse_cbtable(possible_base_addresses[j], 0))
break;
}