Skip to content

Commit e3fe8d2

Browse files
zhuyjkuba-moo
authored andcommitted
virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
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> Link: https://lore.kernel.org/r/20240104020902.2753599-1-yanjun.zhu@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a0cb76a commit e3fe8d2

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/net/virtio_net.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,10 +4295,11 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
42954295
{
42964296
vq_callback_t **callbacks;
42974297
struct virtqueue **vqs;
4298-
int ret = -ENOMEM;
4299-
int i, total_vqs;
43004298
const char **names;
4299+
int ret = -ENOMEM;
4300+
int total_vqs;
43014301
bool *ctx;
4302+
u16 i;
43024303

43034304
/* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by
43044305
* possible N-1 RX/TX queue pairs used in multiqueue mode, followed by
@@ -4335,8 +4336,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
43354336
for (i = 0; i < vi->max_queue_pairs; i++) {
43364337
callbacks[rxq2vq(i)] = skb_recv_done;
43374338
callbacks[txq2vq(i)] = skb_xmit_done;
4338-
sprintf(vi->rq[i].name, "input.%d", i);
4339-
sprintf(vi->sq[i].name, "output.%d", i);
4339+
sprintf(vi->rq[i].name, "input.%u", i);
4340+
sprintf(vi->sq[i].name, "output.%u", i);
43404341
names[rxq2vq(i)] = vi->rq[i].name;
43414342
names[txq2vq(i)] = vi->sq[i].name;
43424343
if (ctx)

0 commit comments

Comments
 (0)