net: fec_mpc52xx: Fix resource size format
Subsystems (2)
PATCH 1/1 net: fec_mpc52xx: Fix resource size format
resource_size() is printed after casting to unsigned long, but sizeof() returns size_t.
Use %zx for the sizeof() value so the format string matches the argument type so that 64-bit builds compile.
--- drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
@@ -834,7 +834,7 @@ static int mpc52xx_fec_probe(struct platform_device *op) goto err_netdev; }if (resource_size (&mem) <sizeof (struct mpc52xx_fec )) { -pr_err ("invalid resource size (%lx < %x), check mpc52xx_devices.c\n" , +pr_err ("invalid resource size (%lx < %zx), check mpc52xx_devices.c\n" , (unsigned long )resource_size (&mem),sizeof (struct mpc52xx_fec )); rv = -EINVAL ;
Signature · 1 line
2.54.0
Quoted 2 lines · Rosen Penev
resource_size()is printed after casting to unsigned long, butsizeof()returnssize_t.
trivia and I wonder if this code path is even possible
drivers/net/ethernet/freescale/fec_mpc52xx.c
Quoted 1 line
drivers/net/ethernet/freescale/fec_mpc52xx.c +0
-0
[]
drivers/net/ethernet/freescale/fec_mpc52xx.c static int mpc52xx_fec_probe(struct platform_device *op) · line 839
Quoted 8 lines
drivers/net/ethernet/freescale/fec_mpc52xx.c +1
-1@@ -834,7 +834,7 @@ static int mpc52xx_fec_probe(struct platform_device *op) goto err_netdev; }if (resource_size (&mem) <sizeof (struct mpc52xx_fec )) { -pr_err ("invalid resource size (%lx < %x), check mpc52xx_devices.c\n" , +pr_err ("invalid resource size (%lx < %zx), check mpc52xx_devices.c\n" , (unsigned long )resource_size (&mem),sizeof (struct mpc52xx_fec ));
mpc52xx_devices.c does not exist.
It was deleted nearly 20 years ago by:
commit 917f0af9e5a9ceecf9e72537fabb501254ba321d
Author: Paul Mackerras <[email protected]> Date: Mon Jun 9 14:01:46 2008 +1000
and
It's possible to remove the cast to unsigned long and use %pa and %zx could be %#zx to match output prefixes.
Quoted 6 lines · Joe Perches
Quoted 2 lines · Rosen Penev
resource_size()is printed after casting to unsigned long, butsizeof()returnssize_t.trivia and I wonder if this code path is even possible
Not sure what you mean. probe has a corresponding of_match_table in the platform_driver struct.
Quoted 13 lines
drivers/net/ethernet/freescale/fec_mpc52xx.c
Quoted 2 lines
drivers/net/ethernet/freescale/fec_mpc52xx.c +0
-0[]
drivers/net/ethernet/freescale/fec_mpc52xx.c static int mpc52xx_fec_probe(struct platform_device *op) · line 839
Quoted 8 lines
drivers/net/ethernet/freescale/fec_mpc52xx.c +1
-1@@ -834,7 +834,7 @@ static int mpc52xx_fec_probe(struct platform_device *op) goto err_netdev; }if (resource_size (&mem) <sizeof (struct mpc52xx_fec )) { -pr_err ("invalid resource size (%lx < %x), check mpc52xx_devices.c\n" , +pr_err ("invalid resource size (%lx < %zx), check mpc52xx_devices.c\n" , (unsigned long )resource_size (&mem),sizeof (struct mpc52xx_fec ));
mpc52xx_devices.cdoes not exist.
right. the message is wrong. this is only meant to be a compilation fix.
Quoted 10 lines
It was deleted nearly 20 years ago by:
commit
917f0af9e5a9ceecf9e72537fabb501254ba321dAuthor: Paul Mackerras <[email protected]> Date: Mon Jun 9 14:01:46 2008 +1000and
It's possible to remove the cast to unsigned long and use %pa and %zx could be %#zx to match output prefixes.
Yeah I haven't had luck getting cleanups like this merged. Compilation fix has a higher chance of getting in.
Jakub Kicinski
maintainerQuoted 1 line · On Sun, 17 May 2026 21:40:47 -0700 Rosen Penev wrote:
resource_size()is printed after casting to unsigned long,
This portion is confusing and irrelevant, you're touching the second arg.
Quoted 4 lines
but
sizeof()returnssize_t.Use %zx for the
sizeof()value so the format string matches the argument type so that 64-bit builds compile.
Not on 64-bit x86 builds apparently. Please provide more details on which platform and compiler you see a warning and the warning.
Quoted 2 lines
Assisted-by Codex:GPT-5.5Fixes 31b7720c8259 ("fec: Convert printks to netdev_<level>")
Not a fix.
Quoted 18 lines
Signed-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_mpc52xx.c +1
-1@@ -834,7 +834,7 @@ static int mpc52xx_fec_probe(struct platform_device *op) goto err_netdev; }if (resource_size (&mem) <sizeof (struct mpc52xx_fec )) { -pr_err ("invalid resource size (%lx < %x), check mpc52xx_devices.c\n" , +pr_err ("invalid resource size (%lx < %zx), check mpc52xx_devices.c\n" , (unsigned long )resource_size (&mem),sizeof (struct mpc52xx_fec )); rv = -EINVAL ;
Quoted 7 lines · Jakub Kicinski
Quoted 1 line · On Sun, 17 May 2026 21:40:47 -0700 Rosen Penev wrote:
resource_size()is printed after casting to unsigned long,This portion is confusing and irrelevant, you're touching the second arg.
Quoted 7 lines
Quoted 4 lines
but
sizeof()returnssize_t.Use %zx for the
sizeof()value so the format string matches the argument type so that 64-bit builds compile.Not on 64-bit x86 builds apparently. Please provide more details on which platform and compiler you see a warning and the warning.
64-bit powerpc. How would this driver be built on x86? There are a lot of PPC APIs used here.
drivers/net/ethernet/freescale/fec_mpc52xx.c:46:10: fatal error:
'asm/mpc52xx.h' file not found
46 | #include <asm/mpc52xx.h>
| ^~~~~~~~~~~~~~~
Quoted 25 lines
Quoted 3 lines
Assisted-by Codex:GPT-5.5Fixes 31b7720c8259 ("fec: Convert printks to netdev_<level>")Not a fix.
Quoted 18 lines
Signed-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_mpc52xx.c +1
-1@@ -834,7 +834,7 @@ static int mpc52xx_fec_probe(struct platform_device *op) goto err_netdev; }if (resource_size (&mem) <sizeof (struct mpc52xx_fec )) { -pr_err ("invalid resource size (%lx < %x), check mpc52xx_devices.c\n" , +pr_err ("invalid resource size (%lx < %zx), check mpc52xx_devices.c\n" , (unsigned long )resource_size (&mem),sizeof (struct mpc52xx_fec )); rv = -EINVAL ;
Jakub Kicinski
maintainerQuoted 3 lines · On Wed, 20 May 2026 17:42:37 -0700 Rosen Penev wrote:
Quoted 2 lines
Not on 64-bit x86 builds apparently. Please provide more details on which platform and compiler you see a warning and the warning.
64-bit powerpc. How would this driver be built on x86?
Hm, CI did rebuild a bunch of fec objects when this patch was applied. But looking closer indeed not this exact file.