[PATCH 5/8] firmware: correct signedness of comparisons

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Alexander Huemer alexander.huemer at xx.vu
Wed Nov 23 22:59:41 UTC 2011


this eliminates the occurrance of gcc warning
warning: comparison between signed and unsigned
---
 src/target/firmware/apps/loader/main.c |   10 +++++-----
 src/target/firmware/flash/cfi_flash.c  |    2 +-
 src/target/firmware/layer1/prim_pm.c   |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/target/firmware/apps/loader/main.c b/src/target/firmware/apps/loader/main.c
index 602297b..b4c51de 100644
--- a/src/target/firmware/apps/loader/main.c
+++ b/src/target/firmware/apps/loader/main.c
@@ -125,7 +125,7 @@ static const uint8_t phone_ack[] = { 0x1b, 0xf6, 0x02, 0x00, 0x41, 0x03, 0x42 };
 int main(void)
 {
 	/* Simulate a compal loader saying "ACK" */
-	int i = 0;
+	unsigned int i;
 	for (i = 0; i < sizeof(phone_ack); i++) {
 		putchar_asm(phone_ack[i]);
 	}
@@ -166,11 +166,11 @@ int main(void)
 		       the_flash.f_size, the_flash.f_base,
 		       the_flash.f_nregions);
 
-		int i;
-		for (i = 0; i < the_flash.f_nregions; i++) {
+		unsigned int j;
+		for (j = 0; j < the_flash.f_nregions; j++) {
 			printf("  Region %d of %zu pages with %zu bytes each.\n",
 			       i,
-			       the_flash.f_regions[i].fr_bnum,
+			       the_flash.f_regions[j].fr_bnum,
 			       the_flash.f_regions[i].fr_bsize);
 		}
 
@@ -312,7 +312,7 @@ static void cmd_handler(uint8_t dlci, struct msgb *msg)
 		msgb_put_u32(reply, the_flash.f_size);
 		msgb_put_u8(reply, the_flash.f_nregions);
 
-		int i;
+		unsigned int i;
 		for (i = 0; i < the_flash.f_nregions; i++) {
 			msgb_put_u32(reply, the_flash.f_regions[i].fr_bnum);
 			msgb_put_u32(reply, the_flash.f_regions[i].fr_bsize);
diff --git a/src/target/firmware/flash/cfi_flash.c b/src/target/firmware/flash/cfi_flash.c
index 167cf20..eaaedff 100644
--- a/src/target/firmware/flash/cfi_flash.c
+++ b/src/target/firmware/flash/cfi_flash.c
@@ -402,7 +402,7 @@ __ramtext
 static int get_query(void *base_addr, struct cfi_query *query)
 {
 	int res = 0;
-	int i;
+	unsigned int i;
 
 	flash_write_cmd(base_addr, CFI_CMD_CFI);
 
diff --git a/src/target/firmware/layer1/prim_pm.c b/src/target/firmware/layer1/prim_pm.c
index 640f960..54a6780 100644
--- a/src/target/firmware/layer1/prim_pm.c
+++ b/src/target/firmware/layer1/prim_pm.c
@@ -101,7 +101,7 @@ static int l1s_pm_resp(uint8_t num_meas, __unused uint8_t p2,
 	if (!l1s.pm.msg)
 		l1s.pm.msg = l1ctl_msgb_alloc(L1CTL_PM_CONF);
 
-	if (msgb_tailroom(l1s.pm.msg) < sizeof(*pmr)) {
+	if (msgb_tailroom(l1s.pm.msg) < (int)sizeof(*pmr)) {
 		/* flush current msgb */
 		l1_queue_for_l2(l1s.pm.msg);
 		/* allocate a new msgb and initialize header */
-- 
1.7.8.rc1





More information about the baseband-devel mailing list