Skip to contentSkip to conversation

udbg_printf() formatting attribute

PATCH RESEND In review [email protected] 2 participants 6 messages May 17, 2006 – May 22, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 udbg_printf() formatting attribute

Sorry, Previous patch was munged by MTA.

This patch allows the compiler to catch any printf-like mismatches for udbg_printf(). After some brute force building I've only found issues with my own code and lparcfg.c It could break some developers, but IMHO that would be goodness.

---

arch/powerpc/kernel/lparcfg.c +2 -2
diff -r 0163968f7fce arch/powerpc/kernel/lparcfg.c
@@ -521,10 +521,10 @@ static ssize_t lparcfg_write(struct file
 
 	current_weight = (resource >> 5 * 8) & 0xFF;
 
-	pr_debug("%s: current_entitled = %lu, current_weight = %lu\n",
+	pr_debug("%s: current_entitled = %lu, current_weight = %u\n",
 		 __FUNCTION__, current_entitled, current_weight);
 
-	pr_debug("%s: new_entitled = %lu, new_weight = %lu\n",
+	pr_debug("%s: new_entitled = %lu, new_weight = %u\n",
 		 __FUNCTION__, *new_entitled_ptr, *new_weight_ptr);
 
 	retval = plpar_hcall_norets(H_SET_PPP, *new_entitled_ptr,
include/asm-powerpc/udbg.h +2 -1
diff -r 0163968f7fce include/asm-powerpc/udbg.h
@@ -23,7 +23,8 @@ extern int udbg_read(char *buf, int bufl
 extern int udbg_read(char *buf, int buflen);
 
 extern void register_early_udbg_console(void);
-extern void udbg_printf(const char *fmt, ...);
+extern void udbg_printf(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));
 extern void udbg_progress(char *s, unsigned short hex);
 
 extern void udbg_init_uart(void __iomem *comport, unsigned int speed,
#1 lore raw
Quoted 15 lines · On Wed, 2006-05-17 at 12:00 -0400, [email protected] wrote:

Sorry, Previous patch was munged by MTA.

This patch allows the compiler to catch any printf-like mismatches for udbg_printf(). After some brute force building I've only found issues with my own code and lparcfg.c It could break some developers, but IMHO that would be goodness.

---

diff -r 0163968f7fce arch/powerpc/kernel/lparcfg.c

arch/powerpc/kernel/lparcfg.c static ssize_t lparcfg_write(struct file · line 528

Quoted 10 lines
arch/powerpc/kernel/lparcfg.c +2 -2
@@ -521,10 +521,10 @@ static ssize_t lparcfg_write(struct file
 
 	current_weight = (resource >> 5 * 8) & 0xFF;
 
-	pr_debug("%s: current_entitled = %lu, current_weight = %lu\n",
+	pr_debug("%s: current_entitled = %lu, current_weight = %u\n",
 		 __FUNCTION__, current_entitled, current_weight);
 
-	pr_debug("%s: new_entitled = %lu, new_weight = %lu\n",
+	pr_debug("%s: new_entitled = %lu, new_weight = %u\n",
 		 __FUNCTION__, *new_entitled_ptr, *new_weight_ptr);

But pr_debug() calls printk, not udbg_printf() ?

cheers

Quoted 15 lines
arch/powerpc/kernel/lparcfg.c +0 -0
 	retval = plpar_hcall_norets(H_SET_PPP, *new_entitled_ptr,

diff -r 0163968f7fce include/asm-powerpc/udbg.h

include/asm-powerpc/udbg.h +2 -1
@@ -23,7 +23,8 @@ extern int udbg_read(char *buf, int bufl
 extern int udbg_read(char *buf, int buflen);
 
 extern void register_early_udbg_console(void);
-extern void udbg_printf(const char *fmt, ...);
+extern void udbg_printf(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));
 extern void udbg_progress(char *s, unsigned short hex);
 
 extern void udbg_init_uart(void __iomem *comport, unsigned int speed,
Signature · 8 lines
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#2 lore raw
Quoted 10 lines · Michael Ellerman

arch/powerpc/kernel/lparcfg.c static ssize_t lparcfg_write(struct file · line 528

Quoted 7 lines · On Wed, 2006-05-17 at 12:00 -0400, [email protected] wrote:
arch/powerpc/kernel/lparcfg.c +2 -2
-	pr_debug("%s: current_entitled = %lu, current_weight = %lu\n",
+	pr_debug("%s: current_entitled = %lu, current_weight = %u\n",
 		 __FUNCTION__, current_entitled, current_weight);
 
-	pr_debug("%s: new_entitled = %lu, new_weight = %lu\n",
+	pr_debug("%s: new_entitled = %lu, new_weight = %u\n",
 		 __FUNCTION__, *new_entitled_ptr, *new_weight_ptr);

But pr_debug() calls printk, not udbg_printf() ?

Now _thats_ funny!
Then I'm so happy to have found and fixed this compiler warning :)

Quoted 3 lines

include/asm-powerpc/udbg.h extern int udbg_read(char *buf, int bufl · line 27

Quoted 3 lines
include/asm-powerpc/udbg.h +2 -1
-extern void udbg_printf(const char *fmt, ...);
+extern void udbg_printf(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));

I believe this chunk is still goodness as it will catch format issues for developers. -JX

#3 lore raw
Quoted 7 lines · Jimi Xenidis
Quoted 5 lines · Michael Ellerman
Quoted 4 lines · On Wed, 2006-05-17 at 12:00 -0400, [email protected] wrote:
arch/powerpc/kernel/lparcfg.c +1 -1
-	pr_debug("%s: current_entitled = %lu, current_weight = %lu\n",
+	pr_debug("%s: current_entitled = %lu, current_weight = %u\n",
 		 __FUNCTION__, current_entitled, current_weight);
Quoted 8 lines
Quoted 5 lines

arch/powerpc/kernel/lparcfg.c static ssize_t lparcfg_write(struct file · line 528

Quoted 3 lines
arch/powerpc/kernel/lparcfg.c +1 -1
-	pr_debug("%s: new_entitled = %lu, new_weight = %lu\n",
+	pr_debug("%s: new_entitled = %lu, new_weight = %u\n",
 		 __FUNCTION__, *new_entitled_ptr, *new_weight_ptr);

But pr_debug() calls printk, not udbg_printf() ?

Now _thats_ funny!
Then I'm so happy to have found and fixed this compiler warning :)

Haha, nice one Jimi :D

Quoted 6 lines
Quoted 3 lines

include/asm-powerpc/udbg.h extern int udbg_read(char *buf, int bufl · line 27

Quoted 3 lines
include/asm-powerpc/udbg.h +2 -1
-extern void udbg_printf(const char *fmt, ...);
+extern void udbg_printf(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));

I believe this chunk is still goodness as it will catch format issues for developers.

I'm actually hoping to get rid of udbg_printf(), but if I can't we should stick this in I guess. The real problem IMHO is that debug printks rot because they're rarely compiled, not sure what to do about that.

cheers

Signature · 8 lines
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#4 lore raw
Quoted 5 lines · Michael Ellerman

I'm actually hoping to get rid of udbg_printf(), but if I can't we should stick this in I guess. The real problem IMHO is that debug printks rot because they're rarely compiled, not sure what to do about that.

Yeah, debug code always has that problem. But I must say, whenever I work with the x86 guys and I see how long they are _blind_ when they boot it blows my mind. Lets hope we don't go there. -JX

#5 lore raw
Quoted 10 lines · Jimi Xenidis
Quoted 5 lines · Michael Ellerman

I'm actually hoping to get rid of udbg_printf(), but if I can't we should stick this in I guess. The real problem IMHO is that debug printks rot because they're rarely compiled, not sure what to do about that.

Yeah, debug code always has that problem. But I must say, whenever I work with the x86 guys and I see how long they are _blind_ when they boot it blows my mind. Lets hope we don't go there.

Yeah nuts. Don't worry, when I say "get rid of udbg_printf()" I mean "replace with printk".

cheers

Signature · 8 lines
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person