From nobody Sun Nov 24 14:35:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722461174; cv=none; d=zohomail.com; s=zohoarc; b=H6n6HN1tfJh958OWoXWqpSyTxvKb5xELHM5xTaSRwy4L5dDTJJiP64YXQWT4SAuhIDTTOPwe20jxK0l8bH33VHXQL4UP7DGhQGubYfARRssTjWc0XuMEGDD6JF36z0ll2bTQ2T2IGGx3y3seJyoCUwP+8+JF4Uo291nsooyUIsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722461174; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; b=afy5w5WlycxN57mzTHEA+hxArAd0l+KLUuN5LjnCrM0rIETmPINhIjodG5AJAeKItRw0tNCvHZHC2G7nFPHOGGbw70znT+MK9MlVSTSBP4L2d3TxrEgiIM2N06R/b3MMLk611M4HlDhlYWTjIQllK+aNNlwLJgeiPJahfl4yPCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722461174239810.7961321415441; Wed, 31 Jul 2024 14:26:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZGov-0007pq-Rh; Wed, 31 Jul 2024 17:25:17 -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 1sZGou-0007nN-7B for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:16 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZGor-0002AX-Od for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:15 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2f136e23229so46199901fa.1 for ; Wed, 31 Jul 2024 14:25:13 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857d5asm17928671f8f.84.2024.07.31.14.25.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Jul 2024 14:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722461111; x=1723065911; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; b=rDvtgVCKgwsQGA478CUXIzu75jL8QSrmVMfqKRotzBbS/sQvsQdDdyE5Wt8o9voY4r Zb+yT3WKMhFhHnTxo+WJHdku3SPr/By8aArsfFR6FWwT3x5XlNkxC4s28ynW4+iLx8wC Q5BugH45hl/VCRhej8ssh3KtbPbtJGuqQyXseRjeYn+Ajsfti0R2w8Y/EHoRwj4MLSn3 qkNnS1COXWtEA8EPkoQo7UPop68Xh+IwjdtCWMcQp6Na+eMf/dnp3etSbxz/FlI7lEk9 YPXF84DxDLgNglAOaCtvTIfk0XcWxfjz+dJztMJdqArcz30LRazOwtrko9r1B4RdG6g4 x7Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722461111; x=1723065911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; b=bz6lD5TS9Q17+i14b3JhrLzIYN1t3bqC2COH4uPJGlM3kIAATHXSa6hmQENkgoMVTF GxkeCUyQp6gLDvZxFbxjBLJD7uJeQlHlm2KgoAic4NRnlYdnPi5ynd4ZRCRVD2Sok7vv ja91Hd2SAF5BgpxpfP98f3lbJlqqmooNJ6v/kGkjhQvvmcuTCuyp6leewtzM8qbOd7B6 FJpq7gb9faxzqzUhZpTLusdF2GtXfLtjRPjynV6ix+a2GS3u7xffV7lesch3tUkKDkib 470XaBHPDzKI9hRfShYvze9oJisnUhA+ir/91SXX5BO0jGlc3QxzX65LbkFMlgHQuk7J EL5w== X-Gm-Message-State: AOJu0Yy24eOwMfrbpUZV8vb1qZmluNFftW5XPQFLlyvZj94eua56jCPg rRzBohMbWl9bi4dVaCFOT77ZtLpkV+wlQnFjgL74ylGA7Q/YI/zRUJD0RbdzUGGVUguB1pgeCnx 6 X-Google-Smtp-Source: AGHT+IF21v7RXbC4zE2kKVBGAtlj6ogTZmPz2NG8LRoGfLj11Hq+90jT5dDgvIksgMVhMjCINs0qMA== X-Received: by 2002:a2e:3517:0:b0:2ef:2b44:9977 with SMTP id 38308e7fff4ca-2f1531027b6mr3324571fa.18.1722461111245; Wed, 31 Jul 2024 14:25:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH-for-9.1? v2 1/4] hw/sd/sdhci: Reduce variables scope in sdhci_do_adma() Date: Wed, 31 Jul 2024 23:24:58 +0200 Message-ID: <20240731212501.44385-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731212501.44385-1-philmd@linaro.org> References: <20240731212501.44385-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722461175906116600 All variables are only used within the for loop. Declare them within it. In particular this resets 'dscr' on each iteration. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sdhci.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 66b9364e9e..773f2b284b 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -751,20 +751,19 @@ static void get_adma_description(SDHCIState *s, ADMAD= escr *dscr) =20 static void sdhci_do_adma(SDHCIState *s) { - unsigned int begin, length; - const uint16_t block_size =3D s->blksize & BLOCK_SIZE_MASK; - const MemTxAttrs attrs =3D { .memory =3D true }; - ADMADescr dscr =3D {}; - MemTxResult res; - int i; - if (s->trnmod & SDHC_TRNS_BLK_CNT_EN && !s->blkcnt) { /* Stop Multiple Transfer */ sdhci_end_transfer(s); return; } =20 - for (i =3D 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { + for (int i =3D 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { + unsigned int begin, length; + const uint16_t block_size =3D s->blksize & BLOCK_SIZE_MASK; + const MemTxAttrs attrs =3D { .memory =3D true }; + ADMADescr dscr =3D { }; + MemTxResult res; + s->admaerr &=3D ~SDHC_ADMAERR_LENGTH_MISMATCH; =20 get_adma_description(s, &dscr); --=20 2.45.2