From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 142B8A00C2; Thu, 6 Oct 2022 09:24:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A29A64280E; Thu, 6 Oct 2022 09:24:44 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6D13141153 for ; Thu, 6 Oct 2022 09:24:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665041082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nnVY4qAqZELz6nXFkSzKVTKZKo3eGA0jL/xXq/i9ZXk=; b=dFEK9b8qXOyzyfK0goQBZS44FEpQ6ZyfMmKbDDN699cxrebnQcqYtePYNNeyd9VZYSxIeI IDMcivxudf1xeh939Xyt2UIqzFzFxztzgmOZUFw7a1Jgk3Kw80GPdV84FWJQb92tK4BLoW MQKdzFVvHjG2/9jW+wLH4GJhzAVNr8c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-jBsIqxe8MJa_vcONgYFfDw-1; Thu, 06 Oct 2022 03:24:39 -0400 X-MC-Unique: jBsIqxe8MJa_vcONgYFfDw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EF1585A5B6; Thu, 6 Oct 2022 07:24:39 +0000 (UTC) Received: from [10.39.208.19] (unknown [10.39.208.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 98518477F55; Thu, 6 Oct 2022 07:24:36 +0000 (UTC) Message-ID: <5fe93e73-a88a-88b6-e35f-a06038cf4414@redhat.com> Date: Thu, 6 Oct 2022 09:24:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v3] vhost: compilation fix for GCC-12 To: Amit Prakash Shukla , Chenbo Xia Cc: "dev@dpdk.org" , Jerin Jacob Kollanukkaran , "stable@dpdk.org" , "Ruifeng.Wang@arm.com" References: <20220901084943.3075710-1-amitprakashs@marvell.com> <20220902150622.3233855-1-amitprakashs@marvell.com> From: Maxime Coquelin In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 >> Sent: Friday, September 2, 2022 8:36 PM >> To: Maxime Coquelin ; Chenbo Xia >> >> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran ; >> stable@dpdk.org; Ruifeng.Wang@arm.com; Amit Prakash Shukla >> >> 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 >> --- >> 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 >