DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: Amit Prakash Shukla <amitprakashs@marvell.com>,
	Chenbo Xia <chenbo.xia@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	"stable@dpdk.org" <stable@dpdk.org>,
	"Ruifeng.Wang@arm.com" <Ruifeng.Wang@arm.com>
Subject: Re: [PATCH v3] vhost: compilation fix for GCC-12
Date: Thu, 6 Oct 2022 09:24:35 +0200	[thread overview]
Message-ID: <5fe93e73-a88a-88b6-e35f-a06038cf4414@redhat.com> (raw)
In-Reply-To: <PH0PR18MB5167B80A0538126CB062C01AC85C9@PH0PR18MB5167.namprd18.prod.outlook.com>

Hi Amit,

On 10/6/22 09:22, Amit Prakash Shukla wrote:
> Ping.

I posted a patch yesterday that fixes this issue without having to
change the runtime behavior:

http://patches.dpdk.org/project/dpdk/patch/20221005203524.89336-1-maxime.coquelin@redhat.com/

Could you test it and provide ack if OK on your side?

Thanks,
Maxime

>> -----Original Message-----
>> From: Amit Prakash Shukla <amitprakashs@marvell.com>
>> Sent: Friday, September 2, 2022 8:36 PM
>> To: Maxime Coquelin <maxime.coquelin@redhat.com>; Chenbo Xia
>> <chenbo.xia@intel.com>
>> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
>> stable@dpdk.org; Ruifeng.Wang@arm.com; Amit Prakash Shukla
>> <amitprakashs@marvell.com>
>> Subject: [PATCH v3] vhost: compilation fix for GCC-12
>>
>> GCC-12 complains about the possible use of un-initialized array. At compile
>> time it seems like it is not able to evaluate the size as it involves run-time
>> variable and at compile time it seems like gcc assumes value of "size" variable
>> to be zero which makes gcc-12 to jump the while loop.
>> "size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf);"
>>
>> As part of the fix, "while (){}" is replaced by "do {} while()" which make the
>> compiler to generate a code in which buf_vec will never be used un-
>> initialized.
>>
>> ../lib/vhost/virtio_net.c:941:35: error:
>> 		'buf_vec[0].buf_len' may be used uninitialized
>> 		[-Werror=maybe-uninitialized]
>>    941 |         buf_len = buf_vec[vec_idx].buf_len;
>>        |                   ~~~~~~~~~~~~~~~~^~~~~~~~
>> ../lib/vhost/virtio_net.c: In function 'virtio_dev_rx_packed':
>> ../lib/vhost/virtio_net.c:1285:27: note: 'buf_vec' declared here
>>   1285 |         struct buf_vector buf_vec[BUF_VECTOR_MAX];
>>        |                           ^~~~~~~
>> cc1: all warnings being treated as errors
>>
>> Fixes: 93520085efda ("vhost: add packed ring single enqueue")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
>> ---
>> v2:
>> - Changes for code review suggestion
>>
>> v3:
>> - Added a description
>>
>>   lib/vhost/virtio_net.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index
>> b3d954aab4..9b77d3d10f 100644
>> --- a/lib/vhost/virtio_net.c
>> +++ b/lib/vhost/virtio_net.c
>> @@ -1069,7 +1069,7 @@ vhost_enqueue_single_packed(struct virtio_net
>> *dev,
>>   	else
>>   		max_tries = 1;
>>
>> -	while (size > 0) {
>> +	do {
>>   		/*
>>   		 * if we tried all available ring items, and still
>>   		 * can't get enough buf, it means something abnormal @@ -
>> 1097,7 +1097,7 @@ vhost_enqueue_single_packed(struct virtio_net *dev,
>>   		avail_idx += desc_count;
>>   		if (avail_idx >= vq->size)
>>   			avail_idx -= vq->size;
>> -	}
>> +	} while (size > 0);
>>
>>   	if (mbuf_to_desc(dev, vq, pkt, buf_vec, nr_vec, num_buffers, false)
>> < 0)
>>   		return -1;
>> @@ -1574,7 +1574,7 @@ vhost_enqueue_async_packed(struct virtio_net
>> *dev,
>>   	else
>>   		max_tries = 1;
>>
>> -	while (size > 0) {
>> +	do {
>>   		/*
>>   		 * if we tried all available ring items, and still
>>   		 * can't get enough buf, it means something abnormal @@ -
>> 1601,7 +1601,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
>>   		avail_idx += desc_count;
>>   		if (avail_idx >= vq->size)
>>   			avail_idx -= vq->size;
>> -	}
>> +	} while (size > 0);
>>
>>   	if (unlikely(mbuf_to_desc(dev, vq, pkt, buf_vec, nr_vec,
>> *nr_buffers, true) < 0))
>>   		return -1;
>> --
>> 2.25.1
> 


  reply	other threads:[~2022-10-06  7:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01  8:49 [PATCH] " Amit Prakash Shukla
2022-09-02  7:23 ` Ruifeng Wang
2022-09-02 11:57   ` Amit Prakash Shukla
2022-09-02 12:41 ` [PATCH v2] " Amit Prakash Shukla
2022-09-02 12:56   ` Bagas Sanjaya
2022-09-02 15:11     ` [EXT] " Amit Prakash Shukla
2022-09-02 15:06 ` [PATCH v3] " Amit Prakash Shukla
2022-10-06  7:22   ` Amit Prakash Shukla
2022-10-06  7:24     ` Maxime Coquelin [this message]
2022-10-06  8:05       ` [EXT] " Amit Prakash Shukla
2022-10-06 12:35         ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fe93e73-a88a-88b6-e35f-a06038cf4414@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=Ruifeng.Wang@arm.com \
    --cc=amitprakashs@marvell.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).