summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-06-27 16:02:32 -0600
committerMartin Roth <martinroth@google.com>2019-07-02 16:11:46 +0000
commit414d5d8698c2acc1655ba59ff794524cd45e7fb6 (patch)
tree6bb8a683d5198bc566c8bfaccb99e5c60997ac11
parenta88921e2b0123226d2258850a229f434007e9807 (diff)
downloadcoreboot-414d5d8698c2acc1655ba59ff794524cd45e7fb6.tar.xz
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>
-rw-r--r--util/cbmem/cbmem.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 9d2a64349c..563bcbe9c2 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -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;
}