From patchwork Mon May 3 23:11:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1473521 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=M7myxERq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FYzSL3bfCz9sCD for ; Tue, 4 May 2021 09:18:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDF3082D5C; Tue, 4 May 2021 01:18:11 +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="M7myxERq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A61D582D23; Tue, 4 May 2021 01:17:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 99ECA82D42 for ; Tue, 4 May 2021 01:12:34 +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-il1-x12c.google.com with SMTP id i22so4894263ila.11 for ; Mon, 03 May 2021 16:12:34 -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=xTvsFlEGSn91usTWdf3RBteup/3pGHiCGEp/ulsXg/8=; b=M7myxERqicIh4D+k2ZfYqu1hJmYkLcmd0GTa6Ta8cX8InYvuc70o55zVVkb4yruQK+ j/yxvoKLkRAKr39ahICzbB7MHcKvEUk1NK5GvPdafKL+AXmfYvEZvH6cYEyQUIEjhe8B 7oxR9aZG95YiEAX/QTNg7/guvlX493wEm7ocA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xTvsFlEGSn91usTWdf3RBteup/3pGHiCGEp/ulsXg/8=; b=tjB952l0Uz/lmfQwvgIakIUE1EpdOZ6ibqTLRnJ99w3qrT5RXg925ratqmzKhMJIc9 DQJTmNcCg7Zk9o0C404YmoHQhDXpRIQmfVtK2vpITzf9soWhQEcTHBUK2jxcaBdjsfvm jzB/31ZQDIHn9JOfBAbUgM/sTsbSygK3NjlVTd7q5FOSKt7UaJtm1aVwwXOKA68FSEYo ADZBTZ4WlmpIIgnRwRNqFGwqmjAK1LukSlORXUzqIBjC3GjavDJuCeith6pFroCkhIo+ RaPbsUP5t0+57K/94jBx2URPDtfFDlR4SRN+A5vPdVei3tBXqFz8o08s9sbRE4rYXNV8 Iu5w== X-Gm-Message-State: AOAM532VOtncfOkSQRAJE0S1MtZ+vLi8BEuh2Qi7TzJTrhObb5H2ZY3D AxKEDR+XBGk/MLAHypwXjsCg7c007PibcQ== X-Google-Smtp-Source: ABdhPJywBdsKi8QwfbA1YWop4PjGCA3+hHoSNp3KC2/GcA2QGZ2ZYM+NaT0/Wn9Q2mXJZ8EzfvsK8g== X-Received: by 2002:a05:6e02:13e1:: with SMTP id w1mr12351970ilj.181.1620083553240; Mon, 03 May 2021 16:12:33 -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 o6sm422727ioa.21.2021.05.03.16.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 16:12:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Bin Meng , Robert Marko , Andre Przywara , Masahiro Yamada , Simon Glass , Joe Hershberger , Marek Vasut , Naoki Hayama , Stefan Roese Subject: [PATCH 43/49] image: Reduce variable scope in boot_get_ramdisk() Date: Mon, 3 May 2021 17:11:30 -0600 Message-Id: <20210503231136.744283-16-sjg@chromium.org> X-Mailer: git-send-email 2.31.1.527.g47e6f16901-goog In-Reply-To: <20210503231136.744283-1-sjg@chromium.org> References: <20210503231136.744283-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 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-board.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/common/image-board.c b/common/image-board.c index 0543c67d3bd..f0ef426d1c9 100644 --- a/common/image-board.c +++ b/common/image-board.c @@ -337,18 +337,8 @@ int genimg_has_config(bootm_headers_t *images) int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, u8 arch, ulong *rd_start, ulong *rd_end) { - ulong rd_addr, rd_load; ulong rd_data, rd_len; -#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT) - const image_header_t *rd_hdr; -#endif void *buf; -#if CONFIG_IS_ENABLED(FIT) - const char *fit_uname_config = images->fit_uname_cfg; - const char *fit_uname_ramdisk = NULL; - ulong default_addr; - int rd_noffset; -#endif const char *select = NULL; *rd_start = 0; @@ -373,8 +363,15 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, rd_len = 0; rd_data = 0; } else if (select || genimg_has_config(images)) { + ulong rd_addr, rd_load; + #if CONFIG_IS_ENABLED(FIT) + const char *fit_uname_config = images->fit_uname_cfg; + const char *fit_uname_ramdisk = NULL; + int rd_noffset; + if (select) { + ulong default_addr; /* * If the init ramdisk comes from the FIT image and * the FIT image address is omitted in the command @@ -427,7 +424,9 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, buf = map_sysmem(rd_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 *rd_hdr; + printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n", rd_addr); @@ -442,6 +441,7 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, rd_len = image_get_data_size(rd_hdr); rd_load = image_get_load(rd_hdr); break; + } #endif #if CONFIG_IS_ENABLED(FIT) case IMAGE_FORMAT_FIT: