netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
@ 2023-12-27 14:26 Zhu Yanjun
  2023-12-27 14:41 ` Zhu Yanjun
  2024-01-04  0:55 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: Zhu Yanjun @ 2023-12-27 14:26 UTC (permalink / raw)
  To: mst, jasowang, xuanzhuo, davem, edumazet, kuba, pabeni,
	virtualization, netdev
  Cc: Zhu Yanjun

From: Zhu Yanjun <yanjun.zhu@linux.dev>

Fix the warnings when building virtio_net driver.

"
drivers/net/virtio_net.c: In function ‘init_vqs’:
drivers/net/virtio_net.c:4551:48: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=]
 4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
      |                                                ^~
In function ‘virtnet_find_vqs’,
    inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
drivers/net/virtio_net.c:4551:41: note: directive argument in the range [-2147483643, 65534]
 4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
      |                                         ^~~~~~~~~~
drivers/net/virtio_net.c:4551:17: note: ‘sprintf’ output between 8 and 18 bytes into a destination of size 16
 4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/virtio_net.c: In function ‘init_vqs’:
drivers/net/virtio_net.c:4552:49: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=]
 4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
      |                                                 ^~
In function ‘virtnet_find_vqs’,
    inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
drivers/net/virtio_net.c:4552:41: note: directive argument in the range [-2147483643, 65534]
 4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
      |                                         ^~~~~~~~~~~
drivers/net/virtio_net.c:4552:17: note: ‘sprintf’ output between 9 and 19 bytes into a destination of size 16
 4552 |                 sprintf(vi->sq[i].name, "output.%d", i);

"

Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
 drivers/net/virtio_net.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d16f592c2061..89a15cc81396 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -4096,10 +4096,11 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
 {
 	vq_callback_t **callbacks;
 	struct virtqueue **vqs;
-	int ret = -ENOMEM;
-	int i, total_vqs;
 	const char **names;
+	int ret = -ENOMEM;
+	int total_vqs;
 	bool *ctx;
+	u16 i;
 
 	/* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by
 	 * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by
@@ -4136,8 +4137,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
 	for (i = 0; i < vi->max_queue_pairs; i++) {
 		callbacks[rxq2vq(i)] = skb_recv_done;
 		callbacks[txq2vq(i)] = skb_xmit_done;
-		sprintf(vi->rq[i].name, "input.%d", i);
-		sprintf(vi->sq[i].name, "output.%d", i);
+		sprintf(vi->rq[i].name, "input.%u", i);
+		sprintf(vi->sq[i].name, "output.%u", i);
 		names[rxq2vq(i)] = vi->rq[i].name;
 		names[txq2vq(i)] = vi->sq[i].name;
 		if (ctx)
-- 
2.27.0


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

* Re: [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
  2023-12-27 14:26 [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings Zhu Yanjun
@ 2023-12-27 14:41 ` Zhu Yanjun
  2023-12-28  1:26   ` Xuan Zhuo
  2024-01-04  0:55 ` Jakub Kicinski
  1 sibling, 1 reply; 5+ messages in thread
From: Zhu Yanjun @ 2023-12-27 14:41 UTC (permalink / raw)
  To: Zhu Yanjun, mst, jasowang, xuanzhuo, davem, edumazet, kuba,
	pabeni, virtualization, netdev


在 2023/12/27 22:26, Zhu Yanjun 写道:
> From: Zhu Yanjun <yanjun.zhu@linux.dev>
>
> Fix the warnings when building virtio_net driver.
>
> "
> drivers/net/virtio_net.c: In function ‘init_vqs’:
> drivers/net/virtio_net.c:4551:48: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=]
>   4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
>        |                                                ^~
> In function ‘virtnet_find_vqs’,
>      inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
> drivers/net/virtio_net.c:4551:41: note: directive argument in the range [-2147483643, 65534]
>   4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
>        |                                         ^~~~~~~~~~
> drivers/net/virtio_net.c:4551:17: note: ‘sprintf’ output between 8 and 18 bytes into a destination of size 16
>   4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
>        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/virtio_net.c: In function ‘init_vqs’:
> drivers/net/virtio_net.c:4552:49: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=]
>   4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
>        |                                                 ^~
> In function ‘virtnet_find_vqs’,
>      inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
> drivers/net/virtio_net.c:4552:41: note: directive argument in the range [-2147483643, 65534]
>   4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
>        |                                         ^~~~~~~~~~~
> drivers/net/virtio_net.c:4552:17: note: ‘sprintf’ output between 9 and 19 bytes into a destination of size 16
>   4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
>
> "

Hi, all

V1->V2: Add commit logs. Format string is changed.

Best Regards,

Zhu Yanjun

> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
> ---
>   drivers/net/virtio_net.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index d16f592c2061..89a15cc81396 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -4096,10 +4096,11 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
>   {
>   	vq_callback_t **callbacks;
>   	struct virtqueue **vqs;
> -	int ret = -ENOMEM;
> -	int i, total_vqs;
>   	const char **names;
> +	int ret = -ENOMEM;
> +	int total_vqs;
>   	bool *ctx;
> +	u16 i;
>   
>   	/* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by
>   	 * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by
> @@ -4136,8 +4137,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
>   	for (i = 0; i < vi->max_queue_pairs; i++) {
>   		callbacks[rxq2vq(i)] = skb_recv_done;
>   		callbacks[txq2vq(i)] = skb_xmit_done;
> -		sprintf(vi->rq[i].name, "input.%d", i);
> -		sprintf(vi->sq[i].name, "output.%d", i);
> +		sprintf(vi->rq[i].name, "input.%u", i);
> +		sprintf(vi->sq[i].name, "output.%u", i);
>   		names[rxq2vq(i)] = vi->rq[i].name;
>   		names[txq2vq(i)] = vi->sq[i].name;
>   		if (ctx)

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

* Re: [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
  2023-12-27 14:41 ` Zhu Yanjun
@ 2023-12-28  1:26   ` Xuan Zhuo
  0 siblings, 0 replies; 5+ messages in thread
From: Xuan Zhuo @ 2023-12-28  1:26 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: Zhu Yanjun, mst, jasowang, davem, edumazet, kuba, pabeni,
	virtualization, netdev

On Wed, 27 Dec 2023 22:41:07 +0800, Zhu Yanjun <yanjun.zhu@linux.dev> wrote:
>
> 在 2023/12/27 22:26, Zhu Yanjun 写道:
> > From: Zhu Yanjun <yanjun.zhu@linux.dev>
> >
> > Fix the warnings when building virtio_net driver.
> >
> > "
> > drivers/net/virtio_net.c: In function ‘init_vqs’:
> > drivers/net/virtio_net.c:4551:48: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=]
> >   4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
> >        |                                                ^~
> > In function ‘virtnet_find_vqs’,
> >      inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
> > drivers/net/virtio_net.c:4551:41: note: directive argument in the range [-2147483643, 65534]
> >   4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
> >        |                                         ^~~~~~~~~~
> > drivers/net/virtio_net.c:4551:17: note: ‘sprintf’ output between 8 and 18 bytes into a destination of size 16
> >   4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
> >        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/net/virtio_net.c: In function ‘init_vqs’:
> > drivers/net/virtio_net.c:4552:49: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=]
> >   4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
> >        |                                                 ^~
> > In function ‘virtnet_find_vqs’,
> >      inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
> > drivers/net/virtio_net.c:4552:41: note: directive argument in the range [-2147483643, 65534]
> >   4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
> >        |                                         ^~~~~~~~~~~
> > drivers/net/virtio_net.c:4552:17: note: ‘sprintf’ output between 9 and 19 bytes into a destination of size 16
> >   4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
> >
> > "
>
> Hi, all
>
> V1->V2: Add commit logs. Format string is changed.
>
> Best Regards,
>
> Zhu Yanjun
>
> > Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
> > ---

You can put the changes log after "---" inside the patch.

Thanks.

> >   drivers/net/virtio_net.c | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index d16f592c2061..89a15cc81396 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -4096,10 +4096,11 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
> >   {
> >   	vq_callback_t **callbacks;
> >   	struct virtqueue **vqs;
> > -	int ret = -ENOMEM;
> > -	int i, total_vqs;
> >   	const char **names;
> > +	int ret = -ENOMEM;
> > +	int total_vqs;
> >   	bool *ctx;
> > +	u16 i;
> >
> >   	/* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by
> >   	 * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by
> > @@ -4136,8 +4137,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
> >   	for (i = 0; i < vi->max_queue_pairs; i++) {
> >   		callbacks[rxq2vq(i)] = skb_recv_done;
> >   		callbacks[txq2vq(i)] = skb_xmit_done;
> > -		sprintf(vi->rq[i].name, "input.%d", i);
> > -		sprintf(vi->sq[i].name, "output.%d", i);
> > +		sprintf(vi->rq[i].name, "input.%u", i);
> > +		sprintf(vi->sq[i].name, "output.%u", i);
> >   		names[rxq2vq(i)] = vi->rq[i].name;
> >   		names[txq2vq(i)] = vi->sq[i].name;
> >   		if (ctx)

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

* Re: [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
  2023-12-27 14:26 [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings Zhu Yanjun
  2023-12-27 14:41 ` Zhu Yanjun
@ 2024-01-04  0:55 ` Jakub Kicinski
  2024-01-04  1:30   ` Zhu Yanjun
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2024-01-04  0:55 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: mst, jasowang, xuanzhuo, davem, edumazet, pabeni, virtualization,
	netdev, Zhu Yanjun

On Wed, 27 Dec 2023 22:26:37 +0800 Zhu Yanjun wrote:
> From: Zhu Yanjun <yanjun.zhu@linux.dev>
> 
> Fix the warnings when building virtio_net driver.

This got marked as Not Applicable in patchwork, not sure why.
Could you repost?

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

* Re: [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
  2024-01-04  0:55 ` Jakub Kicinski
@ 2024-01-04  1:30   ` Zhu Yanjun
  0 siblings, 0 replies; 5+ messages in thread
From: Zhu Yanjun @ 2024-01-04  1:30 UTC (permalink / raw)
  To: Jakub Kicinski, Zhu Yanjun
  Cc: mst, jasowang, xuanzhuo, davem, edumazet, pabeni, virtualization,
	netdev


在 2024/1/4 8:55, Jakub Kicinski 写道:
> On Wed, 27 Dec 2023 22:26:37 +0800 Zhu Yanjun wrote:
>> From: Zhu Yanjun <yanjun.zhu@linux.dev>
>>
>> Fix the warnings when building virtio_net driver.
> This got marked as Not Applicable in patchwork, not sure why.
> Could you repost?

Got it. I will resend this commit very soon.

Best Regards,

Zhu Yanjun


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

end of thread, other threads:[~2024-01-04  1:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27 14:26 [PATCH v2 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings Zhu Yanjun
2023-12-27 14:41 ` Zhu Yanjun
2023-12-28  1:26   ` Xuan Zhuo
2024-01-04  0:55 ` Jakub Kicinski
2024-01-04  1:30   ` Zhu Yanjun

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).