Skip to contentSkip to conversation

net: fec_mpc52xx: Fix resource size format

PATCH In review Rosen Penev 3 participants 6 messages May 18 – May 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Assisted-by Codex:GPT-5.5
Fixes 31b7720c8259 ("fec: Convert printks to netdev_<level>")
---
 drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
index 556f646073af..a770e7edb1dc 100644
@@ -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
#1 lore raw
Quoted 2 lines · Rosen Penev

resource_size() is printed after casting to unsigned long, but sizeof() returns size_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.

#2 lore raw
Quoted 6 lines · Joe Perches
Quoted 2 lines · Rosen Penev

resource_size() is printed after casting to unsigned long, but sizeof() returns size_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.c does 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 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.

Yeah I haven't had luck getting cleanups like this merged. Compilation fix has a higher chance of getting in.

maintainer
#3 lore raw
In reply to Rosen Penev
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 4 lines

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.

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.5
Fixes 31b7720c8259 ("fec: Convert printks to netdev_<level>")

Not a fix.

Quoted 18 lines
---
 drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
index 556f646073af..a770e7edb1dc 100644
@@ -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;
#4 lore raw
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() returns size_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.5
Fixes 31b7720c8259 ("fec: Convert printks to netdev_<level>")

Not a fix.

Quoted 18 lines
---
 drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
index 556f646073af..a770e7edb1dc 100644
@@ -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;
maintainer
#5 lore raw
Quoted 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.