From patchwork Tue Mar 12 18:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779768 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2167975wrt; Tue, 12 Mar 2024 11:39:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBMdxa1nBsm+hyY1h3jWGdUuFgqzP3xVcDUemiqF4TVT9facFUSqR4aiN690usOJdgGZb2exIrtoU9QvF7Tn4v X-Google-Smtp-Source: AGHT+IHhtHSMNupWjpnYZ47H2boj1TQNMumBKQjYI1V3mTWYJ8pX9cd9O59AnemXbIuR2kC66pwS X-Received: by 2002:a05:6870:1590:b0:21f:a11a:e251 with SMTP id j16-20020a056870159000b0021fa11ae251mr3075979oab.5.1710268746599; Tue, 12 Mar 2024 11:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268746; cv=none; d=google.com; s=arc-20160816; b=O8bjWVhRZ1MP4U4eCqiNHi8n8GsdHFp5NgxkhTrbOJUnMWN3Yn1GK8lLdo7jJlTd9y vBE4FlGHaoip3xa+YaIlrEJxPwu5gS//ULs68mNKdf/6Hiaun1n4g22SHeCoxNuWM8EK R14uzYd48NaOJbaiSkeyqEk7oCJuWUe3zLJg54QnyNa9N6jvcoRfKKXfI4u6IEfpeLne 238nrKhUJ2XvHygpv26fCnfK9auTR06kplbECTMnKNIVpQ4gq7B8R3UXaDewt0rYKSu5 6brLqvYdIfY+sWbnrdqHnRtadxxEXPlyouUSN3pcQ3x24pcWKlRl6f9LHpJwfgJorwI/ 7t3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=YLwrLK6pe4v4As4FiQrlSek3puRi+quH0IgezmVNfJ4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=df7JlmqJSL6tht9Xr4CWx4sp6WoIKIASqPfdZps39LATFEZ6W+tGYnDO/uFAZb+CFG 9nQbsKRRzQcVfJfMERwAcg6JnWKa6V+WKgk3qve4fcHqjraD3Nnpu7tBI/E/Uj+G/+sO bJUubVEn9ODpsYgzJ44uDDcYLQ6O6CMDhEbM9b9x6WLXp/ufN0uRh4wTWKKCiiBFVtHW uFFxzky/RHA7AHYu4flELsQiRI18osuOodAZdklfpCh1q6/uzEr7TMIyg9eYDtQtHT5b XklJsgnBD5l01T0RF1LgDHCWfjkUaGhqrvUsJalSK6W8WVHr9BV4+y4CyvE6OAr5ZRQk mFwQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HcRIvthY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 dv10-20020ad44eea000000b0068f8d411539si8089603qvb.464.2024.03.12.11.39.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:39:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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=HcRIvthY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71G-0003aT-R7; Tue, 12 Mar 2024 14:38:34 -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 1rk711-0003NE-R5 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:20 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70w-0000c9-I0 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:19 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-41342849a15so1965085e9.3 for ; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268692; x=1710873492; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YLwrLK6pe4v4As4FiQrlSek3puRi+quH0IgezmVNfJ4=; b=HcRIvthYq4A0mQf2YXObfenS22poAr8WP07lH/HI+PHs/eVo/EX45zagQmSu/zky5l KvJdCXezzTIsYmiqRYo2HJhVF6rYZSRi8+ZCiw/UsEKG6SIFHCHN9w6j8gtS62Q7uTt8 PoT6s9SL34EJsFerAqZPN3bPbEQGm/MMKuShqMRAGHTv4XlDQu6fMAU7RgSQJCbMqiC0 OOep0it2IvzMPehED/Q+z8KCX8LP1DVvkMfUOjnu3SpGByTObeX0tzY+6EQeD6zIQuVg WFGHv5Y+beVPzSv9o2NKnVfRddTyWerqSN1XW8aGNA6/dR6zJwP/K7+L6iu6bUNCRuL0 7nUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268692; x=1710873492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YLwrLK6pe4v4As4FiQrlSek3puRi+quH0IgezmVNfJ4=; b=X7EPUvmmbOUmwVolrSlsHKlFd35sYqnhJk6qFnSXZm6H7qBsMObzmg5F053BRPZMSX a+mZyB8xE+tmU0uTPctpfwkv3RbHsxJq53X1n7Z3YoY3chTd/+yM8vcZ8FZxDTesNCLD SRIcu2laqrPjS99DVeJUngCS97wt8zRN1c6f3Fipd8OgU7lwhjGSozQGbvPB0hnE1j/Q MpQD+tuHUx3GEpGT4PBzDxQHoK+YeHX5ZAQUess2GwDTdg40BDKxoH+TooBiNCoeZ5xi ANxgtIHJAjEMxI+LcMABt90Y3O53CpaPCVxagZqRMSZLME0GmnTVeANs+4jmlkgcNMEo GibQ== X-Gm-Message-State: AOJu0YyN5KcYsHorpQIVo/4HGnzPvQnyWSXonJkUcG9i1dTqojeum7VZ abYzvolSw2HpKYTxA7TYXC/EhKgWltC9MYoIX1eE9sEPSWtEEgmWlJ6Ze8XsGMk7+Z68uTv9XwZ f X-Received: by 2002:a05:600c:4e56:b0:413:1645:29a6 with SMTP id e22-20020a05600c4e5600b00413164529a6mr733115wmq.22.1710268691930; Tue, 12 Mar 2024 11:38:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 1/7] tests/qtest/npcm7xx_emc_test: Don't leak cmd_line Date: Tue, 12 Mar 2024 18:38:04 +0000 Message-Id: <20240312183810.557768-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In test_rx() and test_tx() we allocate a GString *cmd_line but never free it. This is pretty harmless in a test case, but Coverity spotted it. Resolves: Coverity CID 1507122 Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth Reviewed-by: Thomas Huth --- tests/qtest/npcm7xx_emc-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c index 63f6cadb5cc..2e1a1a6d702 100644 --- a/tests/qtest/npcm7xx_emc-test.c +++ b/tests/qtest/npcm7xx_emc-test.c @@ -789,7 +789,7 @@ static void emc_test_ptle(QTestState *qts, const EMCModule *mod, int fd) static void test_tx(gconstpointer test_data) { const TestData *td = test_data; - GString *cmd_line = g_string_new("-machine quanta-gsj"); + g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj"); int *test_sockets = packet_test_init(emc_module_index(td->module), cmd_line); QTestState *qts = qtest_init(cmd_line->str); @@ -814,7 +814,7 @@ static void test_tx(gconstpointer test_data) static void test_rx(gconstpointer test_data) { const TestData *td = test_data; - GString *cmd_line = g_string_new("-machine quanta-gsj"); + g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj"); int *test_sockets = packet_test_init(emc_module_index(td->module), cmd_line); QTestState *qts = qtest_init(cmd_line->str); From patchwork Tue Mar 12 18:38:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779771 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2168358wrt; Tue, 12 Mar 2024 11:40:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXEL58XAhIOdnHmaUs2CowSZTtmOwkAX1HD4bk98FBSJF9esIJtGYDfJIzAVgsoVjMAGkm3KGJ6R+Ad/xFEwbOi X-Google-Smtp-Source: AGHT+IHbIubVYvEvTSvZjlpcG4nRzvewbDk+jsff4NIPNbbp/W03PVCxHaV85X6Ehxb540tu3biv X-Received: by 2002:a05:6830:12c5:b0:6e5:220c:7ec4 with SMTP id a5-20020a05683012c500b006e5220c7ec4mr10840533otq.16.1710268808742; Tue, 12 Mar 2024 11:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268808; cv=none; d=google.com; s=arc-20160816; b=q++Mp2LSgH5aqeVsCPnUEKS99CZdfUK5loZLHNG0JHJjoXBl07aJUA+Hok+QJVvvGm /ne1sskZ2HhCLGSdpJHX2enYp8y4fSHCjNYRkXSK4uDm0ovK6ihn57Cp0X8ZjDVoQNj5 pRNaDNiiWEK1gcc/RhciqauPySnH9S0FGZ7kwDiIMFLOfO6/0nhxJxOaCNqbAPeZxrPp OMKGhjOHZeLR6QUfTwzL+rQNAXY1q7PKcmmQ1iXBpbJ3KdQgAjUwEyZ4/doG8Y9FvABi ABws3sAK9kLme80GMSRFFxrqFno5HrhsfmP0lmr/M82Rx34VoP79/Ne7arlcPl89TUHW BE5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=09aQF63pPHOllcqpbcVLj8Q606SuNrCw0WJNZs+4sLY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=KrXtPC64acZye02k1ihRUyaT2ezOZDUVo/+3UHcIMgHRwAVoL97E/k5TZxh7pJBosU K24ShVz0JV4s5cwPS0nHhS/edNa2f3NitPs1Q33aAy9GMf8XfLACL6QdHeAPOT2VAWEW pA8PnUQQ5oDaPE94Tn2O9vuvSOblu7IYyxtLI81ealkzKZalhW291DvJDtDmnRUtqftI /HtYNPQUwLD3KHQj0L0mrv3FL9zysdE2AyyyESBCHv34ccil4YUEC56bCCSLI1p1C7GS 0lqirRyPaAQS8LwGUG3BCq2YcxFqKK4qg1PJu9jOMv/L4OcFA0ciC0WEkXGn2pw4z3GW 48Fg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dL20NEt8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 c24-20020a37e118000000b007882f7f74c6si7981459qkm.257.2024.03.12.11.40.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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=dL20NEt8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71D-0003VW-0M; Tue, 12 Mar 2024 14:38:31 -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 1rk70y-0003MZ-N7 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70v-0000cB-R1 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:16 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41329b6286bso14727745e9.0 for ; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268692; x=1710873492; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=09aQF63pPHOllcqpbcVLj8Q606SuNrCw0WJNZs+4sLY=; b=dL20NEt8U99+WpjLVmbF2fkkSD7tFmqjoeMGHuH6mTpcXSr0VZ7GZob7jK/E0ajq+E pgHi9+t0JEvNwFUBJ5YAPXW21n63uEFv2VgX8AiErBSLdMAOV0+qqsqAKqniPrjbeW+A acwZlA7iXwjlLvv0A1DZDqDzidp25/+FWGXAHo63DcRbUCU9YgUwEXsA5p6qASxeu7aQ JLGS/rqgUPSM/ZsWSkQzosoeGCzHbDcaCNXYxZsWX+G8eidZOdw0Q8nkdSrTOmN8Ge8W 1k2O2MUtvJ3ADHmUn4jYgfolLg80IJRjQNwVOwFQxljKHyLeJFsthO0sfq3wBwfoj7eS Kv9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268692; x=1710873492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=09aQF63pPHOllcqpbcVLj8Q606SuNrCw0WJNZs+4sLY=; b=DsEKRj89b2GnHfBr3C96Sycg63s2rAMyxR+Cn0nwnJvw7t/jiL3Yz2EshqvYZe9wM+ capSidjQMYsmwXLShSYpW+At+9xcT1jImj4Rd/uQw9AUz60sgqjdSSzXlew4ifnbykp0 iwwUViVi6Ibu2uk/9u/HUIsDU3pxS0HmhIWNYhEMXpBc5gGZab7FMVxHuBFujK8IaopR klTV6ktsA9W7jpJI5oGUOrW4PH7tW5AYhc6+iPE51iXxZ2S2AUDM7SAhkVkXPONpMrZ1 HDlLdaiFjLxZEndfzHLCVx0ev7kFuP6YrD/IZsRtvVC8JOR0qGeqZn2L48E5zY20iMNF RKvA== X-Gm-Message-State: AOJu0YzffBMYgnuUu3p93WRwXCl5ufa8KqA5tN5n1RHuMYm/3Ujynu09 1ae/fZPynsHxMSV0s9tH2HCnUGcwbbHr7Ou9mJ7IHydy4+gYk50nOy3DM4qdqHuIU5o0+XApxX0 b X-Received: by 2002:a05:600c:548c:b0:413:271a:1e5e with SMTP id iv12-20020a05600c548c00b00413271a1e5emr691533wmb.38.1710268692473; Tue, 12 Mar 2024 11:38:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 2/7] tests/unit/socket-helpers: Don't close(-1) Date: Tue, 12 Mar 2024 18:38:05 +0000 Message-Id: <20240312183810.557768-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In socket_check_afunix_support() we call socket(PF_UNIX, SOCK_STREAM, 0) to see if it works, but we call close() on the result whether it worked or not. Only close the fd if the socket() call succeeded. Spotted by Coverity. Resolves: Coverity CID 1497481 Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth --- tests/unit/socket-helpers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c index 6de27baee2e..f3439cc4e52 100644 --- a/tests/unit/socket-helpers.c +++ b/tests/unit/socket-helpers.c @@ -160,7 +160,6 @@ void socket_check_afunix_support(bool *has_afunix) int fd; fd = socket(PF_UNIX, SOCK_STREAM, 0); - close(fd); #ifdef _WIN32 *has_afunix = (fd != (int)INVALID_SOCKET); @@ -168,5 +167,8 @@ void socket_check_afunix_support(bool *has_afunix) *has_afunix = (fd >= 0); #endif + if (*has_afunix) { + close(fd); + } return; } From patchwork Tue Mar 12 18:38:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779767 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2167941wrt; Tue, 12 Mar 2024 11:39:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTr2BJWfYi/IxWbApKD4g0k8TnSAvY+NCQLuYFSNQxHkYCD7mb/+OSPP/a4wPDYn1L7gl2Tm8G+z9NwdIsu7em X-Google-Smtp-Source: AGHT+IHMmwB7EHJgpSHwyZZQXsRbXmxKNHpfYCryye07qOmG8mwD3ITQNkEbtI53JQ/FMhnzOQfK X-Received: by 2002:a05:6808:3011:b0:3c1:c36e:9ec9 with SMTP id ay17-20020a056808301100b003c1c36e9ec9mr13040726oib.17.1710268743017; Tue, 12 Mar 2024 11:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268742; cv=none; d=google.com; s=arc-20160816; b=vpQ7XrA9hMaIKiVM73TXsLdDHoo5RTcUUXr2CuHWfkRW38ZtFlmhM6zw5RPrhiGoRA J2/vXkIMWW7sZabBS1tU5/2asDRRl53xLJmZY3N351fQBR4pADno4J/0dAUssDc/oNmV fNDqkL/qdkDNHWbFYnvqdzVxB197QjJthinYsq1hBVYz2DySaFA6fcTA1vJL6LIuNvb+ XQ3nSlxTTKxBxVn98MO4dvngaOmdDxvuN9uhpheISsK9x+BlCFCpvdXDrtqWgZwWbQhZ 0Kud+VOu8/s1IYvaPP/jHZdBU0fudsxuf6CIw3ST6W7Ov3DBPNZD8BPM2q3cyRlpBLNp lv9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=leIb44YVt2ONZNF3/nNgR8JxpEyw4LXHpjhhtBaqKe0=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=S2r5aOdXDxTzBvVlXJHc1qZcqPOmhUSkA4pfg9CWSFYHfL6J18sGlxLelyaU4ccaLb SLdpU5svx2hPq/PSvFbDbqXOUslMZTmXVaiIQWQQ1cGOQy5NDNwuCEgFWIWz1iOL813f 5XPr5p3SjzpVdUhU+PtmVMX8qag5WOaLoWCLAFI9Wl1jOJnnpa9n/AmZTUnGirB6rbNR WboFFVrsP6P2q3RscHC6GL/dm0YigffF0LARoIz8MMlEFaORnzTGs/TGB+e3lnlTq3Qe vM9f/DNOz9DVX3P9dVOgqfWWMBw0PD0AcRbOJqqRNnKve80qwIkNSYrCvuu+EtUIHNw+ 6Rrg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v9dHZnYR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 e1-20020ac85981000000b0042ea0a2fb20si8363301qte.570.2024.03.12.11.39.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:39:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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=v9dHZnYR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71C-0003Uy-Oe; Tue, 12 Mar 2024 14:38:30 -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 1rk712-0003Pc-6q for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:20 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70w-0000cF-JZ for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:19 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41324a16c9eso2033875e9.0 for ; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268693; x=1710873493; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=leIb44YVt2ONZNF3/nNgR8JxpEyw4LXHpjhhtBaqKe0=; b=v9dHZnYRG7+oD5nMa8uuk9IwitY1efDwuWbM5SA3lQhK7HhNONltNzbAQf3PnQjPE/ OLwk47u69wteLpQP1RREDM17Kbak1zNCNFgTtDVLGuLSaZquB8mkp/fwXRC3Mg4F/ts+ NAlp9Io5yvkUDGbtudnCJlDi0feaBPw5Dz9b25nyyv0wMqm32DW7TjYt7DoWlEM0UniY f93J1LDVxJPateL7RFswqhdhswjWxvn2YMsrHBs+nnsj+aPhHkg9v+jig4E6/aDOP5zY +myhKsz/2N2ViK63app6y6auw6vRYbl02BaWrZZYrz9JmH9TIlkhVcqoSacDAn69nH4J NQVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268693; x=1710873493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=leIb44YVt2ONZNF3/nNgR8JxpEyw4LXHpjhhtBaqKe0=; b=HvICX1pCawcgO62K8IZqoz7uExj9odJ+C6SuTgmiCMcfZ2iSyF0u3eG6CsGxhsayIz PZO+/Xsc9Nd5Moy/WnBFYfnXMBjyBxcP+3/tRLPhtRqTD7lBwqxPw2tiueI/C+UQpzbD 6fR8qmDCnXRRDVjMNj7M+3Gvid4HidFfAuaQ06zFycHa6Fw/SLHcl2oO0hp/a/yu9wIc xR5l3SmAg7r38eNXd+Y4Mmpcde0sr+sFc3Xu//046lBG8JyJKfe089njfe+nszyiGzLt CTFeb+HDcoBGncf81BO1MpA/4FaihZhhkG8xnK9wT3+udaUeBHz3DKjZ8UnqmaCilx7Q 3B5Q== X-Gm-Message-State: AOJu0Yz/DL321qG0SzpyosTB8h7xPPN4+OUxne/YgmWy6BW1MtUDllnk +xduo2YkoxShTNGWbgP3HOelZ81TeXojY1nB6ycbU6FTwSwXV+U7zX7/bgEY1WotPEx1XK6erQE + X-Received: by 2002:a05:600c:45cf:b0:413:e4cf:109d with SMTP id s15-20020a05600c45cf00b00413e4cf109dmr846067wmo.1.1710268692868; Tue, 12 Mar 2024 11:38:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 3/7] net/af-xdp.c: Don't leak sock_fds array in net_init_af_xdp() Date: Tue, 12 Mar 2024 18:38:06 +0000 Message-Id: <20240312183810.557768-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In net_init_af_xdp() we parse the arguments and allocate a buffer of ints into sock_fds. However, although we free this in the error exit path, we don't ever free it in the successful return path. Coverity spots this leak. Switch to g_autofree so we don't need to manually free the array. Resolves: Coverity CID 1534906 Signed-off-by: Peter Maydell --- net/af-xdp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/af-xdp.c b/net/af-xdp.c index 38e600703a3..01c5fb914ec 100644 --- a/net/af-xdp.c +++ b/net/af-xdp.c @@ -446,7 +446,7 @@ int net_init_af_xdp(const Netdev *netdev, NetClientState *nc, *nc0 = NULL; unsigned int ifindex; uint32_t prog_id = 0; - int *sock_fds = NULL; + g_autofree int *sock_fds = NULL; int64_t i, queues; Error *err = NULL; AFXDPState *s; @@ -516,7 +516,6 @@ int net_init_af_xdp(const Netdev *netdev, return 0; err: - g_free(sock_fds); if (nc0) { qemu_del_net_client(nc0); } From patchwork Tue Mar 12 18:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779774 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2168578wrt; Tue, 12 Mar 2024 11:40:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4hsdKBUpLUFFuzxoQJkmabVQMma2JyFw/ljW1xx5gXsj7imYdD+Asp7rF3vLaQdjRprZDKSDPPBlmWD2+TbIu X-Google-Smtp-Source: AGHT+IGtxDNhTLfzCTxLqgiCzzsJhBupYvJrZ+lRbEMrvYySGWI3M/nmkJibKkdH7UX6HNaVvjRu X-Received: by 2002:a05:6870:819e:b0:221:8a03:6de7 with SMTP id k30-20020a056870819e00b002218a036de7mr10604132oae.32.1710268841624; Tue, 12 Mar 2024 11:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268841; cv=none; d=google.com; s=arc-20160816; b=u0weEFM+6FCFqD7VDA56z9IqGaOmRR0hlnrjgDdWMed/pKiOzs86xjs7cWgEmIYzDh B09wzmYJ1k6mLNRctDLNEzA3jA0cy8U9ggmRVy7HNQwDfEFOOKYPf7VuOzOexGj29btx OC5erfnExtDFck1gcLbbSLX+Pu/NpRggaGMYmx/DieSCKQImnPjtUrZiz0dOrjl6YdQh WtBXno/OiVYQTsg7XeCYIETrBrWsmvfIi3ZY8oze3w8jox01EMZVxtRS56ffb25hkMky 0bJoXQzRTng6gvAKVMqslpqIqIDpMq25xZ3/qy55VU7z/Jji4GvDjQwxdJLMNu8Q/qIE 2Qyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XxETGuhhBQo6mApLsduj7FC9ZSriYQJnVDPgySwv8KY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=EPNxWeLGiaMHlWi88nq6ZPZqJ7dvTMLn1e61Vhhi2I0NtIVAiHVAvNWJ7YWsaa21KC aNRPzzRMvYFueSNO1SqnU/6DPDsY8g6gTvSLahHk0atxxHBwQ0RrEU2HfX+Ne7NVraVt JFsjks+e6jZq1aNPzr4rYfJ3jFtA92UlF/3oPoXWaTac7/0ab8zjMYTwt66dfLAxi29S 4WcwwoJhM3aGm3OnYRNhaxwkD1HCRiiZYZ2MrgNiuufBvwILNZT7Vcbgkdn4RKk45isb raIU2TlkKaB5ncio+XqTsQJw61JjL0ReIAHc+sJ0OOiybj74oZQ9lbT7bclYUpCJzhXE T4Lg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FsPkBAIv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 q12-20020a05620a038c00b00787b4590845si7967114qkm.107.2024.03.12.11.40.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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=FsPkBAIv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71C-0003T6-1q; Tue, 12 Mar 2024 14:38:30 -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 1rk70z-0003Mh-Ne for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70x-0000cL-0j for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-41329b6286bso14727815e9.0 for ; Tue, 12 Mar 2024 11:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268693; x=1710873493; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XxETGuhhBQo6mApLsduj7FC9ZSriYQJnVDPgySwv8KY=; b=FsPkBAIvLRzG7OfBAwYq7BywGOs4oQkJxpOec3xQdU+r7w9IW6pnoXrPZi8UfhD/kR rC9WBfyLpbebc8vANlQzDRJwV7DL7PGDqkiPNcsOCzJ9Kf9gevymKm3ZM7yrYKXW3h1e zfPY9RzR/j2P7YT/PMvkIyP+cXD5qtUUyNAGygsgYpgwhEXia0sVajy3/2mfDp+13H1E XJTNC4is7ehzUG7dLRw4RFVLmn+X7VRo23lPymojV8A0Sa1yAXPEKTqxQ8R7Mtgq34kt zwmEiiJZZQL9TV5Q1sUdPRz6PsGBPH82UW23W6lTUBOZ8MMv7YNl+UKqmK+/+l6hW7AJ YUPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268693; x=1710873493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XxETGuhhBQo6mApLsduj7FC9ZSriYQJnVDPgySwv8KY=; b=ljKhcpj6spaEvpiFP2Klq7QuaNYMF7J1iUscM/GdcVXjnsD5QswaLO28zs9/TlNxFE Sycf49h9Bu5E1hmfYGsmOchL1/yDBpzKKDjL4TzgDjjFjFEkvSx9eqqUYIKz7+aD3BYP +RRuZxDqZi7zK2FuHsx85DOUKv9G76wtZdq9HIYX2g/uycjT/b3jzhGcACwF3YWQjeCF 0lQIu2ZRhGe9GOs8Qa0GwJtpfBgtL79hDYXEjHr+5/o8/4o8IQwPUUjHwYXqNUzPFi35 lAHXUHDvYv8M4uyvoznAE0h5yjZ5TXhc2x/tin/0jlF8I2T2sgTKiud2UiQvv52nNf9y +5ew== X-Gm-Message-State: AOJu0YyITBebTpbrR6rJA6sEI9CU77Qsz98PEw6uaF1PNXI7D74QGq/X 8wkqMocX6UPxg1cHktKu5WabzFgOeueipRB3LMv+SARtQlHvKJLdMeIEFCVrVlCyQy/gJAHbsiI D X-Received: by 2002:a05:600c:4708:b0:413:2958:e323 with SMTP id v8-20020a05600c470800b004132958e323mr798783wmo.10.1710268693246; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 4/7] hw/misc/pca9554: Correct error check bounds in get/set pin functions Date: Tue, 12 Mar 2024 18:38:07 +0000 Message-Id: <20240312183810.557768-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In pca9554_get_pin() and pca9554_set_pin(), we try to detect an incorrect pin value, but we get the condition wrong, using ">" when ">=" was intended. This has no actual effect, because in pca9554_initfn() we use the correct test when creating the properties and so we'll never be called with an out of range value. However, Coverity complains about the mismatch between the check and the later use of the pin value in a shift operation. Use the correct condition. Resolves: Coverity CID 1534917 Signed-off-by: Peter Maydell --- hw/misc/pca9554.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/misc/pca9554.c b/hw/misc/pca9554.c index 778b32e4430..5e31696797d 100644 --- a/hw/misc/pca9554.c +++ b/hw/misc/pca9554.c @@ -160,7 +160,7 @@ static void pca9554_get_pin(Object *obj, Visitor *v, const char *name, error_setg(errp, "%s: error reading %s", __func__, name); return; } - if (pin < 0 || pin > PCA9554_PIN_COUNT) { + if (pin < 0 || pin >= PCA9554_PIN_COUNT) { error_setg(errp, "%s invalid pin %s", __func__, name); return; } @@ -187,7 +187,7 @@ static void pca9554_set_pin(Object *obj, Visitor *v, const char *name, error_setg(errp, "%s: error reading %s", __func__, name); return; } - if (pin < 0 || pin > PCA9554_PIN_COUNT) { + if (pin < 0 || pin >= PCA9554_PIN_COUNT) { error_setg(errp, "%s invalid pin %s", __func__, name); return; } From patchwork Tue Mar 12 18:38:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779773 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2168548wrt; Tue, 12 Mar 2024 11:40:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5YR9MxqTM7nikqDmvxou9/NCPz7bKqWpIm+JhqRBRlL1LbqJmoqCmaUknli0YUDtz1L+2/HIQ2lIpx1PkHgsd X-Google-Smtp-Source: AGHT+IEBWQ93xxq8i+6IHsbBflqNZW6h52Bo0pQMh+B3jaXQmpXL7rF2ddVdsRikFipalPZ5GUri X-Received: by 2002:a05:6830:13c1:b0:6e4:dbcc:d36c with SMTP id e1-20020a05683013c100b006e4dbccd36cmr1012251otq.18.1710268836842; Tue, 12 Mar 2024 11:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268836; cv=none; d=google.com; s=arc-20160816; b=uzIXlYn3hptggE0tEIOwZQ5eHHgkmgG8CRvC385LoonQtn/NrilcqP8ipDw2evtUqt wILSAC3Bm6S5i/dVK0AtAkC9f+lDrXx0L7TfRqAhkb09tYXjqWF6BWS9/LxjV6X5SUOm n9oN2CwOYHM+ZwenQ9UDX0JffaGqElTcWTI9BRDZS0by63IuqsngqSyF/hW3UQp4BAfk MkLrWrWx2so7qP3gAnP6YdwP9foX1noNDAZVmwQBQ0qYQAj57LWC9XG0CeEIfDVXL4bU rqv6KvDmvA+D9p2VIydHLHieaTZA+7hVQWjDnQZNNFt+q33ogWuZhO26KVTyc7rYjzaf UdfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rNmtdgrS8nqQbHwAjbW+CEcSMsj64qvynMqUvuKu6rE=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=AhQl6yS74aCTJkqF6zTaQgwp+NimgpSxs7jsA3vtfa68KRuxVO82W0p0MVOKXTrXC9 prFmWb0CTSk7dZmrl+8vZlNp0TDfSH8wydacF8vGF8zN0LF8OtWJk7MaKdwHtmBJ53ee aC4zdy+6+nYIRou1/sbtoF8u4kiNgro+CmNb8nLyuXxsgNFptvgaRlEsOdOr5c0UUQg/ ItHUo9JVj45xnnnjXV7s2Rd0chfYZDwMbLN4fAQIIaFBQTLFMCWEIwAppNu5VU2KT6YP 0QABbBppcUUX5LgjG+iKLBwvYvMk+RRLl+ChvxxsA8un30beoSV/eafRfInN8piqW3Fa SGzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PVPqJ4/P"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 xz13-20020a05620a5e0d00b007884e44a655si7911128qkn.682.2024.03.12.11.40.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:40:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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="PVPqJ4/P"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71C-0003Tx-5p; Tue, 12 Mar 2024 14:38:30 -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 1rk70z-0003Mb-14 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70w-0000cN-VT for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:16 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41329b6286bso14727845e9.0 for ; Tue, 12 Mar 2024 11:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268693; x=1710873493; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rNmtdgrS8nqQbHwAjbW+CEcSMsj64qvynMqUvuKu6rE=; b=PVPqJ4/PF7J4rRdwOH7lbeGROHnwBpYnv9wFwIjeXrLyCx4LQvk6ZYO/p4M9NYS+/9 cmkEpiNxF+RQkXCnFGT0wLmkdE061k9+/+pGFlh3rkk48xMsb1AThLhoj6+SmVDjog2c 2/wgVkHakY3Og8t85uu34sZJtVNKStK5CQ9ftT8mpcSnft53mjZ77TOuF5mJlJAMzlmr FZqVxS8fckopWM2SkKUShRuIccxA7R+62Alu3AuiSCA/XQEmD/+pQSI4WhlaYeS5xQ9c ds73mbSC65uZl0QH2p0LZdV2VELEQbRC2pIlmOGMPTTXVNU86cRVT3fOlDuZwOgGr20H OKwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268693; x=1710873493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rNmtdgrS8nqQbHwAjbW+CEcSMsj64qvynMqUvuKu6rE=; b=cJ8ArTJXvUBGvmYMitjzKR3GztG17vTe/MA7GrNWYX7UHMAXpiZIrC8nq8tcVUaj9+ 2pj1HnJ9WjInJJ9yRGdoVqEFX4pOuQ1ekKzZjXK0CTDhRlvhiCh638gjbUiK67W+Wp1y lNMsLel0ag/neMn9uc/ttTx6IWzXFPVeHsSAxKXJHJkmvqQ6Yx79q3CEKlkr8vFQmbHR jnmUaBmTpdgOKFNEj/d88cQvABwT9lmerIVvhf9LRVIyVC4e/xAgycxRLHqFd7g5WYXj MYjYCEW6dubyY+4GVLkpug9KgwoYzDf0z1ri5O5DUPtXrAaYBuhLLJPOYKpPGRNnlYDP l96g== X-Gm-Message-State: AOJu0YzJKppr4XVm5sOTEH5ep/Mrf+7bYAV/z5S+PJXmB3wAQ+O9x0pP tDQwBqb2H1a3GEi3eHXnCQTeZglhXWwREdZA90SJeiz+kgOqyhSCCOcCXp58zqnXK4K4g6EICB2 n X-Received: by 2002:a05:600c:1f07:b0:413:1f58:9d15 with SMTP id bd7-20020a05600c1f0700b004131f589d15mr811421wmb.7.1710268693598; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 5/7] hw/nvram/mac_nvram: Report failure to write data Date: Tue, 12 Mar 2024 18:38:08 +0000 Message-Id: <20240312183810.557768-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There's no way for the macio_nvram device to report failure to write data, but we can at least report it to the user with error_report() as we do in other devices like xlnx-efuse. Spotted by Coverity. Resolves: Coverity CID 1507628 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- hw/nvram/mac_nvram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c index 5f9d16fb3e3..59277fbc776 100644 --- a/hw/nvram/mac_nvram.c +++ b/hw/nvram/mac_nvram.c @@ -48,7 +48,10 @@ static void macio_nvram_writeb(void *opaque, hwaddr addr, trace_macio_nvram_write(addr, value); s->data[addr] = value; if (s->blk) { - blk_pwrite(s->blk, addr, 1, &s->data[addr], 0); + if (blk_pwrite(s->blk, addr, 1, &s->data[addr], 0) < 0) { + error_report("%s: write of NVRAM data to backing store failed", + blk_name(s->blk)); + } } } From patchwork Tue Mar 12 18:38:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779772 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2168363wrt; Tue, 12 Mar 2024 11:40:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnnB/iIcQcRNHZRsCYNh+GX+HS5Wl7IRV+Cwm500u4cWcpqEO1aW6J5o+d1Wv2Vp+BgtrgkxJ8siE8HdV6icv1 X-Google-Smtp-Source: AGHT+IF5O6j+06Rdp5FwRlgIRlf5JCb1u1RrBDl4I1xCM3WkhdDMVw40/94s/H6lhmUNdwMmlyzB X-Received: by 2002:a05:620a:1998:b0:789:c78f:954a with SMTP id bm24-20020a05620a199800b00789c78f954amr84079qkb.76.1710268810089; Tue, 12 Mar 2024 11:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268810; cv=none; d=google.com; s=arc-20160816; b=KOcpPH8f1VgLid0CJH72RujmzjZwDtY5VN7bwDcBeYBshOkN4RnYPdK297CoanoL9A hIa9Aewiub54sOaa2+30DKWEi0Snd+j1d9SFZI5ot5BPL3D3u/QmQv9A/bYq4SwF2Bo0 PrOEW4yX7GcFuCY4x/PjepgwiizyJD0RQix0scfzbCYAx98ztajELXLvQL0x+QraiT1u E2cpUIWIBHskTqIU8vi3OjRvFiiWDCzxh7OoySoI8V+GwYBQvtCeSGC219VzjvAXrnUD J6/t17549kdLWb8JILqGMVCPPYBWRrJCVKCqm1ZoQVetitBynDuCqe2yaeZ+q2QjIPBP YRsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GSQdrQ1n3f4UDvq+g8f2/lXlL51/iuaHiFWXMRnbpHk=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=GJIceQsSgX6zWCVP42EfMq932TQ7EvYm+qrpEkkvEVXlzQ28ZgxF0a87M8In6hU0pz Io77LfZQWFoT8ziOj4fhk2x58VzPhmZQN56jQc56FmWONycbL8e8E6Ohh+OHYrtuVoIW 0OhlHWvXzadYpkeApjUYiHEZazbpshxefRg5r15xIsOB49MzenYR1Sn2IjFHESiDLFb5 im5Z4kKn7K/+/D1bV5BgtzCwWdfa/lPvME8PmqMgAeIZrTMNcG6lk6ze2MCeFpmtXIva UqOW6yay/VgJA0ayJ9yIIgHtrjhfO0D3jP5m4AusEhkbDEw6ulSZgjEbFReFVM9VOmb5 1Ibg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yWuGgLDH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 wi22-20020a05620a571600b0078842187dc3si7967839qkn.669.2024.03.12.11.40.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:40:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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=yWuGgLDH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71E-0003Xa-3z; Tue, 12 Mar 2024 14:38:32 -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 1rk710-0003N2-4r for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:18 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70x-0000cR-7b for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-413e613316cso2016935e9.1 for ; Tue, 12 Mar 2024 11:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268694; x=1710873494; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GSQdrQ1n3f4UDvq+g8f2/lXlL51/iuaHiFWXMRnbpHk=; b=yWuGgLDH0SG/GSl56ftf3mrv1jLw4be21RNZYFnEX/v5FaOnAalPe2Wdt5FY7B11KW LiDkV6j3pxZ2Te6Je1lH43F8d9jkfDI1Z63D5Z8HWw3UocL0Uk3SQZkd7umOjBl6rLYX 8XRkmOHvrJA/NYy3hLiw+QxS1NbugtREW4l7+3D5KDh8sFKts6sw17q7ZKWWy4yvlCxP IX+ePkzBUNZ3dl5PxLftRU3xRrEDD7FciIUpHBvlwmslJtvXw6z1pye2Uuetsi3HeimY 91EUKw4UFHPheWTbgZWscHmaOGSQJ4fqg8BFabYIR7ex5LTDE3GUDtvMpmEdXAEqkEdr FX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268694; x=1710873494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GSQdrQ1n3f4UDvq+g8f2/lXlL51/iuaHiFWXMRnbpHk=; b=Ug4pAfyFWQ/dvgKkn1GZVnHY4rrw6mA3sL4gUyQMrKGF7VfBgIbXOEpGiSgz9Y55Yb XseWqE8VxWv36TIkS8g5VrPzRjbVy0S+RX4P0oSqksE8/eayKbsGTy01cYW0fCyBKbVZ Jrqlc8vVh1WpN+wGEfy6oNHSkZ04vURAnk169kgtveFeGBv7uFbBRR44KEGDbwyg0j8h za9ul227IyZbpNoIrVqfhJTC1PTdGtNxYrSSY7esbdeYfhBtQvctyrVRTqB9+8fsEm6C QUNV3gMLQ5lKaTfUi00pNOdKYzG4+ZIgt8DmIghzihJ7mn01Km03a9RXhse6oGFl4oF1 mjUA== X-Gm-Message-State: AOJu0YyH1dLB/n7OJG3LQNsXSThKD/vU5rp5GI22b9zsvugbjA+m7V+0 IajuR0feHoHCP3kEFHyu8k/jfNq7FFou9U3UjEpevVbuGZjiKXxSoWJ97NjNCUg11dqO1aYQexd p X-Received: by 2002:a05:600c:458d:b0:413:2779:8e29 with SMTP id r13-20020a05600c458d00b0041327798e29mr5515991wmo.19.1710268693958; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 6/7] tests/unit/test-throttle: Avoid unintended integer division Date: Tue, 12 Mar 2024 18:38:09 +0000 Message-Id: <20240312183810.557768-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In test_compute_wait() we do double units = bkt.max / 10; which does an integer division and then assigns it to a double variable, and similarly later on in the expression for an assertion. Use 10.0 so that we do a floating point division and calculate the exact value, rather than doing an integer division. Spotted by Coverity. Resolves: Coverity CID 1432564 Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth --- tests/unit/test-throttle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c index 2146cfacd36..24032a02667 100644 --- a/tests/unit/test-throttle.c +++ b/tests/unit/test-throttle.c @@ -127,13 +127,13 @@ static void test_compute_wait(void) bkt.avg = 10; bkt.max = 200; for (i = 0; i < 22; i++) { - double units = bkt.max / 10; + double units = bkt.max / 10.0; bkt.level += units; bkt.burst_level += units; throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 10); wait = throttle_compute_wait(&bkt); g_assert(double_cmp(bkt.burst_level, 0)); - g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10)); + g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10.0)); /* We can do bursts for the 2 seconds we have configured in * burst_length. We have 100 extra milliseconds of burst * because bkt.level has been leaking during this time. From patchwork Tue Mar 12 18:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779769 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2168040wrt; Tue, 12 Mar 2024 11:39:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+4CxLjpW5xIYJHXSaxt/V+XUZoVDlnmG6b7jOOZqgWmkT2pWp82F8TCK6wTR0+Sr+4qKXHVa4HAqfpDQ34ffN X-Google-Smtp-Source: AGHT+IHt/Cbm4qH+YKF9dSC1jNYWMfqLahGLzW8I3WvuvG3fl5DhT7XtsM5ctFPW8hgNGFA1TEqc X-Received: by 2002:a05:620a:1664:b0:788:20d8:f2e6 with SMTP id d4-20020a05620a166400b0078820d8f2e6mr4383337qko.18.1710268754339; Tue, 12 Mar 2024 11:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268754; cv=none; d=google.com; s=arc-20160816; b=LB6JEZv42we7TZvNCjHCujMqNIcx1jnP/Fed7fpIvU1JBGm3YisNY6ekeEBFQog5n6 3zIGLxWYDF4/dExHZOjKmeRaIetVcN1hl5OY+osmasC4rU5n+51BCYHVDIGqEn1+i9gB ufpJO09t03IU+r9b40AATz86g6VtALTtfTViOu6Jq/OCApn85HL0GPGWVoG7aGSzs9Zg Bn27eN2XCdQICXiUyHPRFP5HlWyOmdMSIWC553dCJynWFt2KWpdTbIHijYmG1N6I9VsB pLClSoEK+WhhdUij6l3E1OtuzRB3SALkphKKssdlUmzjtednSf0k7cIKigLhHcqoYVty 33nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=F5TgssMb195QO0ZRrXOaRa+rjmUvH1NGzSH3Wll6Fnw=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=xUgQ7HC6DAZe14Oco3Wz/wFyG0qhe7K7bk91PHLG1hk32iphEVgzXK4YxX9nzsMvV+ v8ANgAU/DKuvLAH3ws23iLO7sh+3DBAVaLv+frPechTr33VPdT4n3TTb5Hln94yCaCax 9zprPyq43tNc0e9VMyM0xpYLf582sQ7gLyuKUFRAjpa/O6RbOwdjLi8kqabCPv3q5QY0 Vev3AbbUNwM9hN2CJj36lRdxioQ7xxSYfFOm1EKCXi//5HYuUeNmRqlbPThIkkNe2ciy 3F3FhL3U2ru/oR81eTC92wpTZKg5RHD9tO1tSX4W54WbjvgBX90ICi/UyAOQHlSzSgxf a+cw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMfWKLE5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 l5-20020a05620a210500b0078834291811si7813385qkl.278.2024.03.12.11.39.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+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=hMfWKLE5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+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 1rk71D-0003Wo-Jz; Tue, 12 Mar 2024 14:38:31 -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 1rk710-0003N6-8A for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:19 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70x-0000cW-MO for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:18 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4133100bccdso9412895e9.0 for ; Tue, 12 Mar 2024 11:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268694; x=1710873494; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=F5TgssMb195QO0ZRrXOaRa+rjmUvH1NGzSH3Wll6Fnw=; b=hMfWKLE5AxQwmn41SKLaRp/xO5wwJwTHhSFHLkoSTBACEurGgfsK4OSWP2/WQDzj/o xFS8YMg/lqbQ0mYGy9pc3zSvStea9TDx6SwbAcT4ITTevnm0mo50YTNRnQVzzC7cjmGI j1eU5RU3MJZcU/GKls4+CsukvBeT23fuh+2SV7JSQ8pl13DhWOvZvVF0AgXnwZsdh2He W4xQa2vZsqbtkn18sOuIONjTUbYvLC4q4PdvXFIJWOWHzTwQlcK2ItNR+TlOQFJMukz6 ERWBb+dAAMu5xeQCSkWJTvDfWHdwN903B2UHSppZv6a4ARLBEvWGQvvjX3c2GwU5i18R gF6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268694; x=1710873494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F5TgssMb195QO0ZRrXOaRa+rjmUvH1NGzSH3Wll6Fnw=; b=Kj0/XY/asZPKMozyFlJmseRST33MJv4+dN5VVGTo0tbnVu1d50yr2QU6XN9eqG7hyO cl4Zzc0VS7ixae2TJla8qEvGSlHKAh1i4CnSQVdM2MkpPaCAxo5FJ1VxuF0swKrq1m2j kP4har9DK9kzUFGVOrpxt9d49ghglLqlsyrIUAWDqi74xt5/KiY+F8mV3OVLgYZYK8ep N1kK+d5dK7TKOp78sS+eK5hZPkZEKrH87C5FmsZpXAVW2xQWKNBap8mTCjDVcKig/Olb 7Rm+f8iJH0n8qrk2ePWEwHWBoCJx1HnCLg5ubGs8b5bWgEOW3hZU7ht4jRZvSc5sQR8j ofMQ== X-Gm-Message-State: AOJu0YwesTITl9eR1QERaosJTmhSZv/gEMrn1lpLgWdC39lRU6r9tJzF 6SMPUtV6s6LRkk4WQTHrNxeKNH88ZuqGa0RvUldGEdf19nSO7kvi8oNULClyIDNqIFlxpQEVGjn 7 X-Received: by 2002:a05:600c:1d12:b0:413:2ea4:1731 with SMTP id l18-20020a05600c1d1200b004132ea41731mr3970648wms.15.1710268694341; Tue, 12 Mar 2024 11:38:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 7/7] tests/qtest/libqtest.c: Check for g_setenv() failure Date: Tue, 12 Mar 2024 18:38:10 +0000 Message-Id: <20240312183810.557768-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Coverity points out that g_setenv() can fail and we don't check for this in qtest_inproc_init(). In practice this will only fail if a memory allocation failed in setenv() or if the caller passed an invalid architecture name (e.g. one with an '=' in it), so rather than requiring the callsite to check for failure, make g_setenv() failure fatal here, similarly to what we did in commit aca68d95c515. Resolves: Coverity CID 1497485 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/libqtest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index f33a2108610..d8f80d335e7 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1814,7 +1814,11 @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, * way, qtest_get_arch works for inproc qtest. */ gchar *bin_path = g_strconcat("/qemu-system-", arch, NULL); - g_setenv("QTEST_QEMU_BINARY", bin_path, 0); + if (!g_setenv("QTEST_QEMU_BINARY", bin_path, 0)) { + fprintf(stderr, + "Could not set environment variable QTEST_QEMU_BINARY\n"); + exit(1); + } g_free(bin_path); return qts;