]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
image: Reduce variable scope in boot_get_fdt()
authorSimon Glass <sjg@chromium.org>
Sun, 26 Sep 2021 01:43:40 +0000 (19:43 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 8 Oct 2021 19:53:27 +0000 (15:53 -0400)
Move the variables declarations to where they are needed, to reduce the
number of #ifdefs needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/image-fdt.c

index abea17bd56528305e5f1dcf22066806b01adeb32..58c8936c9897485f38bf87ee1fa4b30f6a53a1ea 100644 (file)
@@ -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:
                        /*