From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8684C433F5 for ; Sun, 26 Sep 2021 01:49:30 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BCF460184 for ; Sun, 26 Sep 2021 01:49:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3BCF460184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 10B758362C; Sun, 26 Sep 2021 03:47:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="frk6nknY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9BC3C835FF; Sun, 26 Sep 2021 03:45:29 +0200 (CEST) Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BB250835EF for ; Sun, 26 Sep 2021 03:44:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oo1-xc29.google.com with SMTP id m14-20020a4ad50e000000b002912a944a47so4658073oos.12 for ; Sat, 25 Sep 2021 18:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RDVYJUsA0iqz879i6oOIRCFDQ3oDzoVKxU+AnTSX1vg=; b=frk6nknYT61sqmb+SPPSQYP3AjRnKZ66T8PVfgVLQS6EbbBxRtIFpG7MBtS0YUnLrl 3fvAtwcKtnhUh4TWdzj0rsypcfKiVuegLLEllbQ3DG5T9Yiq6ZRri52A5GPNoukH9oPx b3T7KfAyAIyXvQgpPdu7W1V2N1N1BAQw2eDgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RDVYJUsA0iqz879i6oOIRCFDQ3oDzoVKxU+AnTSX1vg=; b=rfCmEH8QZAGnDg7JfMJzu9bYN6NEva8vmW4CVB1kUY/dMqppmEbcOt8ynykgmuQU2L vY78o6Ox0sROCdYNv8ti1/fUnsB9D2WZ2b3qgn0Bd3yY7Ead2pGYN6oD1roRvWsh/e+T hZC2HLf2c2qo9Fv+JGwzCSDeWbS/4z2aJomT+Bh+OjaFrUg4ANWOVyJmqOwWDA+XPlir WutTeKkEhipqWXxAwJUet8XIuYPXakh6n9A+WKwBw6WgNgR6439LTJo5fsGyizOJs8M1 Yzf9S61QQV3WRQImrTFbP/keZzQioYRr+J84vzqAv9gKstE0PNzO+4rXbuxnzG7tc3kH CuGQ== X-Gm-Message-State: AOAM532QTD7PPSIHmyYIl/MyzLTr33lI7mYs0iAX3LqUYKFoGyf6+2Qg 7YYg4yQlrHZNxNqfRhsi2lYTx0PDy6gxNA== X-Google-Smtp-Source: ABdhPJzQdFEkkoNRpJMZgle0fFrx4EH8OVtsIDKzHnIfQg9c5S3uvXYf6np5kxBcjp13UC+QL+4Lnw== X-Received: by 2002:a4a:de57:: with SMTP id z23mr2161921oot.70.1632620657241; Sat, 25 Sep 2021 18:44:17 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id c18sm330378otr.72.2021.09.25.18.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Sep 2021 18:44:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alexandru Gagniuc , Andre Przywara , Rasmus Villemoes , Robert Marko , Masahiro Yamada , Tom Rini , Simon Glass , Joe Hershberger , Marek Vasut Subject: [PATCH v5 27/29] image: Reduce variable scope in boot_get_fdt() Date: Sat, 25 Sep 2021 19:43:40 -0600 Message-Id: <20210926014342.127913-21-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog In-Reply-To: <20210926014342.127913-1-sjg@chromium.org> References: <20210926014342.127913-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Move the variables declarations to where they are needed, to reduce the number of #ifdefs needed. Signed-off-by: Simon Glass --- (no changes since v1) common/image-fdt.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/common/image-fdt.c b/common/image-fdt.c index cf87e455230..78c1e5b1a9a 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -276,21 +276,10 @@ error: int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, bootm_headers_t *images, char **of_flat_tree, ulong *of_size) { -#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT) - const image_header_t *fdt_hdr; - ulong load, load_end; - ulong image_start, image_data, image_end; -#endif ulong img_addr; ulong fdt_addr; char *fdt_blob = NULL; void *buf; -#if CONFIG_IS_ENABLED(FIT) - const char *fit_uname_config = images->fit_uname_cfg; - const char *fit_uname_fdt = NULL; - ulong default_addr; - int fdt_noffset; -#endif const char *select = NULL; *of_flat_tree = NULL; @@ -304,6 +293,11 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, select = argv[2]; if (select || genimg_has_config(images)) { #if CONFIG_IS_ENABLED(FIT) + const char *fit_uname_config = images->fit_uname_cfg; + const char *fit_uname_fdt = NULL; + ulong default_addr; + int fdt_noffset; + if (select) { /* * If the FDT blob comes from the FIT image and the @@ -359,7 +353,11 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, buf = map_sysmem(fdt_addr, 0); switch (genimg_get_format(buf)) { #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT) - case IMAGE_FORMAT_LEGACY: + case IMAGE_FORMAT_LEGACY: { + const image_header_t *fdt_hdr; + ulong load, load_end; + ulong image_start, image_data, image_end; + /* verify fdt_addr points to a valid image header */ printf("## Flattened Device Tree from Legacy Image at %08lx\n", fdt_addr); @@ -398,6 +396,7 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, fdt_addr = load; break; + } #endif case IMAGE_FORMAT_FIT: /* -- 2.33.0.685.g46640cef36-goog