* [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
@ 2007-10-18 22:15 Emil Medve
2007-10-19 0:30 ` David Miller
2007-10-19 14:35 ` Timur Tabi
0 siblings, 2 replies; 8+ messages in thread
From: Emil Medve @ 2007-10-18 22:15 UTC (permalink / raw)
To: jgarzik, leoli, netdev, linuxppc-dev
drivers/net/ucc_geth.c: In function 'ucc_geth_startup':
drivers/net/ucc_geth.c:2614: warning: assignment makes integer from pointer without a cast
drivers/net/ucc_geth.c:2651: warning: assignment makes integer from pointer without a cast
Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
---
This patch is against Jeff's tree: d85714d81cc0408daddb68c10f7fd69eafe7c213
netdev-2.6> scripts/checkpatch.pl 0001-POWERPC-ucc_geth-Eliminate-compile-warnings.patch
Your patch has no obvious style problems and is ready for submission.
drivers/net/ucc_geth.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index bec413b..d427da8 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -2611,7 +2611,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4)
align = UCC_GETH_TX_BD_RING_ALIGNMENT;
ugeth->tx_bd_ring_offset[j] =
- kmalloc((u32) (length + align), GFP_KERNEL);
+ (u32)kmalloc(length + align, GFP_KERNEL);
if (ugeth->tx_bd_ring_offset[j] != 0)
ugeth->p_tx_bd_ring[j] =
@@ -2648,7 +2648,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
align = UCC_GETH_RX_BD_RING_ALIGNMENT;
ugeth->rx_bd_ring_offset[j] =
- kmalloc((u32) (length + align), GFP_KERNEL);
+ (u32)kmalloc(length + align, GFP_KERNEL);
if (ugeth->rx_bd_ring_offset[j] != 0)
ugeth->p_rx_bd_ring[j] =
(void*)((ugeth->rx_bd_ring_offset[j] +
--
1.5.3.GIT
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-18 22:15 [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings Emil Medve
@ 2007-10-19 0:30 ` David Miller
2007-10-19 13:39 ` Medve Emilian-EMMEDVE1
2007-10-19 14:35 ` Timur Tabi
1 sibling, 1 reply; 8+ messages in thread
From: David Miller @ 2007-10-19 0:30 UTC (permalink / raw)
To: Emilian.Medve; +Cc: netdev, leoli, jgarzik, linuxppc-dev
From: Emil Medve <Emilian.Medve@freescale.com>
Date: Thu, 18 Oct 2007 17:15:13 -0500
> drivers/net/ucc_geth.c: In function 'ucc_geth_startup':
> drivers/net/ucc_geth.c:2614: warning: assignment makes integer from pointer without a cast
> drivers/net/ucc_geth.c:2651: warning: assignment makes integer from pointer without a cast
>
> Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
It only kills the warning on 32-bit systems, the cast is wrong
either way.
> ugeth->tx_bd_ring_offset[j] =
> - kmalloc((u32) (length + align), GFP_KERNEL);
> + (u32)kmalloc(length + align, GFP_KERNEL);
>
> if (ugeth->tx_bd_ring_offset[j] != 0)
> ugeth->p_tx_bd_ring[j] =
Pointers can be up to "unsigned long" in size, therefore that
is the minimal amount of storage you need to store them into
if they are needed in integer form for some reason.
Any cast from pointer to integer like this is a huge red flag.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-19 0:30 ` David Miller
@ 2007-10-19 13:39 ` Medve Emilian-EMMEDVE1
2007-10-19 23:41 ` David Miller
0 siblings, 1 reply; 8+ messages in thread
From: Medve Emilian-EMMEDVE1 @ 2007-10-19 13:39 UTC (permalink / raw)
To: David Miller; +Cc: netdev, jgarzik, linuxppc-dev
Hello David
> It only kills the warning on 32-bit systems, the cast is wrong
> either way.
I'm not aware of the QE being present on any 64-bit PowerPC. However,
porting the entire driver to a 64-bit platform is an exercise in itself
as many other things would need tweaking the QE hardware itself. But
that's an orthogonal issue. For now I just want to fix that warning.
>=20
> > ugeth->tx_bd_ring_offset[j] =3D
> > - kmalloc((u32) (length + align),=20
> GFP_KERNEL);
> > + (u32)kmalloc(length + align,=20
> GFP_KERNEL);
> > =20
> > if (ugeth->tx_bd_ring_offset[j] !=3D 0)
> > ugeth->p_tx_bd_ring[j] =3D
>=20
> Pointers can be up to "unsigned long" in size, therefore that
> is the minimal amount of storage you need to store them into
> if they are needed in integer form for some reason.
>=20
> Any cast from pointer to integer like this is a huge red flag.
Agreed, but again, I'm not trying to fix the entire driver or to port it
to a different architecture.
For the current situation, 32-bit QE, 32-bit PowerPC, do you find the
patch acceptable?
Cheers,
Emil.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-19 13:39 ` Medve Emilian-EMMEDVE1
@ 2007-10-19 23:41 ` David Miller
2007-10-22 13:47 ` Medve Emilian-EMMEDVE1
0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2007-10-19 23:41 UTC (permalink / raw)
To: Emilian.Medve; +Cc: netdev, jgarzik, linuxppc-dev
From: "Medve Emilian-EMMEDVE1" <Emilian.Medve@freescale.com>
Date: Fri, 19 Oct 2007 06:39:12 -0700
> For the current situation, 32-bit QE, 32-bit PowerPC, do you find
> the patch acceptable?
No piece of code in the kernel should live in a vacuum.
In order to improve overall code quality, every piece of
driver code should avoid assuming things about pointer
sizes and things of this nature.
Then the driver can get enabled into the build on every
platform, and therefore nobody will break the build of
this driver again since it will get hit by "allmodconfig"
et al. builds even on platforms other than the one it is
meant for.
This hack fix is not acceptable, really.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-19 23:41 ` David Miller
@ 2007-10-22 13:47 ` Medve Emilian-EMMEDVE1
2007-10-23 3:38 ` Li Yang-r58472
2007-10-23 17:10 ` Scott Wood
0 siblings, 2 replies; 8+ messages in thread
From: Medve Emilian-EMMEDVE1 @ 2007-10-22 13:47 UTC (permalink / raw)
To: David Miller; +Cc: netdev, jgarzik, linuxppc-dev
Hello David,
> No piece of code in the kernel should live in a vacuum.
>=20
> In order to improve overall code quality, every piece of
> driver code should avoid assuming things about pointer
> sizes and things of this nature.
I'm afraid we might be talking about orthogonal issues here. I actively
agree that all code (not only kernel) should be written up to the
coding/quality standards you mention above, but I see a difference
between fixing a warning and making a driver portable (to 64-bit
PowerPCs, to other platforms, etc.). If there is a kernel todo list
somewhere lets add to it the task to make the ucc_geth more portable.
> Then the driver can get enabled into the build on every
> platform, and therefore nobody will break the build of
> this driver again since it will get hit by "allmodconfig"
> et al. builds even on platforms other than the one it is
> meant for.
>=20
> This hack fix is not acceptable, really.
Are you suggesting we leave those warnings there until somebody decides
to fix all the portability issues of this driver? My patch is a small
and insignificant improvement and not the revolution you're asking for,
but is an small improvement today (I dislike warnings) vs. an improbable
big one in the future.
Leo, as author and maintainer of this driver, what's your take on this?
Cheers,
Emil.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-22 13:47 ` Medve Emilian-EMMEDVE1
@ 2007-10-23 3:38 ` Li Yang-r58472
2007-10-23 17:10 ` Scott Wood
1 sibling, 0 replies; 8+ messages in thread
From: Li Yang-r58472 @ 2007-10-23 3:38 UTC (permalink / raw)
To: Medve Emilian-EMMEDVE1, David Miller; +Cc: netdev, jgarzik, linuxppc-dev
> -----Original Message-----
> From: Medve Emilian-EMMEDVE1=20
> Sent: Monday, October 22, 2007 9:48 PM
> To: David Miller
> Cc: jgarzik@pobox.com; Li Yang-r58472;=20
> netdev@vger.kernel.org; linuxppc-dev@ozlabs.org
> Subject: RE: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
>=20
> Hello David,
>=20
>=20
> > No piece of code in the kernel should live in a vacuum.
> >=20
> > In order to improve overall code quality, every piece of=20
> driver code=20
> > should avoid assuming things about pointer sizes and things of this=20
> > nature.
>=20
> I'm afraid we might be talking about orthogonal issues here.=20
> I actively agree that all code (not only kernel) should be=20
> written up to the coding/quality standards you mention above,=20
> but I see a difference between fixing a warning and making a=20
> driver portable (to 64-bit PowerPCs, to other platforms,=20
> etc.). If there is a kernel todo list somewhere lets add to=20
> it the task to make the ucc_geth more portable.
>=20
> > Then the driver can get enabled into the build on every=20
> platform, and=20
> > therefore nobody will break the build of this driver again since it=20
> > will get hit by "allmodconfig"
> > et al. builds even on platforms other than the one it is meant for.
> >=20
> > This hack fix is not acceptable, really.
>=20
> Are you suggesting we leave those warnings there until=20
> somebody decides to fix all the portability issues of this=20
> driver? My patch is a small and insignificant improvement and=20
> not the revolution you're asking for, but is an small=20
> improvement today (I dislike warnings) vs. an improbable big=20
> one in the future.
I'd say we can not use our way of doing things while working with the
community. The community has to consider the kernel as a whole and thus
has its own virtue. The warning has been there for some time. It stays
as an indicator that we have something to do to improve the portability.
I will work on a patch to fix this portability issue.
- Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-22 13:47 ` Medve Emilian-EMMEDVE1
2007-10-23 3:38 ` Li Yang-r58472
@ 2007-10-23 17:10 ` Scott Wood
1 sibling, 0 replies; 8+ messages in thread
From: Scott Wood @ 2007-10-23 17:10 UTC (permalink / raw)
To: Medve Emilian-EMMEDVE1; +Cc: netdev, jgarzik, David Miller, linuxppc-dev
On Mon, Oct 22, 2007 at 06:47:32AM -0700, Medve Emilian-EMMEDVE1 wrote:
> Are you suggesting we leave those warnings there until somebody decides
> to fix all the portability issues of this driver? My patch is a small
> and insignificant improvement and not the revolution you're asking for,
> but is an small improvement today (I dislike warnings) vs. an improbable
> big one in the future.
It is not an improvement, as it moves the driver further away from being
64-bit clean. A better fix would be to change the definition of
tx/rx_bd_ring_offset to unsigned long (or better yet, a union).
-Scott
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
2007-10-18 22:15 [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings Emil Medve
2007-10-19 0:30 ` David Miller
@ 2007-10-19 14:35 ` Timur Tabi
1 sibling, 0 replies; 8+ messages in thread
From: Timur Tabi @ 2007-10-19 14:35 UTC (permalink / raw)
To: Emil Medve; +Cc: netdev, leoli, jgarzik, linuxppc-dev
Emil Medve wrote:
> drivers/net/ucc_geth.c: In function 'ucc_geth_startup':
> drivers/net/ucc_geth.c:2614: warning: assignment makes integer from pointer without a cast
> drivers/net/ucc_geth.c:2651: warning: assignment makes integer from pointer without a cast
>
> Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Acked-by: Timur Tabi <timur@freescale.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-10-23 17:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-18 22:15 [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings Emil Medve
2007-10-19 0:30 ` David Miller
2007-10-19 13:39 ` Medve Emilian-EMMEDVE1
2007-10-19 23:41 ` David Miller
2007-10-22 13:47 ` Medve Emilian-EMMEDVE1
2007-10-23 3:38 ` Li Yang-r58472
2007-10-23 17:10 ` Scott Wood
2007-10-19 14:35 ` Timur Tabi
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).