[PATCH 8] Cosmetic fixes, including format attributes for printf() and friends.

Krzysztof Halasa khc at pm.waw.pl
Mon Dec 20 18:02:02 EST 2010


Signed-off-by: Krzysztof Hałasa <khc at pm.waw.pl>

diff --git a/commands/crc.c b/commands/crc.c
index 0873a1c..993074c 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -134,7 +134,7 @@ static int do_crc(struct command *cmdtp, int argc, char *argv[])
 #endif
 
 	if (verify && crc != vcrc) {
-		printf(" != 0x%08x ** ERROR **", vcrc);
+		printf(" != 0x%08lx ** ERROR **", vcrc);
 		err = 1;
 	}
 
diff --git a/commands/flash.c b/commands/flash.c
index 9a0eb50..a3f3508 100644
--- a/commands/flash.c
+++ b/commands/flash.c
@@ -63,7 +63,7 @@ static int do_flerase(struct command *cmdtp, int argc, char *argv[])
 
 	fd = open(filename, O_WRONLY);
 	if (fd < 0) {
-		printf("open %s:", filename, errno_str());
+		printf("open %s: %s", filename, errno_str());
 		return 1;
 	}
 
@@ -139,7 +139,7 @@ static int do_protect(struct command *cmdtp, int argc, char *argv[])
 
 	fd = open(filename, O_WRONLY);
 	if (fd < 0) {
-		printf("open %s:", filename, errno_str());
+		printf("open %s: %s", filename, errno_str());
 		return 1;
 	}
 
diff --git a/commands/go.c b/commands/go.c
index 0262940..6082fe5 100644
--- a/commands/go.c
+++ b/commands/go.c
@@ -55,7 +55,7 @@ static int do_go(struct command *cmdtp, int argc, char *argv[])
 	} else
 		addr = (void *)simple_strtoul(argv[1], NULL, 16);
 
-	printf("## Starting application at 0x%08lX ...\n", addr);
+	printf("## Starting application at 0x%p ...\n", addr);
 
 	console_flush();
 
diff --git a/commands/loadb.c b/commands/loadb.c
index dc0e517..439a83a 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -625,7 +625,6 @@ static ulong load_serial_ymodem(void)
 	int res, wr;
 	connection_info_t info;
 	char ymodemBuf[1024];
-	ulong store_addr = ~0;
 	ulong addr = 0;
 
 	size = 0;
diff --git a/commands/ls.c b/commands/ls.c
index 4f9c408..278a8bc 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -32,10 +32,10 @@
 static void ls_one(const char *path, struct stat *s)
 {
 	char modestr[11];
-	unsigned long namelen = strlen(path);
+	unsigned int namelen = strlen(path);
 
 	mkmodestr(s->st_mode, modestr);
-	printf("%s %10u %*.*s\n", modestr, s->st_size, namelen, namelen, path);
+	printf("%s %10lu %*.*s\n", modestr, s->st_size, namelen, namelen, path);
 }
 
 int ls(const char *path, ulong flags)
diff --git a/commands/menu.c b/commands/menu.c
index b9d6699..c3e0901 100644
--- a/commands/menu.c
+++ b/commands/menu.c
@@ -119,7 +119,7 @@ static int do_menu_entry_remove(struct cmd_menu *cm)
 	me = menu_entry_get_by_num(m, cm->num);
 
 	if (!me) {
-		eprintf("Entry '%s' not found\n", cm->num);
+		eprintf("Entry '%i' not found\n", cm->num);
 		return -EINVAL;
 	}
 
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index 7d55a61..fd40f62 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -7,7 +7,6 @@
 #include <mach/netx-eth.h>
 #include <mach/netx-regs.h>
 #include <xfuncs.h>
-#include <miidev.h>
 #include <init.h>
 #include <driver.h>
 
diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index f7eeb2a..677a59d 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -485,7 +485,7 @@ static int __cfi_erase(struct cdev *cdev, size_t count, unsigned long offset,
         unsigned long start, end;
         int i, ret = 0;
 
-	debug("%s: erase 0x%08x (size %d)\n", __func__, offset, count);
+	debug("%s: erase 0x%08lx (size %d)\n", __func__, offset, count);
 
         start = find_sector(finfo, cdev->dev->map_base + offset);
         end   = find_sector(finfo, cdev->dev->map_base + offset + count - 1);
@@ -651,8 +651,8 @@ static int cfi_protect(struct cdev *cdev, size_t count, unsigned long offset, in
 	int i, ret = 0;
 	const char *action = (prot? "protect" : "unprotect");
 
-	printf("%s: %s 0x%08x (size %d)\n", __FUNCTION__,
-		action, cdev->dev->map_base + offset, count);
+	printf("%s: %s 0x%08lx (size %d)\n", __FUNCTION__,
+	       action, cdev->dev->map_base + offset, count);
 
 	start = find_sector(finfo, cdev->dev->map_base + offset);
 	end   = find_sector(finfo, cdev->dev->map_base + offset + count - 1);
@@ -1007,7 +1007,7 @@ static int cfi_probe (struct device_d *dev)
 	info->base = (void __iomem *)dev->map_base;
 
 	if (dev->size == 0) {
-		printf("cfi_probe: size : 0x%08x\n", info->size);
+		printf("cfi_probe: size : 0x%08lx\n", info->size);
 		dev->size = info->size;
 	}
 
diff --git a/include/stdio.h b/include/stdio.h
index 8bc45fa..c824764 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -9,7 +9,7 @@
  */
 
 /* serial stuff */
-void	serial_printf (const char *fmt, ...);
+void	serial_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
 
 /* stdin */
 int	tstc(void);
@@ -20,20 +20,22 @@ int	getc(void);
 void	console_puts(unsigned int ch, const char *s);
 void	console_flush(void);
 
-static inline void puts(const char *s) {
+static inline void puts(const char *s)
+{
 	console_puts(CONSOLE_STDOUT, s);
 }
 
-static inline void putchar(char c) {
+static inline void putchar(char c)
+{
 	console_putc(CONSOLE_STDOUT, c);
 }
 
-int	printf(const char *fmt, ...);
+int	printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
 int	vprintf(const char *fmt, va_list args);
-int	sprintf(char * buf, const char *fmt, ...);
-int	snprintf(char *buf, size_t size, const char *fmt, ...);
+int	sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
+int	snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(printf, 3, 4)));
 int	vsprintf(char *buf, const char *fmt, va_list args);
-char	*asprintf(const char *fmt, ...);
+char	*asprintf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
 char	*vasprintf(const char *fmt, va_list ap);
 int	vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
 int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
@@ -52,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 #define stderr		2
 #define MAX_FILES	128
 
-void	fprintf(int file, const char *fmt, ...);
+void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
 int	fputs(int file, const char *s);
 int	fputc(int file, const char c);
 int	ftstc(int file);
diff --git a/net/tftp.c b/net/tftp.c
index 6be8b8f..0f38b6b 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -218,7 +218,7 @@ static void tftp_handler(char *packet, unsigned len)
 			tftp_last_block = 0;
 
 			if (tftp_block != 1) {	/* Assertion */
-				printf("error: First block is not block 1 (%ld)\n",
+				printf("error: First block is not block 1 (%d)\n",
 					tftp_block);
 				tftp_err = -EINVAL;
 				tftp_state = STATE_DONE;



More information about the barebox mailing list