* [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings @ 2023-12-26 11:45 Zhu Yanjun 2023-12-26 11:53 ` Zhu Yanjun 0 siblings, 1 reply; 5+ messages in thread From: Zhu Yanjun @ 2023-12-26 11:45 UTC (permalink / raw) To: mst, jasowang, xuanzhuo, davem, edumazet, kuba, pabeni, virtualization, netdev Cc: Zhu Yanjun From: Zhu Yanjun <yanjun.zhu@linux.dev> Fix a warning when building virtio_net driver. Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev> --- drivers/net/virtio_net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 49625638ad43..cf57eddf768a 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -4508,10 +4508,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 -- 2.41.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings 2023-12-26 11:45 [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings Zhu Yanjun @ 2023-12-26 11:53 ` Zhu Yanjun 2023-12-26 12:43 ` Xuan Zhuo 2023-12-26 18:01 ` Stephen Hemminger 0 siblings, 2 replies; 5+ messages in thread From: Zhu Yanjun @ 2023-12-26 11:53 UTC (permalink / raw) To: Zhu Yanjun, mst, jasowang, xuanzhuo, davem, edumazet, kuba, pabeni, virtualization, netdev The warnings are as below: " 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); " Please review. Best Regards, Zhu Yanjun 在 2023/12/26 19:45, Zhu Yanjun 写道: > From: Zhu Yanjun <yanjun.zhu@linux.dev> > > Fix a warning when building virtio_net driver. > > Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev> > --- > drivers/net/virtio_net.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 49625638ad43..cf57eddf768a 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -4508,10 +4508,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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings 2023-12-26 11:53 ` Zhu Yanjun @ 2023-12-26 12:43 ` Xuan Zhuo 2023-12-26 18:01 ` Stephen Hemminger 1 sibling, 0 replies; 5+ messages in thread From: Xuan Zhuo @ 2023-12-26 12:43 UTC (permalink / raw) To: Zhu Yanjun Cc: Zhu Yanjun, mst, jasowang, davem, edumazet, kuba, pabeni, virtualization, netdev On Tue, 26 Dec 2023 19:53:58 +0800, Zhu Yanjun <yanjun.zhu@linux.dev> wrote: > The warnings are as below: > > " > > 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); > > " > > Please review. Please put this to the git msg. Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Thanks. > > Best Regards, > > Zhu Yanjun > > 在 2023/12/26 19:45, Zhu Yanjun 写道: > > From: Zhu Yanjun <yanjun.zhu@linux.dev> > > > > Fix a warning when building virtio_net driver. > > > > Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev> > > --- > > drivers/net/virtio_net.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 49625638ad43..cf57eddf768a 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -4508,10 +4508,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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings 2023-12-26 11:53 ` Zhu Yanjun 2023-12-26 12:43 ` Xuan Zhuo @ 2023-12-26 18:01 ` Stephen Hemminger 2023-12-26 18:11 ` Michael S. Tsirkin 1 sibling, 1 reply; 5+ messages in thread From: Stephen Hemminger @ 2023-12-26 18:01 UTC (permalink / raw) To: Zhu Yanjun Cc: Zhu Yanjun, mst, jasowang, xuanzhuo, davem, edumazet, kuba, pabeni, virtualization, netdev On Tue, 26 Dec 2023 19:53:58 +0800 Zhu Yanjun <yanjun.zhu@linux.dev> wrote: > The warnings are as below: > > " > > 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); > > " > > Please review. > > Best Regards, > > Zhu Yanjun > > 在 2023/12/26 19:45, Zhu Yanjun 写道: > > From: Zhu Yanjun <yanjun.zhu@linux.dev> > > > > Fix a warning when building virtio_net driver. > > > > Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev> > > --- > > drivers/net/virtio_net.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 49625638ad43..cf57eddf768a 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -4508,10 +4508,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 > If you change the variable type to u16, then the format string should no longer use %d. Instead should be %u ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings 2023-12-26 18:01 ` Stephen Hemminger @ 2023-12-26 18:11 ` Michael S. Tsirkin 0 siblings, 0 replies; 5+ messages in thread From: Michael S. Tsirkin @ 2023-12-26 18:11 UTC (permalink / raw) To: Stephen Hemminger Cc: Zhu Yanjun, Zhu Yanjun, jasowang, xuanzhuo, davem, edumazet, kuba, pabeni, virtualization, netdev On Tue, Dec 26, 2023 at 10:01:13AM -0800, Stephen Hemminger wrote: > On Tue, 26 Dec 2023 19:53:58 +0800 > Zhu Yanjun <yanjun.zhu@linux.dev> wrote: > > > The warnings are as below: > > > > " > > > > 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); > > > > " > > > > Please review. > > > > Best Regards, > > > > Zhu Yanjun > > > > 在 2023/12/26 19:45, Zhu Yanjun 写道: > > > From: Zhu Yanjun <yanjun.zhu@linux.dev> > > > > > > Fix a warning when building virtio_net driver. > > > > > > Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev> > > > --- > > > drivers/net/virtio_net.c | 5 +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > > index 49625638ad43..cf57eddf768a 100644 > > > --- a/drivers/net/virtio_net.c > > > +++ b/drivers/net/virtio_net.c > > > @@ -4508,10 +4508,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 > > > > If you change the variable type to u16, then the format string should no > longer use %d. Instead should be %u I would just use unsigned FWIW. But it doesn't matter the range is limited here. It's just that the compiler can't figure it out. -- MST ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-26 18:11 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-12-26 11:45 [PATCH 1/1] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings Zhu Yanjun 2023-12-26 11:53 ` Zhu Yanjun 2023-12-26 12:43 ` Xuan Zhuo 2023-12-26 18:01 ` Stephen Hemminger 2023-12-26 18:11 ` Michael S. Tsirkin
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).