[PATCH] pktgen: sprintf arg type warning

STALE7981d

6 messages, 4 authors, 2004-10-09 · open the first message on its own page

[PATCH] pktgen: sprintf arg type warning

From: Randy.Dunlap <hidden>
Date: 2004-10-09 03:30:27

Fix sprintf arg type error (gcc 3.3.3), although it looks more like
a gcc problem than a kernel source code problem to me.
Doesn't matter on x86-32.  Fixes a warning on x86-64.

net/core/pktgen.c:607: warning: long long unsigned int format, long unsigned int arg (arg 4)

Signed-off-by: Randy Dunlap <redacted>


diffstat:=
 net/core/pktgen.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff -Naurp ./net/core/pktgen.c~pktgen_type ./net/core/pktgen.c
--- ./net/core/pktgen.c~pktgen_type	2004-10-06 15:04:06.260548504 -0700
+++ ./net/core/pktgen.c	2004-10-08 20:16:57.191340296 -0700
@@ -603,7 +603,7 @@ static void show_results(struct pktgen_i
 	do_div(idle, cpu_speed);
 
 	p += sprintf(p, "OK: %llu(c%llu+d%lu) usec, %llu (%dbyte,%dfrags)\n",
-		     total, total - idle, idle,
+		     total, total - (__u64)idle, idle,
 		     info->sofar, size, nr_frags);
 
 	pps = info->sofar * USEC_PER_SEC;


--
~Randy

Re: [PATCH] pktgen: sprintf arg type warning

From: "David S. Miller" <davem@davemloft.net>
Date: 2004-10-09 05:19:34

On Fri, 8 Oct 2004 20:30:27 -0700
"Randy.Dunlap" [off-list ref] wrote:
Fix sprintf arg type error (gcc 3.3.3), although it looks more like
a gcc problem than a kernel source code problem to me.
Doesn't matter on x86-32.  Fixes a warning on x86-64.

net/core/pktgen.c:607: warning: long long unsigned int format, long unsigned int arg (arg 4)
This won't fix the problem on sparc64 where u64 is an "unsigned long"
So, just cast the thing to the type gcc wants "unsigned long long"

Re: [PATCH] pktgen: sprintf arg type warning

From: Sam Leffler <hidden>
Date: 2004-10-09 17:30:09

David S. Miller wrote:
On Fri, 8 Oct 2004 20:30:27 -0700
"Randy.Dunlap" [off-list ref] wrote:

quoted
Fix sprintf arg type error (gcc 3.3.3), although it looks more like
a gcc problem than a kernel source code problem to me.
Doesn't matter on x86-32.  Fixes a warning on x86-64.

net/core/pktgen.c:607: warning: long long unsigned int format, long unsigned int arg (arg 4)

This won't fix the problem on sparc64 where u64 is an "unsigned long"
So, just cast the thing to the type gcc wants "unsigned long long"
Other systems have addressed this problem by extending printf with 
portable %formats.

	Sam

Re: [PATCH] pktgen: sprintf arg type warning

From: Andi Kleen <hidden>
Date: 2004-10-09 17:36:44

Other systems have addressed this problem by extending printf with 
portable %formats.
Problem is that gcc -Wformat doesn't know the new format codes,
and in Linux we still have to support old gcc versions.

Standard trick is to cast to long.

-Andi

Re: [PATCH] pktgen: sprintf arg type warning

From: Sam Leffler <hidden>
Date: 2004-10-09 17:49:55

Andi Kleen wrote:
quoted
Other systems have addressed this problem by extending printf with 
portable %formats.

Problem is that gcc -Wformat doesn't know the new format codes,
and in Linux we still have to support old gcc versions.
Yes, gcc has been modified to understand the new %formats.  That's the 
advantage to distributing a full system and not just a kernel :)
Standard trick is to cast to long.

-Andi

[PATCH] pktgen: sprintf arg type warning

From: Randy.Dunlap <hidden>
Date: 2004-10-09 22:07:03

This won't fix the problem on sparc64 where u64 is an "unsigned long"
So, just cast the thing to the type gcc wants "unsigned long long"
Yep, I should have known that.  New patch attached.

(Note:  testing new mail client; hopefully it's not munged.)

-- 
~Randy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help