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 978CCA00C3; Mon, 26 Sep 2022 05:26:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 443F3400D7; Mon, 26 Sep 2022 05:26:11 +0200 (CEST) Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by mails.dpdk.org (Postfix) with ESMTP id 42206400D5 for ; Mon, 26 Sep 2022 05:26:08 +0200 (CEST) Received: from localhost.localdomain (unknown [10.20.42.60]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx_2vGGzFjOgYiAA--.59517S3; Mon, 26 Sep 2022 11:25:59 +0800 (CST) Subject: Re: [PATCH v2] vhost: fix build To: "Xia, Chenbo" , "david.marchand@redhat.com" , "maxime.coquelin@redhat.com" Cc: "dev@dpdk.org" , "maobibo@loongson.cn" References: <20220829082915.1056865-1-zhoumin@loongson.cn> From: zhoumin Message-ID: <7352946c-b313-d5ea-e2a0-6f761997594d@loongson.cn> Date: Mon, 26 Sep 2022 11:25:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-CM-TRANSID: AQAAf8Dx_2vGGzFjOgYiAA--.59517S3 X-Coremail-Antispam: 1UD129KBjvJXoWxur48Kr4DXw48AF47Jw1fZwb_yoW5uw13pr n3JanrCFW8tF4I9an7XF4Fk34rZa4kCasrKrsxW3WxCFWUt3srJF929Fy09rZrAr1Uu3W8 Xr18tFyUt3WDuaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvS14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxV W0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCYjI0SjxkI62AI1cAE 67vIY487MxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43 ZEXa7VUbrMaUUUUUU== X-CM-SenderInfo: 52kr3ztlq6z05rqj20fqof0/ 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 Chenbo, On Mon, 26 Sep 2022, 10:57, Xia, Chenbo wrote: > Hi Min, > >> -----Original Message----- >> From: Min Zhou >> Sent: Monday, August 29, 2022 4:29 PM >> To: david.marchand@redhat.com; maxime.coquelin@redhat.com; Xia, Chenbo >> ; zhoumin@loongson.cn >> Cc: dev@dpdk.org; maobibo@loongson.cn >> Subject: [PATCH v2] vhost: fix build >> >> On CentOS 8 or Debian 10.4 systems using gcc 12.1 to cross >> compile DPDK, gcc shows a following warning which will cause >> build to fail when build is run with -werror: >> >> In function 'mbuf_to_desc', >> inlined from 'vhost_enqueue_async_packed' >> at ../lib/vhost/virtio_net.c:1826:6, >> inlined from 'virtio_dev_rx_async_packed' >> at ../lib/vhost/virtio_net.c:1840:6, >> inlined from 'virtio_dev_rx_async_submit_packed.constprop' >> at ../lib/vhost/virtio_net.c:1900:7: >> ../lib/vhost/virtio_net.c:1161:35: error: 'buf_vec[0].buf_len' may be used >> uninitialized [-Werror=maybe-uninitialized] >> 1161 | buf_len = buf_vec[vec_idx].buf_len; >> | ~~~~~~~~~~~~~~~~^~~~~~~~ >> ../lib/vhost/virtio_net.c: In function >> 'virtio_dev_rx_async_submit_packed.constprop': >> ../lib/vhost/virtio_net.c:1838:27: note: 'buf_vec' declared here >> 1838 | struct buf_vector buf_vec[BUF_VECTOR_MAX]; >> | ^~~~~~~ >> cc1: all warnings being treated as errors >> >> Actually, there are eight places to see the same codes in the file >> lib/vhost/virtio_net.c, and all these `buf_vec` arraies are >> initialized by sub-function calls under various conditions. >> >> Although It's hard to understand why gcc just emits warning at one >> of the eight places, adding validity checks for array length is >> reasonable and can also fix the warning. >> >> Signed-off-by: David Marchand >> Signed-off-by: Min Zhou >> --- >> lib/vhost/virtio_net.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) > Just want you to know that your patch is still pending because by accident > your fix is almost the same as a previous patch that fixes a real issue but > that patch is still in progress: > > http://patchwork.dpdk.org/project/dpdk/patch/20220802004938.23670-2-cfontana@suse.de/ > > Thanks, > Chenbo Thanks for your helpful reply. I think I can drop this patch if the patch you mentioned above could be accepted. Thanks, Min Zhou >> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c >> index 35fa4670fd..99233f1759 100644 >> --- a/lib/vhost/virtio_net.c >> +++ b/lib/vhost/virtio_net.c >> @@ -1153,7 +1153,7 @@ mbuf_to_desc(struct virtio_net *dev, struct >> vhost_virtqueue *vq, >> struct virtio_net_hdr_mrg_rxbuf tmp_hdr, *hdr = NULL; >> struct vhost_async *async = vq->async; >> >> - if (unlikely(m == NULL)) >> + if (unlikely(m == NULL || nr_vec == 0)) >> return -1; >> >> buf_addr = buf_vec[vec_idx].buf_addr; >> @@ -2673,6 +2673,9 @@ desc_to_mbuf(struct virtio_net *dev, struct >> vhost_virtqueue *vq, >> struct vhost_async *async = vq->async; >> struct async_inflight_info *pkts_info; >> >> + if (unlikely(nr_vec == 0)) >> + return -1; >> + >> buf_addr = buf_vec[vec_idx].buf_addr; >> buf_iova = buf_vec[vec_idx].buf_iova; >> buf_len = buf_vec[vec_idx].buf_len; >> -- >> 2.31.1