netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] declance: Fix 64-bit compilation warnings
@ 2014-06-28 22:57 Maciej W. Rozycki
  2014-06-28 23:06 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2014-06-28 22:57 UTC (permalink / raw)
  To: netdev

This fixes compiler warnings:

drivers/net/ethernet/amd/declance.c: In function 'lance_init_ring':
drivers/net/ethernet/amd/declance.c:478: warning: format '%8.8x' expects type 'unsigned int', but argument 3 has type 'long unsigned int'
drivers/net/ethernet/amd/declance.c:487: warning: format '%8.8x' expects type 'unsigned int', but argument 3 has type 'long unsigned int'
drivers/net/ethernet/amd/declance.c:503: warning: cast from pointer to integer of different size
drivers/net/ethernet/amd/declance.c:520: warning: cast from pointer to integer of different size

in 64-bit compilation.  Where the value printed is an offset (whose range 
will always fit) the cast uses a 32-bit type, otherwise, where it is a 
host memory address, the `long' type is used and the width of the number 
printed adjusted according to the size of this type.

Tested with both 32-bit and 64-bit compilation, as well as at the run time 
(with the debug messages affected enabled).

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-declance-desc-printk.patch
Index: net-next-20140424-4maxp64/drivers/net/ethernet/amd/declance.c
===================================================================
--- net-next-20140424-4maxp64.orig/drivers/net/ethernet/amd/declance.c
+++ net-next-20140424-4maxp64/drivers/net/ethernet/amd/declance.c
@@ -475,7 +475,7 @@ static void lance_init_ring(struct net_d
 	*lib_ptr(ib, rx_ptr, lp->type) = leptr;
 	if (ZERO)
 		printk("RX ptr: %8.8x(%8.8x)\n",
-		       leptr, lib_off(brx_ring, lp->type));
+		       leptr, (uint)lib_off(brx_ring, lp->type));
 
 	/* Setup tx descriptor pointer */
 	leptr = offsetof(struct lance_init_block, btx_ring);
@@ -484,7 +484,7 @@ static void lance_init_ring(struct net_d
 	*lib_ptr(ib, tx_ptr, lp->type) = leptr;
 	if (ZERO)
 		printk("TX ptr: %8.8x(%8.8x)\n",
-		       leptr, lib_off(btx_ring, lp->type));
+		       leptr, (uint)lib_off(btx_ring, lp->type));
 
 	if (ZERO)
 		printk("TX rings:\n");
@@ -499,8 +499,9 @@ static void lance_init_ring(struct net_d
 						/* The ones required by tmd2 */
 		*lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
 		if (i < 3 && ZERO)
-			printk("%d: 0x%8.8x(0x%8.8x)\n",
-			       i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
+			printk("%d: 0x%8.8x(%#0*lx)\n",
+			       i, leptr, (int)sizeof(long),
+			       (long)lp->tx_buf_ptr_cpu[i]);
 	}
 
 	/* Setup the Rx ring entries */
@@ -516,8 +517,9 @@ static void lance_init_ring(struct net_d
 							     0xf000;
 		*lib_ptr(ib, brx_ring[i].mblength, lp->type) = 0;
 		if (i < 3 && ZERO)
-			printk("%d: 0x%8.8x(0x%8.8x)\n",
-			       i, leptr, (uint)lp->rx_buf_ptr_cpu[i]);
+			printk("%d: 0x%8.8x(%#0*lx)\n",
+			       i, leptr, (int)sizeof(long),
+			       (long)lp->rx_buf_ptr_cpu[i]);
 	}
 	iob();
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] declance: Fix 64-bit compilation warnings
  2014-06-28 22:57 [PATCH] declance: Fix 64-bit compilation warnings Maciej W. Rozycki
@ 2014-06-28 23:06 ` Joe Perches
  2014-06-29  1:30   ` Maciej W. Rozycki
  2014-06-30  9:44   ` David Laight
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2014-06-28 23:06 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: netdev

On Sat, 2014-06-28 at 23:57 +0100, Maciej W. Rozycki wrote:
> This fixes compiler warnings:
> 
> drivers/net/ethernet/amd/declance.c: In function 'lance_init_ring':
> drivers/net/ethernet/amd/declance.c:478: warning: format '%8.8x' expects type 'unsigned int', but argument 3 has type 'long unsigned int'
> drivers/net/ethernet/amd/declance.c:487: warning: format '%8.8x' expects type 'unsigned int', but argument 3 has type 'long unsigned int'
> drivers/net/ethernet/amd/declance.c:503: warning: cast from pointer to integer of different size
> drivers/net/ethernet/amd/declance.c:520: warning: cast from pointer to integer of different size
> 
> in 64-bit compilation.  Where the value printed is an offset (whose range 
> will always fit) the cast uses a 32-bit type, otherwise, where it is a 
> host memory address, the `long' type is used and the width of the number 
> printed adjusted according to the size of this type.
> 
> Tested with both 32-bit and 64-bit compilation, as well as at the run time 
> (with the debug messages affected enabled).
[]
> Index: net-next-20140424-4maxp64/drivers/net/ethernet/amd/declance.c
[]
> @@ -499,8 +499,9 @@ static void lance_init_ring(struct net_d
>  						/* The ones required by tmd2 */
>  		*lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
>  		if (i < 3 && ZERO)
> -			printk("%d: 0x%8.8x(0x%8.8x)\n",
> -			       i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
> +			printk("%d: 0x%8.8x(%#0*lx)\n",
> +			       i, leptr, (int)sizeof(long),
> +			       (long)lp->tx_buf_ptr_cpu[i]);

You need to adjust the "*" and sizeof(long) with +2 for the
0x prefix in the output length here.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] declance: Fix 64-bit compilation warnings
  2014-06-28 23:06 ` Joe Perches
