Skip to contentSkip to conversation

: Remove build warnings on 64-bit architecture

PATCH In review Gerrit Renker 3 participants 3 messages Jan 12, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Remove build warnings on 64-bit architecture

[CCID 3]: Remove build warnings on 64-bit architecure

This clears build warnings which will appear on some architectures such as sparc64.

These warnings were of the following type:
warning: format "%llu" expects type "long long unsigned int", but argument 3 has type "__u64"
warning: format "%ld" expects type "long int", but argument 3 has type "suseconds_t"

---
 net/dccp/ccids/ccid3.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
net/dccp/ccids/ccid3.c +8 -6
@@ -93,9 +93,9 @@ static inline void ccid3_update_send_int
 	hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2,
 					   TFRC_OPSYS_HALF_TIME_GRAN);
 
-	ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%llu\n",
+	ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%u\n",
 		       hctx->ccid3hctx_t_ipi, hctx->ccid3hctx_delta,
-		       hctx->ccid3hctx_s, hctx->ccid3hctx_x >> 6);
+		       hctx->ccid3hctx_s, (unsigned)(hctx->ccid3hctx_x >> 6));
 
 }
 /*
@@ -138,9 +138,11 @@ static void ccid3_hc_tx_update_x(struct 
 	}
 
 	if (hctx->ccid3hctx_x != old_x) {
-		ccid3_pr_debug("X_prev=%llu, X_now=%llu, X_calc=%u, "
-			       "X_recv=%llu\n", old_x >> 6, hctx->ccid3hctx_x >> 6,
-			       hctx->ccid3hctx_x_calc, hctx->ccid3hctx_x_recv >> 6);
+		ccid3_pr_debug("X_prev=%u, X_now=%u, X_calc=%u, "
+			       "X_recv=%u\n", (unsigned)(old_x >> 6),
+			       (unsigned)(hctx->ccid3hctx_x >> 6),
+			       hctx->ccid3hctx_x_calc,
+			       (unsigned)(hctx->ccid3hctx_x_recv >> 6));
 
 		ccid3_update_send_interval(hctx);
 	}
@@ -899,7 +901,7 @@ static void ccid3_hc_rx_packet_recv(stru
 		DCCP_BUG_ON(r_sample < 0);
 		if (unlikely(r_sample <= t_elapsed))
 			DCCP_WARN("r_sample=%ldus, t_elapsed=%ldus\n",
-				  r_sample, t_elapsed);
+				  (long)r_sample, (long)t_elapsed);
 		else
 			r_sample -= t_elapsed;
 		CCID3_RTT_SANITY_CHECK(r_sample);
#1 lore raw
Quoted 16 lines · Gerrit Renker

[CCID 3]: Remove build warnings on 64-bit architecure

This clears build warnings which will appear on some architectures such as sparc64.

These warnings were of the following type:
warning: format "%llu" expects type "long long unsigned int", but argument 3 has type "__u64"
warning: format "%ld" expects type "long int", but argument 3 has type "suseconds_t"

---
 net/dccp/ccids/ccid3.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

net/dccp/ccids/ccid3.c static inline void ccid3_update_send_int · line 99

Quoted 9 lines
net/dccp/ccids/ccid3.c +2 -2
@@ -93,9 +93,9 @@ static inline void ccid3_update_send_int
        hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2,
                                           TFRC_OPSYS_HALF_TIME_GRAN);
 
-       ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%llu\n",
+       ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%u\n",
                       hctx->ccid3hctx_t_ipi, hctx->ccid3hctx_delta,
-                      hctx->ccid3hctx_s, hctx->ccid3hctx_x >> 6);
+                      hctx->ccid3hctx_s, (unsigned)(hctx->ccid3hctx_x >> 6));
 

You lose precision here since ccid3hctx_x is 64 bit and %u is 32 bit on a 32 bit platform. You should do a cast to (long long unsigned) on the last line rather than (unsigned) and leave the format as %llu I think.

Quoted 7 lines
net/dccp/ccids/ccid3.c +0 -1
 }
 /*
@@ -138,9 +138,11 @@ static void ccid3_hc_tx_update_x(struct
        }
 
        if (hctx->ccid3hctx_x != old_x) {
-               ccid3_pr_debug("X_prev=%llu, X_now=%llu, X_calc=%u, "

net/dccp/ccids/ccid3.c static void ccid3_hc_tx_update_x(struct · line 148

Quoted 10 lines
net/dccp/ccids/ccid3.c +5 -2
-                              "X_recv=%llu\n", old_x >> 6, hctx->ccid3hctx_x >> 6,
-                              hctx->ccid3hctx_x_calc, hctx->ccid3hctx_x_recv >> 6);
+               ccid3_pr_debug("X_prev=%u, X_now=%u, X_calc=%u, "
+                              "X_recv=%u\n", (unsigned)(old_x >> 6),
+                              (unsigned)(hctx->ccid3hctx_x >> 6),
+                              hctx->ccid3hctx_x_calc,
+                              (unsigned)(hctx->ccid3hctx_x_recv >> 6));
 
                ccid3_update_send_interval(hctx);
        }

And the same as above

net/dccp/ccids/ccid3.c static void ccid3_hc_rx_packet_recv(stru

Quoted 10 lines
net/dccp/ccids/ccid3.c +1 -2
@@ -899,7 +901,7 @@ static void ccid3_hc_rx_packet_recv(stru
                DCCP_BUG_ON(r_sample < 0);
                if (unlikely(r_sample <= t_elapsed))
                        DCCP_WARN("r_sample=%ldus, t_elapsed=%ldus\n",
-                                 r_sample, t_elapsed);
+                                 (long)r_sample, (long)t_elapsed);
                else
                        r_sample -= t_elapsed;
                CCID3_RTT_SANITY_CHECK(r_sample);
-

I can't comment on suseconds stuff as don't know so much...

Signature · 3 lines
Web: http://wand.net.nz/~iam4
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group
#2 lore raw
In reply to Gerrit Renker
Quoted 1 line · Ian McDonald

On 13/01/07, Gerrit Renker <[email protected]> wrote:

<SNIP>

Quoted 4 lines
Quoted 4 lines
net/dccp/ccids/ccid3.c +0 -0
@@ -899,7 +901,7 @@ static void ccid3_hc_rx_packet_recv(stru
                DCCP_BUG_ON(r_sample < 0);
                if (unlikely(r_sample <= t_elapsed))
                        DCCP_WARN("r_sample=%ldus, t_elapsed=%ldus\n",
Quoted 8 lines

net/dccp/ccids/ccid3.c static void ccid3_hc_rx_packet_recv(stru

Quoted 6 lines
net/dccp/ccids/ccid3.c +1 -2
-                                 r_sample, t_elapsed);
+                                 (long)r_sample, (long)t_elapsed);
                else
                        r_sample -= t_elapsed;
                CCID3_RTT_SANITY_CHECK(r_sample);
-

I can't comment on suseconds stuff as don't know so much...

Checked this last month, look at the URL to see the diff:

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;hba78b6cba14bd37fdb12c5367f1e4d58ff2e0f

commit 1fba78b6cba14bd37fdb12c5367f1e4d58ff2e0f

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Sun Dec 10 15:39:29 2006 -0200

[DCCP] ccid3: Fixup some type conversions related to rtts

Spotted by David Miller when compiling on sparc64, I reproduced it here on parisc64, that are the only platforms to define __kernel_suseconds_t as an 'int', all the others, x86_64 and x86 included typedef it as a
'long', but from
the definition of suseconds_t it should just be an 'int' on
platforms where it
is >= 32bits, it would not require all the castings from
suseconds_t to (int)
when printking variables of this type, that are not needed on parisc64 and sparc64.