[PATCH 1/8] firmware: correct format strings

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


this eliminates the occurrance of gcc warning
warning: format ‘?’ expects type ‘?’, but argument ? has type ‘?’
---
 src/target/firmware/apps/loader/main.c |    4 ++--
 src/target/firmware/calypso/dsp.c      |    5 +++--
 src/target/firmware/calypso/keypad.c   |    3 ++-
 src/target/firmware/flash/cfi_flash.c  |   13 +++++++------
 src/target/firmware/layer1/prim_fbsb.c |    9 +++++----
 src/target/firmware/layer1/prim_freq.c |    3 ++-
 6 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/target/firmware/apps/loader/main.c b/src/target/firmware/apps/loader/main.c
index 2ff6f9c..18f0b36 100644
--- a/src/target/firmware/apps/loader/main.c
+++ b/src/target/firmware/apps/loader/main.c
@@ -162,13 +162,13 @@ int main(void)
 	if (flash_init(&the_flash, 0)) {
 		puts("Failed to initialize flash!\n");
 	} else {
-		printf("Found flash of %d bytes at 0x%x with %d regions\n",
+		printf("Found flash of %zu bytes at 0x%p with %zu regions\n",
 		       the_flash.f_size, the_flash.f_base,
 		       the_flash.f_nregions);
 
 		int i;
 		for (i = 0; i < the_flash.f_nregions; i++) {
-			printf("  Region %d of %d pages with %d bytes each.\n",
+			printf("  Region %d of %zu pages with %zu bytes each.\n",
 			       i,
 			       the_flash.f_regions[i].fr_bnum,
 			       the_flash.f_regions[i].fr_bsize);
diff --git a/src/target/firmware/calypso/dsp.c b/src/target/firmware/calypso/dsp.c
index 1daecb2..8bf9749 100644
--- a/src/target/firmware/calypso/dsp.c
+++ b/src/target/firmware/calypso/dsp.c
@@ -23,6 +23,7 @@
 
 #include <stdint.h>
 #include <stdio.h>
+#include <inttypes.h>
 
 #include <debug.h>
 #include <delay.h>
@@ -639,7 +640,7 @@ static void _dsp_dump_range(uint32_t addr, uint32_t size, int mode)
 			 * the sercomm buffer */
 			delay_ms(2);
 			if ((addr&15)==0)
-				printf("%05x : ", addr);
+				printf("%05"PRIx32" : ", addr);
 			printf("%04hx%c", *api++, ((addr&15)==15)?'\n':' ');
 			addr++;
 		}
@@ -685,7 +686,7 @@ void dsp_dump(void)
 
 	/* Dump each range */
 	for (i=0; dr[i].name; i++) {
-		printf("DSP dump: %s [%05x-%05x]\n", dr[i].name,
+		printf("DSP dump: %s [%05"PRIx32"-%05lx]\n", dr[i].name,
 			dr[i].addr, dr[i].addr+dr[i].size-1);
 		_dsp_dump_range(dr[i].addr, dr[i].size, dr[i].mode);
 	}
diff --git a/src/target/firmware/calypso/keypad.c b/src/target/firmware/calypso/keypad.c
index fd4e0ff..30fb3b9 100644
--- a/src/target/firmware/calypso/keypad.c
+++ b/src/target/firmware/calypso/keypad.c
@@ -22,6 +22,7 @@
 
 #include <stdint.h>
 #include <stdio.h>
+#include <inttypes.h>
 
 #include <defines.h>
 #include <debug.h>
@@ -98,7 +99,7 @@ void dispatch_buttons(uint32_t buttons)
 		else if BTN_TO_KEY(OK)
 		else
 		{
-			printf("\nunknown keycode: 0x%08x\n", diff);
+			printf("\nunknown keycode: 0x%08"PRIx32"\n", diff);
 			break;
 		}
 		emit_key(key, state);
diff --git a/src/target/firmware/flash/cfi_flash.c b/src/target/firmware/flash/cfi_flash.c
index 69369d5..4f31d78 100644
--- a/src/target/firmware/flash/cfi_flash.c
+++ b/src/target/firmware/flash/cfi_flash.c
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <memory.h>
 #include <defines.h>
 #include <flash/cfi_flash.h>
@@ -184,7 +185,7 @@ int flash_block_unlock(flash_t * flash, uint32_t block_offset)
 		return -EPERM;
 	}
 
-	printf("Unlocking block at 0x%08x, meaning %08x\n",
+	printf("Unlocking block at 0x%08"PRIx32", meaning %8p\n",
 		   block_offset, base_addr + block_offset);
 
 	flash_write_cmd(base_addr, CFI_CMD_PROTECT);
@@ -203,7 +204,7 @@ int flash_block_lock(flash_t * flash, uint32_t block_offset)
 		return -EINVAL;
 	}
 
-	printf("Locking block at 0x%08x\n", block_offset);
+	printf("Locking block at 0x%08"PRIx32"\n", block_offset);
 
 	flash_write_cmd(base_addr, CFI_CMD_PROTECT);
 	flash_write_cmd(base_addr + block_offset, CFI_PROT_LOCK);
@@ -221,7 +222,7 @@ int flash_block_lockdown(flash_t * flash, uint32_t block_offset)
 		return -EINVAL;
 	}
 
-	printf("Locking down block at 0x%08x\n", block_offset);
+	printf("Locking down block at 0x%08"PRIx32"\n", block_offset);
 
 	flash_write_cmd(base_addr, CFI_CMD_PROTECT);
 	flash_write_cmd(base_addr + block_offset, CFI_PROT_LOCKDOWN);
@@ -243,7 +244,7 @@ int flash_block_erase(flash_t * flash, uint32_t block_offset)
 		return -EPERM;
 	}
 
-	printf("Erasing block 0x%08x...", block_offset);
+	printf("Erasing block 0x%08"PRIx32"...", block_offset);
 
 	void *block_addr = ((uint8_t *) base_addr) + block_offset;
 
@@ -313,7 +314,7 @@ int flash_program(flash_t * flash, uint32_t dst, void *src, uint32_t nbytes)
 	}
 
 	/* say something */
