From patchwork Mon Oct 31 13:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 620247 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2824223pvb; Mon, 31 Oct 2022 06:29:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MhCnZ8TtPDSqZX7oCrEoMYxJMCDnq+PXE0k/UIYLi0J72/R7wVktIHp1d4GAHHk4Uxp3i X-Received: by 2002:ac8:5b05:0:b0:399:9b82:77b4 with SMTP id m5-20020ac85b05000000b003999b8277b4mr10394317qtw.681.1667222965742; Mon, 31 Oct 2022 06:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667222965; cv=none; d=google.com; s=arc-20160816; b=Yx+U/EvW6bLOgbDX/sBNGftcApg2kMKZXoN7VBKaXCna0SWXsRp+3zXOsGhiG5bAwW 0wWQ+iQZVuRjAWGUo5Rq7TV6BStneN42OBdmu6ehwGLFjDFrMOyYBMa3yEmhKjBWp5XX tARHzxA6JjH4UboXpTvnnza+Zy+sbn68guL2nAOjnk4eiHDJ/WCcywS8nf29XzilENgT A162hTcD0fhReR0bimTWpTq/tTQ8/W0BwOh/O2rAUPvDX+tZsjc+kigKZBZqV6sJU/7S izTg/6PdHKp5AiORnLA46mQmOswqp0wutIhpcHkl/PIgv4UAJkby4lUtQpIwv2o47wYs wLJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=yuuYZlJ/V5Ve27LY21d8FcrV2Yd/AQIKFUrJI+yOj5U=; b=FSZXydjKQI1WBBlknzYcGxUzWqwHd04TwrRPCriwropTYMBRXor6035xcA08/nDNNH 0Mmws0ovrckIpBrR6GurwO1u33WyBplDXxt+M9W2H80X96X9yYmQEedJ0Jd+DslN98L6 LtN63Xs3E/yTRbP38wpqPH6O9Om4XfeOeZZ/XVWeQTFHaZErOOrGwyguHbNvjsuU1h1v pU3cWniMXesKXqjCmxA0SehY2RKhCa6KahqSmLO3Nc5QPYi9SNCwH7HtBs7/AMHicFZ0 Etziyf/KxbfT1povluApXmgVPQMi1P1IJhdLUmYkoIFLfROffJbxzx83YWuCt3ANHTPz FJXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rlesVpx7; spf=pass (google.com: domain of qemu-devel-bounces+peter.griffin=linaro.org+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+peter.griffin=linaro.org+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x8-20020a05620a448800b006f4db55e8a8si4315335qkp.62.2022.10.31.06.29.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Oct 2022 06:29:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+peter.griffin=linaro.org+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rlesVpx7; spf=pass (google.com: domain of qemu-devel-bounces+peter.griffin=linaro.org+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+peter.griffin=linaro.org+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opUqj-0002TC-4G; Mon, 31 Oct 2022 09:29:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opUqh-0002Me-77 for qemu-devel@nongnu.org; Mon, 31 Oct 2022 09:29:07 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opUqf-0000b7-KU for qemu-devel@nongnu.org; Mon, 31 Oct 2022 09:29:06 -0400 Received: by mail-wr1-x432.google.com with SMTP id w14so15957830wru.8 for ; Mon, 31 Oct 2022 06:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yuuYZlJ/V5Ve27LY21d8FcrV2Yd/AQIKFUrJI+yOj5U=; b=rlesVpx7TXhvj90rHUuz/P6Q2JKr/fX1pcClGW0GgOJ0zD/pNuW8Wz05vtJ/g97IDT sin7fCVU+BUYdz8ml/OgizNT4/1zDqdVTBYQOsCzlbUwrFaxWC+xiZ2iH+Z+a+WRCqmq TVgMuKYEkf80H5ruTqS+iIgrFhBvzCdJ17AUFztPovD0NXszwrcK6Ulrwx0/2GNv9tQV 5S0SRcn6H+jiYlqV26ma9q1c6MqOSlQJCiXVnSyzwfIHajwipIxx0zMlAgFB5AV+P4Fy gF8MlFx8bAHiVM1UWGQbtRsqFHFsJsmsZzx+B0DM3fj+QRArJpDMIONglzan8+5LQBEs h/lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yuuYZlJ/V5Ve27LY21d8FcrV2Yd/AQIKFUrJI+yOj5U=; b=X7yGhzqIdYDZXkIhIWf4CHFyNESOgRhb7Y6uigHZVPBXEp8AAgdffiuIMvXuNuNUNg xSVrX/8opRa/eeIVJ/NvgsI0wI+YhTgnT8zcwN1itXm7VmViCPbeparok7VtwC/7Wfzf rkp5+No7wWggJ8zsc75DYxx0P4lzk/YibDCooxZJ5G8bDMJrWfG+8x23rYUSl+QuWe/J 1YRYL6C/mWCzAuKDXzolJEppKHzRSZvIq2YOFzvYoNSmkBvL8ltNqpC6BsN/YbrBKwn7 jtzZX07uh4S3zAcoZtJm1TG/eKW6mPXklRcT8+CF4MePrqaTfH9YBqM0T/r0ec5tTlsm TMzQ== X-Gm-Message-State: ACrzQf0ROajI++MJv2UfEAe1fj0yH/mhjDaFjNbocHvh+4clNuQFdsXV F6+ZpzKUPPT1bRQjNQIo4kNcck6YMg5gSA== X-Received: by 2002:adf:dbc5:0:b0:22c:c605:3b81 with SMTP id e5-20020adfdbc5000000b0022cc6053b81mr8056396wrj.218.1667222943976; Mon, 31 Oct 2022 06:29:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z18-20020a1c4c12000000b003cf75f56105sm1524628wmf.41.2022.10.31.06.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 06:29:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Jason Wang , Si-Wei Liu , =?utf-8?q?Alex_Benn=C3=A9e?= , Stefan Hajnoczi Subject: [PATCH] net/vhost-vdpa.c: Fix clang compilation failure Date: Mon, 31 Oct 2022 13:29:01 +0000 Message-Id: <20221031132901.1277150-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+peter.griffin=linaro.org+patch=linaro.org@nongnu.org Commit 8801ccd0500437 introduced a compilation failure with clang version 10.0.0-4ubuntu1: ../../net/vhost-vdpa.c:654:16: error: variable 'vdpa_device_fd' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] } else if (opts->has_vhostfd) { ^~~~~~~~~~~~~~~~~ ../../net/vhost-vdpa.c:662:33: note: uninitialized use occurs here r = vhost_vdpa_get_features(vdpa_device_fd, &features, errp); ^~~~~~~~~~~~~~ ../../net/vhost-vdpa.c:654:12: note: remove the 'if' if its condition is always true } else if (opts->has_vhostfd) { ^~~~~~~~~~~~~~~~~~~~~~~ ../../net/vhost-vdpa.c:629:23: note: initialize the variable 'vdpa_device_fd' to silence this warning int vdpa_device_fd; ^ = 0 1 error generated. It's a false positive -- the compiler doesn't manage to figure out that the error checks further up mean that there's no code path where vdpa_device_fd isn't initialized. Put another way, the problem is that we check "if (opts->has_vhostfd)" when in fact that condition must always be true. A cleverer static analyser would probably warn that we were checking an always-true condition. Fix the compilation failure by removing the unnecessary if(). Fixes: 8801ccd0500437 ("vhost-vdpa: allow passing opened vhostfd to vhost-vdpa") Signed-off-by: Peter Maydell --- Stefan, do you want to apply this directly as a build fix? --- net/vhost-vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 854ebd61ae6..e370ecb8ebd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -651,7 +651,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, if (vdpa_device_fd == -1) { return -errno; } - } else if (opts->has_vhostfd) { + } else { + /* has_vhostfd */ vdpa_device_fd = monitor_fd_param(monitor_cur(), opts->vhostfd, errp); if (vdpa_device_fd == -1) { error_prepend(errp, "vhost-vdpa: unable to parse vhostfd: ");