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 A6973A0543; Wed, 24 Aug 2022 16:10:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D37B40DDE; Wed, 24 Aug 2022 16:10:11 +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 A63924067B for ; Wed, 24 Aug 2022 16:10:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661350209; 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: in-reply-to:in-reply-to:references:references; bh=qtF5oCw9BFq71TFMy5rj+ECHt4jVlJkMAvO+/YzqwWM=; b=Gh+BOW1DbQSdGKJUX4AJHnQbHoSUtdfasjCOA7+YcBWeTzYdzOraX75AhYFdOXdhG0hglT yafnL6/Z03+YjrDrpy+j9nQBeWlj9q/J1cnVoHIAIg1oVdq30Cqzw/MpN4FJl3WAuxaAHR M49f43zddPV3j/sFV4fUtLz/zys1heo= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-556-y97epwUXNeyO5hVqffaNuA-1; Wed, 24 Aug 2022 10:10:07 -0400 X-MC-Unique: y97epwUXNeyO5hVqffaNuA-1 Received: by mail-lj1-f197.google.com with SMTP id m1-20020a2eb6c1000000b00261e5aa37feso45880ljo.6 for ; Wed, 24 Aug 2022 07:10:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=qtF5oCw9BFq71TFMy5rj+ECHt4jVlJkMAvO+/YzqwWM=; b=Er+EigdqS8tePcEbuS/24H2kR2ZUNNfrZF6Gl5PYZnLJxcgTO/qUQWveB3vRrpHIkf nic8jLchQEXWmQMXpQwHswOjyx5sjmHGZx/DI5ca+6WYHB1apoTzWQRwRiZXAJ8kvu5Y r1RlZ6he8cJRs+jWGwfNlas7GTSGTFVLYK32OGfl1gnDL9v0yuByWG1ztiyBERQBHrtf oTS6BJvzMP6cgV/8rtMaubawJFDoPmP2u7ENTYGUyAHFzHZZuH13TfApQWxABmmXGaeP VE+elXZSlxBDI/erZPGgxxCc2UGRrnro3UyKx7QHxQGsW6VNry3C6TcCqjZ0pWtmKgiS ukUg== X-Gm-Message-State: ACgBeo29kKSRBgKHQWM05xnvKeqNxT5nKZN0cRfJwiLFWvvTJrNnaWn0 tQKyKVJiCgOzCj72fUe76uah46C/cyPUZrKKeYWDUPj2KHAOEGlr7pH/kgiicOVysJ87m3siy2z +aCpg7acHVLUuBabPawQ= X-Received: by 2002:a2e:8ed9:0:b0:261:bdfd:4b7d with SMTP id e25-20020a2e8ed9000000b00261bdfd4b7dmr6611579ljl.333.1661350206237; Wed, 24 Aug 2022 07:10:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kVoJ+PfvnoaMoAywCP7qRy5+Al20IqgvQm3Bd0WYeoGnIbTk5lmxDtXhbadFkIEXkUKsbtByhhJw3Uh6t6FM= X-Received: by 2002:a2e:8ed9:0:b0:261:bdfd:4b7d with SMTP id e25-20020a2e8ed9000000b00261bdfd4b7dmr6611572ljl.333.1661350205980; Wed, 24 Aug 2022 07:10:05 -0700 (PDT) MIME-Version: 1.0 References: <20220822074233.209414-1-zhoumin@loongson.cn> In-Reply-To: <20220822074233.209414-1-zhoumin@loongson.cn> From: David Marchand Date: Wed, 24 Aug 2022 16:09:54 +0200 Message-ID: Subject: Re: [PATCH v1] vhost: fix build To: Min Zhou Cc: "Xia, Chenbo" , dev , maobibo@loongson.cn, Maxime Coquelin X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 On Mon, Aug 22, 2022 at 9:42 AM Min Zhou wrote: > > This patch fixes the following build failure seen on CentOS 8 > with gcc 12.1 because of uninitialized struct variable: > > [..] > ../lib/vhost/virtio_net.c:1159:18: warning: 'buf_vec[0].buf_addr' may be used uninitialized [-Wmaybe-uninitialized] > 1159 | buf_addr = buf_vec[vec_idx].buf_addr; > | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ > [..] I don't like setting the whole variable to 0 just to silence a warning, like pushing something under the rug. This is all the more suspicious as there is other code in this file that does almost the same. I had seen a similar warning during 22.07 when cross compiling but did not investigate much. The patch that I had written at the time was: diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 35fa4670fd..9446e33aa7 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; Could you see if this fixes your issue? If it is the case, it may be worth better understanding what bothers the compiler in the current code. -- David Marchand