From patchwork Tue Jul 30 09:40: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: 815298 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp215929wrs; Tue, 30 Jul 2024 02:44:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvmuaVXz+m1J8EB19sgzOvD4AThp0b7eHtUniutHe8k3tFukxKoYeYc7Fz3oLyw2Qk49a1FGZ8bnV/UMU+Apif X-Google-Smtp-Source: AGHT+IFu1FuK8N7pckgCpIeiknqJG0ZsCMNDDC+CrIDsk5yrsx74cXRf0NI1CegG6+GfIcSSRK4k X-Received: by 2002:a05:620a:4152:b0:7a1:df6f:3620 with SMTP id af79cd13be357-7a1e524147fmr1507105185a.22.1722332674359; Tue, 30 Jul 2024 02:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722332674; cv=none; d=google.com; s=arc-20160816; b=GP/aXLbMT04nJ2bR3zejuLR6iy31K7CYhRUcmFeMitfqtYIjOnrbbZzdYb7UGdF+Dn IlSwrh79/4rWkszwOq3sBdg9PQNsPQ2uCouQBxOGVUMpJQZYlKlz2q2p5NnoUALQvg0y MMOnM7gXvpeppoa3wb2aNoD5AQhnY5BcldvuO0EHLoHSPMuWrb0H2TUrTpZWmKQpZsqy QBdNaAk6uDSbRswYe1U6yfpcZ9dwY5nLNvrWHCJLdDHTFgSgdWzCukSA1pYcVLfTBDDQ Ch5Mgui7g0o8qIuMwjyUtXbNwcqL0Y6p7ldhG6MM1MkysPzo15CGsnuJKjke7l/c+6z6 rKHg== 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=720J6Fnn90LCfDNzvb5BOYvjsNm2pz0pQOgxMBS+Hs0=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=yinOBBuA81wcwISb7cgqFCH1ZOm2bPVDjIATCsWlGcy260XXE+gK/wfz+Eg4AMwIIb 7rTdi74qCOQf0k/gRfS6gioc9jIptTGwyNR8FgInDQxrCwHV+sYXlnDmqHsJV2R3bijZ /XeKlJds7PF8AkBi6erJha9mjTd495wXImsa9pHtZBJkY46HtsHdi/J5Zcs9rYD6CFpz jOKS4MTvzoQkzB1q56TQmJYrXeQWcCJh1ITdnYnzl530L/oOhS01JOndqJUnZYP57+w8 0x88WkPIrpPrjlsqLXX4Y5MrmQqSiBuClpJBhSvukhZKxB4uQosHuinTweLp5GCNUpeb uBng==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jjASWuXj; 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 af79cd13be357-7a1d739bc72si1229560585a.98.2024.07.30.02.44.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jul 2024 02:44:34 -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=jjASWuXj; 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 1sYjLR-00041p-3V; Tue, 30 Jul 2024 05:40:37 -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 1sYjLM-0003jL-NZ for qemu-devel@nongnu.org; Tue, 30 Jul 2024 05:40:32 -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 1sYjLK-0000aW-EY for qemu-devel@nongnu.org; Tue, 30 Jul 2024 05:40:32 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4281d812d3eso19863145e9.3 for ; Tue, 30 Jul 2024 02:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722332429; x=1722937229; 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=720J6Fnn90LCfDNzvb5BOYvjsNm2pz0pQOgxMBS+Hs0=; b=jjASWuXjK6MJvGeTE7ennWdmCRDst+YkyOvgKIGip+pLtW4cm1GvfYsJuZVo4qUqZx G4gAfPtn4BpxhSvnNRrCnCKpb1aB58d0NFAlZdQDhyj5ORp25GzmktYu9BAHahT9H1JV GUecfskkf34nRdrCtFV/6P0HTCKDhs9MbcY7JVFxKbbrxyun2jmP81bxCIZjtgMknupb fo4VLZ0VpF9ygSojVjMlZx07sdwv8qgaxGELuLJERj+Xt8df+WU7lk70SeJsmpV4H9ys 6v5k+WD+sURzX1k16hXwNizuTE9yBILZ+qyXHtU1oNer4kzN1d0WTqtZosoUOicBj91Q nK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722332429; x=1722937229; 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=720J6Fnn90LCfDNzvb5BOYvjsNm2pz0pQOgxMBS+Hs0=; b=BUq4QS/Fzy1G61Eulu+UZ/geZatWvn7uwu71usD1NaQN8STDZ/SBWsdUP74Of+hVPf zL48ivAdZaQRPyczKLJx/s6VRUgDDXJd342fPI5IHOa1YO1F72QYWYevlz+f3cdUMez0 EqMpsOfJNjGFlLtn2NwU7qthr0xpf96lHmgtCdtnwFct0oyHOhd5HoTd3mrD2tPbl0KV hAPhZe38lGrn0/Q/HNlKS9EOsak2RMuDWCGB6l0OOtRdhWx9wuyORK3CUtt4ZRg3leBY 3Q77ArLQFLhwRuOdcn1MoTyINAM9TjeUWuWrmn0QbRVrw5ghoI2wYtUf2WdesVf7Dqtx Jinw== X-Gm-Message-State: AOJu0Yxmiwy6L1uMAUdKeK5BXphatzjZz3ztmSX/OcvvT71KZ+tNUUzk 2hAvwaILr10XYT+WuQYbGtKQ8+ouVVK2xWwlXfd6VIdmdEkUnfFiuFfev9aw0fDHeNhyy5hT2zI E X-Received: by 2002:adf:f00c:0:b0:368:7943:8b1f with SMTP id ffacd0b85a97d-36b5d0d0f9dmr8965034f8f.43.1722332428734; Tue, 30 Jul 2024 02:40:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36862549sm14194974f8f.106.2024.07.30.02.40.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 02:40:28 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/21] hw/misc/bcm2835_property: Reduce scope of variables in mbox push function Date: Tue, 30 Jul 2024 10:40:10 +0100 Message-Id: <20240730094020.2758637-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730094020.2758637-1-peter.maydell@linaro.org> References: <20240730094020.2758637-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 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 bcm2835_property_mbox_push(), some variables are defined at function scope but used only in a smaller scope of the function: * tag, bufsize, resplen are used only in the body of the while() loop * tmp is used only for RPI_FWREQ_SET_POWER_STATE (and is badly named) Declare these variables in the scope where they're needed, so the code is easier to read. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240723131029.1159908-5-peter.maydell@linaro.org --- hw/misc/bcm2835_property.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index 443d42a1824..8ca3128f29b 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -25,11 +25,7 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) { - uint32_t tag; - uint32_t bufsize; uint32_t tot_len; - size_t resplen; - uint32_t tmp; /* * Copy the current state of the framebuffer config; we will update @@ -48,10 +44,10 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) /* @(addr + 4) : Buffer response code */ value = s->addr + 8; while (value + 8 <= s->addr + tot_len) { - tag = ldl_le_phys(&s->dma_as, value); - bufsize = ldl_le_phys(&s->dma_as, value + 4); + uint32_t tag = ldl_le_phys(&s->dma_as, value); + uint32_t bufsize = ldl_le_phys(&s->dma_as, value + 4); /* @(value + 8) : Request/response indicator */ - resplen = 0; + size_t resplen = 0; switch (tag) { case RPI_FWREQ_PROPERTY_END: break; @@ -95,13 +91,16 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) resplen = 8; break; case RPI_FWREQ_SET_POWER_STATE: - /* Assume that whatever device they asked for exists, - * and we'll just claim we set it to the desired state + { + /* + * Assume that whatever device they asked for exists, + * and we'll just claim we set it to the desired state. */ - tmp = ldl_le_phys(&s->dma_as, value + 16); - stl_le_phys(&s->dma_as, value + 16, (tmp & 1)); + uint32_t state = ldl_le_phys(&s->dma_as, value + 16); + stl_le_phys(&s->dma_as, value + 16, (state & 1)); resplen = 8; break; + } /* Clocks */