@ 2014-06-29  1:30   ` Maciej W. Rozycki
  2014-06-30  9:44   ` David Laight
  1 sibling, 0 replies; 5+ messages in thread
From: Maciej W. Rozycki @ 2014-06-29  1:30 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev

On Sat, 28 Jun 2014, Joe Perches wrote:

> > @@ -499,8 +499,9 @@ static void lance_init_ring(struct net_d
> >  						/* The ones required by tmd2 */
> >  		*lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
> >  		if (i < 3 && ZERO)
> > -			printk("%d: 0x%8.8x(0x%8.8x)\n",
> > -			       i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
> > +			printk("%d: 0x%8.8x(%#0*lx)\n",
> > +			       i, leptr, (int)sizeof(long),
> > +			       (long)lp->tx_buf_ptr_cpu[i]);
> 
> You need to adjust the "*" and sizeof(long) with +2 for the
> 0x prefix in the output length here.

 Good catch, thanks!  MIPS kernel addresses always have their MSB set so 
this is hard to notice in testing.  But also the width has to be doubled 
first, to take two digits per byte into account too.  Sending an updated 
change right away, as soon as it builds and boots.

  Maciej

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] declance: Fix 64-bit compilation warnings
  2014-06-28 23:06 ` Joe Perches
  2014-06-29  1:30   ` Maciej W. Rozycki
@ 2014-06-30  9:44   ` David Laight
  2014-06-30  9:58     ` Maciej W. Rozycki
  1 sibling, 1 reply; 5+ messages in thread
From: David Laight @ 2014-06-30  9:44 UTC (permalink / raw)
  To: 'Joe Perches', Maciej W. Rozycki; +Cc: netdev@vger.kernel.org

From: Joe Perches
> On Sat, 2014-06-28 at 23:57 +0100, Maciej W. Rozycki wrote:
> > This fixes compiler warnings:
> >
> > drivers/net/ethernet/amd/declance.c: In function 'lance_init_ring':
> > drivers/net/ethernet/amd/declance.c:478: warning: format '%8.8x' expects type 'unsigned int', but
> argument 3 has type 'long unsigned int'
> > drivers/net/ethernet/amd/declance.c:487: warning: format '%8.8x' expects type 'unsigned int', but
> argument 3 has type 'long unsigned int'
> > drivers/net/ethernet/amd/declance.c:503: warning: cast from pointer to integer of different size
> > drivers/net/ethernet/amd/declance.c:520: warning: cast from pointer to integer of different size
> >
> > in 64-bit compilation.  Where the value printed is an offset (whose range
> > will always fit) the cast uses a 32-bit type, otherwise, where it is a
> > host memory address, the `long' type is used and the width of the number
> > printed adjusted according to the size of this type.
> >
> > Tested with both 32-bit and 64-bit compilation, as well as at the run time
> > (with the debug messages affected enabled).
> []
> > Index: net-next-20140424-4maxp64/drivers/net/ethernet/amd/declance.c
> []
> > @@ -499,8 +499,9 @@ static void lance_init_ring(struct net_d
> >  						/* The ones required by tmd2 */
> >  		*lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
> >  		if (i < 3 && ZERO)
> > -			printk("%d: 0x%8.8x(0x%8.8x)\n",
> > -			       i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
> > +			printk("%d: 0x%8.8x(%#0*lx)\n",
> > +			       i, leptr, (int)sizeof(long),
> > +			       (long)lp->tx_buf_ptr_cpu[i]);
> 
> You need to adjust the "*" and sizeof(long) with +2 for the
> 0x prefix in the output length here.

Do you need all the leading zeros at all?

	David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] declance: Fix 64-bit compilation warnings
  2014-06-30  9:44   ` David Laight
@ 2014-06-30  9:58     ` Maciej W. Rozycki
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej W. Rozycki @ 2014-06-30  9:58 UTC (permalink / raw)
  To: David Laight; +Cc: 'Joe Perches', netdev@vger.kernel.org

On Mon, 30 Jun 2014, David Laight wrote:

> > > @@ -499,8 +499,9 @@ static void lance_init_ring(struct net_d
> > >  						/* The ones required by tmd2 */
> > >  		*lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
> > >  		if (i < 3 && ZERO)
> > > -			printk("%d: 0x%8.8x(0x%8.8x)\n",
> > > -			       i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
> > > +			printk("%d: 0x%8.8x(%#0*lx)\n",
> > > +			       i, leptr, (int)sizeof(long),
> > > +			       (long)lp->tx_buf_ptr_cpu[i]);
> > 
> > You need to adjust the "*" and sizeof(long) with +2 for the
> > 0x prefix in the output length here.
> 
> Do you need all the leading zeros at all?

 For output alignment; plus the change is not intended to change 
semantics, but just to address the lack of 64-bit cleanliness.

  Maciej

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-30  9:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-28 22:57 [PATCH] declance: Fix 64-bit compilation warnings Maciej W. Rozycki
2014-06-28 23:06 ` Joe Perches
2014-06-29  1:30   ` Maciej W. Rozycki
2014-06-30  9:44   ` David Laight
2014-06-30  9:58     ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).