-	printf("Programming %u bytes to 0x%08x from 0x%p...", nbytes, dst, src);
+	printf("Programming %"PRIu32" bytes to 0x%08"PRIx32" from 0x%p...", nbytes, dst, src);
 
 	/* clear status register */
 	flash_write_cmd(base_addr, CFI_CMD_CLEAR_STATUS);
@@ -373,7 +374,7 @@ int flash_program(flash_t * flash, uint32_t dst, void *src, uint32_t nbytes)
 	flash_write_cmd(base_addr, CFI_CMD_RESET);
 
  err:
-	printf(" at offset 0x%x\n", i);
+	printf(" at offset 0x%"PRIx32"\n", i);
 
 	return res;
 }
diff --git a/src/target/firmware/layer1/prim_fbsb.c b/src/target/firmware/layer1/prim_fbsb.c
index 7affd75..023902d 100644
--- a/src/target/firmware/layer1/prim_fbsb.c
+++ b/src/target/firmware/layer1/prim_fbsb.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include <defines.h>
 #include <debug.h>
@@ -93,7 +94,7 @@ static void dump_mon_state(struct mon_state *fb)
 		fb->snr, l1s_snr_int(fb->snr), l1s_snr_fract(fb->snr),
 		tpu_get_offset(), tpu_get_synchro());
 #else
-	printf("(%u:%u): TOA=%5u, Power=%4ddBm, Angle=%5dHz\n",
+	printf("(%"PRIu32":%u): TOA=%5u, Power=%4ddBm, Angle=%5dHz\n",
 		fb->fnr_report, fb->attempt, fb->toa,
 		agc_inp_dbm8_by_pm(fb->pm)/8, ANGLE_TO_FREQ(fb->angle));
 #endif
@@ -201,7 +202,7 @@ static int l1s_sbdet_resp(__unused uint8_t p1, uint8_t attempt,
 
 	sb = dsp_api.db_r->a_sch[3] | dsp_api.db_r->a_sch[4] << 16;
 	fbs.mon.bsic = l1s_decode_sb(&fbs.mon.time, sb);
-	printf("=> SB 0x%08x: BSIC=%u ", sb, fbs.mon.bsic);
+	printf("=> SB 0x%08"PRIx32": BSIC=%u ", sb, fbs.mon.bsic);
 	l1s_time_dump(&fbs.mon.time);
 
 	l1s.serving_cell.bsic = fbs.mon.bsic;
@@ -480,9 +481,9 @@ static int l1s_fbdet_resp(__unused uint8_t p1, uint8_t attempt,
 
 			int fn_offset = l1s.current_time.fn - last_fb->attempt + ntdma;
 			int delay = fn_offset + 11 - l1s.current_time.fn - 1;
-			printf("  fn_offset=%d (fn=%u + attempt=%u + ntdma = %d)\n",
+			printf("  fn_offset=%d (fn=%"PRIu32" + attempt=%u + ntdma = %d)\n",
 				fn_offset, l1s.current_time.fn, last_fb->attempt, ntdma);
-			printf("  delay=%d (fn_offset=%d + 11 - fn=%u - 1\n", delay,
+			printf("  delay=%d (fn_offset=%d + 11 - fn=%"PRIu32" - 1\n", delay,
 				fn_offset, l1s.current_time.fn);
 			printf("  scheduling next FB/SB detection task with delay %u\n", delay);
 			if (abs(last_fb->freq_diff) < fbs.req.freq_err_thresh2 &&
diff --git a/src/target/firmware/layer1/prim_freq.c b/src/target/firmware/layer1/prim_freq.c
index 88bc453..64e08b5 100644
--- a/src/target/firmware/layer1/prim_freq.c
+++ b/src/target/firmware/layer1/prim_freq.c
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <inttypes.h>
 
 #include <defines.h>
 #include <debug.h>
@@ -102,7 +103,7 @@ void l1a_freq_req(uint32_t fn_sched)
 	fn_sched = l1s.current_time.fn + diff;
 	if (fn_sched >= GSM_MAX_FN)
 		fn_sched -= GSM_MAX_FN;
-	printf("Scheduling frequency change at fn=%u, currently fn=%u\n",
+	printf("Scheduling frequency change at fn=%"PRIu32", currently fn=%"PRIu32"\n",
 		fn_sched, l1s.current_time.fn);
 
 	local_firq_save(flags);
-- 
1.7.8.rc1





More information about the baseband-devel mailing list