[PATCH] samples: rpmsg: Fix mtu printk specifiers

Nathan Chancellor posted 1 patch 2 weeks, 2 days ago
samples/rpmsg/rpmsg_client_sample.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] samples: rpmsg: Fix mtu printk specifiers
Posted by Nathan Chancellor 2 weeks, 2 days ago
When building rpmsg_client_sample.c for a 32-bit platform, such as
during arm allmodconfig, there are a few warnings due to using an
incorrect specifier for mtu:

  samples/rpmsg/rpmsg_client_sample.c:68:59: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
     68 |                 dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %ld\n", mtu);
        |                                                                 ~~~     ^~~
        |                                                                 %zd
  ...
  samples/rpmsg/rpmsg_client_sample.c:72:50: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
     72 |         dev_info(&rpdev->dev, "rpmsg MTU size = %ld\n", mtu);
        |                                                 ~~~     ^~~
        |                                                 %zd
  ...
  samples/rpmsg/rpmsg_client_sample.c:79:17: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
     78 |                         "message size %zu exceeds rpmsg MTU size %ld\n",
        |                                                                  ~~~
        |                                                                  %zd
     79 |                         strlen(MSG), mtu);
        |                                      ^~~

Use '%zd', the proper specifier for a 'ssize_t' variable, to clear up
the warning. Additionally, modify the last dev_err() call in
rpmsg_sample_probe() to reuse msg_len instead of calling strlen(MSG)
again and use '%zd' throughout the string consistently.

Fixes: 1029c89bafc7 ("samples: rpmsg: Add MTU size info")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 samples/rpmsg/rpmsg_client_sample.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c
index 4c43436aadb6..8c629065c64c 100644
--- a/samples/rpmsg/rpmsg_client_sample.c
+++ b/samples/rpmsg/rpmsg_client_sample.c
@@ -65,18 +65,18 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
 
 	mtu = rpmsg_get_mtu(rpdev->ept);
 	if (mtu < 0) {
-		dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %ld\n", mtu);
+		dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %zd\n", mtu);
 		return mtu;
 	}
 
-	dev_info(&rpdev->dev, "rpmsg MTU size = %ld\n", mtu);
+	dev_info(&rpdev->dev, "rpmsg MTU size = %zd\n", mtu);
 
 	msg_len = strlen(MSG);
 	/* make sure our message fits in a single rpmsg buffer */
 	if (msg_len > mtu) {
 		dev_err(&rpdev->dev,
-			"message size %zu exceeds rpmsg MTU size %ld\n",
-			strlen(MSG), mtu);
+			"message size %zd exceeds rpmsg MTU size %zd\n",
+			msg_len, mtu);
 		return -EMSGSIZE;
 	}
 

---
base-commit: 70e14d5db3a01a44f6c3217bb3dda2dd5828a507
change-id: 20260908-samples-rpmsg-fix-mtu-print-1903f03216ef

Best regards,
--  
Cheers,
Nathan
Re: [PATCH] samples: rpmsg: Fix mtu printk specifiers
Posted by Mathieu Poirier 2 weeks, 2 days ago
On Tue, 8 Sept 2026 at 16:10, Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building rpmsg_client_sample.c for a 32-bit platform, such as
> during arm allmodconfig, there are a few warnings due to using an
> incorrect specifier for mtu:
>
>   samples/rpmsg/rpmsg_client_sample.c:68:59: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
>      68 |                 dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %ld\n", mtu);
>         |                                                                 ~~~     ^~~
>         |                                                                 %zd
>   ...
>   samples/rpmsg/rpmsg_client_sample.c:72:50: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
>      72 |         dev_info(&rpdev->dev, "rpmsg MTU size = %ld\n", mtu);
>         |                                                 ~~~     ^~~
>         |                                                 %zd
>   ...
>   samples/rpmsg/rpmsg_client_sample.c:79:17: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
>      78 |                         "message size %zu exceeds rpmsg MTU size %ld\n",
>         |                                                                  ~~~
>         |                                                                  %zd
>      79 |                         strlen(MSG), mtu);
>         |                                      ^~~
>
> Use '%zd', the proper specifier for a 'ssize_t' variable, to clear up
> the warning. Additionally, modify the last dev_err() call in
> rpmsg_sample_probe() to reuse msg_len instead of calling strlen(MSG)
> again and use '%zd' throughout the string consistently.
>
> Fixes: 1029c89bafc7 ("samples: rpmsg: Add MTU size info")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  samples/rpmsg/rpmsg_client_sample.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>

Applied.

Thanks,
Mathieu

> diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c
> index 4c43436aadb6..8c629065c64c 100644
> --- a/samples/rpmsg/rpmsg_client_sample.c
> +++ b/samples/rpmsg/rpmsg_client_sample.c
> @@ -65,18 +65,18 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
>
>         mtu = rpmsg_get_mtu(rpdev->ept);
>         if (mtu < 0) {
> -               dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %ld\n", mtu);
> +               dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %zd\n", mtu);
>                 return mtu;
>         }
>
> -       dev_info(&rpdev->dev, "rpmsg MTU size = %ld\n", mtu);
> +       dev_info(&rpdev->dev, "rpmsg MTU size = %zd\n", mtu);
>
>         msg_len = strlen(MSG);
>         /* make sure our message fits in a single rpmsg buffer */
>         if (msg_len > mtu) {
>                 dev_err(&rpdev->dev,
> -                       "message size %zu exceeds rpmsg MTU size %ld\n",
> -                       strlen(MSG), mtu);
> +                       "message size %zd exceeds rpmsg MTU size %zd\n",
> +                       msg_len, mtu);
>                 return -EMSGSIZE;
>         }
>
>
> ---
> base-commit: 70e14d5db3a01a44f6c3217bb3dda2dd5828a507
> change-id: 20260908-samples-rpmsg-fix-mtu-print-1903f03216ef
>
> Best regards,
> --
> Cheers,
> Nathan
>