Jacob Garber has uploaded this change for review.

View Change

payloads/coreinfo: 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: I73a88355d86288609e03f7a6fcaec14dfedac203
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
---
M payloads/coreinfo/coreboot_module.c
M payloads/coreinfo/coreinfo.c
M payloads/coreinfo/pci_module.c
M payloads/coreinfo/timestamps_module.c
4 files changed, 13 insertions(+), 17 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/33863/1
diff --git a/payloads/coreinfo/coreboot_module.c b/payloads/coreinfo/coreboot_module.c
index d294288..66c2582 100644
--- a/payloads/coreinfo/coreboot_module.c
+++ b/payloads/coreinfo/coreboot_module.c
@@ -195,7 +195,7 @@
/* Now, walk the tables. */
ptr += header->header_bytes;

- for (i = 0; i < header->table_entries; i++) {
+ for (u32 j = 0; j < header->table_entries; j++) {
struct cb_record *rec = (struct cb_record *)ptr;

switch (rec->tag) {
diff --git a/payloads/coreinfo/coreinfo.c b/payloads/coreinfo/coreinfo.c
index 649bfde..b731abf 100644
--- a/payloads/coreinfo/coreinfo.c
+++ b/payloads/coreinfo/coreinfo.c
@@ -132,7 +132,7 @@

static void print_menu(void)
{
- int i, j;
+ int j;
char menu[80];
char *ptr = menu;

@@ -140,11 +140,11 @@
for (j = 0; j < SCREEN_X; j++)
waddch(menuwin, ' ');

- for (i = 0; i < ARRAY_SIZE(categories); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(categories); i++) {
if (categories[i].count == 0)
continue;

- ptr += sprintf(ptr, "F%d: %s ", i + 1, categories[i].name);
+ ptr += sprintf(ptr, "F%zu: %s ", i + 1, categories[i].name);
}

mvwprintw(menuwin, 1, 0, menu);
@@ -215,9 +215,9 @@

static void print_no_modules_selected(void)
{
- int height = getmaxy(stdscr), i;
+ int height = getmaxy(stdscr);

- for (i = 0; i < ARRAY_SIZE(categories); i++)
+ for (size_t i = 0; i < ARRAY_SIZE(categories); i++)
if (categories[i].count > 0)
return;

@@ -227,9 +227,7 @@

static int first_nonempty_category(void)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(categories); i++)
+ for (size_t i = 0; i < ARRAY_SIZE(categories); i++)
if (categories[i].count > 0)
return i;
return 0;
@@ -268,7 +266,7 @@
if (key >= '1' && key <= '9')
ch = key - '1';

- if (ch >= 0 && ch <= ARRAY_SIZE(categories)) {
+ if (ch >= 0 && (unsigned int)ch <= ARRAY_SIZE(categories)) {
if (ch == ARRAY_SIZE(categories))
continue;
if (categories[ch].count == 0)
@@ -289,7 +287,7 @@

int main(void)
{
- int i, j;
+ int j;

if (CONFIG(LP_USB))
usb_initialize();
@@ -310,7 +308,7 @@

werase(modwin);

- for (i = 0; i < ARRAY_SIZE(categories); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(categories); i++) {
for (j = 0; j < categories[i].count; j++)
categories[i].modules[j]->init();
}
diff --git a/payloads/coreinfo/pci_module.c b/payloads/coreinfo/pci_module.c
index 3060161..cb53ed6 100644
--- a/payloads/coreinfo/pci_module.c
+++ b/payloads/coreinfo/pci_module.c
@@ -51,7 +51,7 @@

static int partition(struct pci_devices *list, int len)
{
- int val = list[len / 2].device;
+ pcidev_t val = list[len / 2].device;
int index = 0;
int i;

diff --git a/payloads/coreinfo/timestamps_module.c b/payloads/coreinfo/timestamps_module.c
index fe2d2b5..5468844 100644
--- a/payloads/coreinfo/timestamps_module.c
+++ b/payloads/coreinfo/timestamps_module.c
@@ -29,9 +29,7 @@

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;
}
@@ -184,7 +182,7 @@
prev_stamp = base_time;

total_time = 0;
- for (int i = 0; i < n_entries; i++) {
+ for (u32 i = 0; i < n_entries; i++) {
uint64_t stamp;
const struct timestamp_entry *tse = &timestamps->entries[i];


To view, visit change 33863. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I73a88355d86288609e03f7a6fcaec14dfedac203
Gerrit-Change-Number: 33863
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1@ualberta.ca>
Gerrit-MessageType: newchange