From patchwork Wed Jul 31 21:24:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 815674 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp923028wrs; Wed, 31 Jul 2024 14:26:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkYPGQ3ld8AAVbDPBkW6LzHUjZL22Xcjx74h+3eoYkQvpnTH1hQoRd14e7oTOD2nXcuunuvMVvakYW0A5yb33D X-Google-Smtp-Source: AGHT+IEvZxytE9YDUz6MpF6vzJnpI1XGmlZh8DWEW1klZMRlkFVIzfnL7ohVwPC7XcAbaeqbK2GF X-Received: by 2002:ac8:7d12:0:b0:447:f292:e4b5 with SMTP id d75a77b69052e-450372a8547mr119775051cf.9.1722461173721; Wed, 31 Jul 2024 14:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722461173; cv=none; d=google.com; s=arc-20160816; b=iy4hF/aqBJXIXGfNuUW+IiCzhKIVcNxmucTQbTt4uZI0XNVE9WWlyvAc/E1rFLXmTD nR1n9lRDL+xk9CwQaleJuHv5a7VSniGzkW0DJrBK1mXNNubv8CzO0qjrTpuoSndxqCbT 9kM1lsiSTV+UZ9RVONjmd+RYWprAE0OdfonjTiPs28bUPfYqb4U6Tsp2Ek5qGz9zzWwE fTNQLJQqnxNtPNuU+Lfpf2zMnX0KDv9srXA7imNQBoJwzVLABD7Mig+Ks4r4FK1InVSr djo1bfOom4BGUzWKX9JVhay99s2oZF4zWXW+BsVEatEBgB87eGwAMc20cdHdAiaClIST g+DA== 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:cc:to :from:dkim-signature; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; fh=ADixSG9ElpvNvhE8iTAdMizg2dtG0TYj8XBNEB0E9kY=; b=a04hwe09oYy2f79KlqmTExuX0JcfMbsgkGrxIlHz4Bb8pUjAvsbFHjlN+HlHldqKbR GuEzXb/BlLqe0mOeZGlwduWmRgqffHsKDdu1OLW8C2NCs5OcFJdhcMVCxnTugO5uTH2A vgEh2GRNdB5hEswHx9NPP4IXhCbg50/uezESKDMFBEsAfjiF6DMmwU1s7E9JjlNQLfFb vnyA923Rl54gBqiSK4XQwQAdTb/Ak4XB1O8Cy5B/kuYPhWHska1XSrBVliW4TL/KRXUp 1mZfuJwrvkzSAKkArfISyFod+sj/vrOz41beC791Y8vr6K6lxwrDC20aeGbO6VCDC/dl xUEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rDvtgVCK; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44fe81fe792si168438101cf.384.2024.07.31.14.26.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jul 2024 14:26:13 -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=rDvtgVCK; 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; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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, ADMADescr *dscr) static void sdhci_do_adma(SDHCIState *s) { - unsigned int begin, length; - const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK; - const MemTxAttrs attrs = { .memory = true }; - ADMADescr dscr = {}; - MemTxResult res; - int i; - if (s->trnmod & SDHC_TRNS_BLK_CNT_EN && !s->blkcnt) { /* Stop Multiple Transfer */ sdhci_end_transfer(s); return; } - for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { + for (int i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { + unsigned int begin, length; + const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK; + const MemTxAttrs attrs = { .memory = true }; + ADMADescr dscr = { }; + MemTxResult res; + s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH; get_adma_description(s, &dscr);