]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
image: Avoid switch default in image_decomp()
authorSimon Glass <sjg@chromium.org>
Sat, 25 Sep 2021 13:03:11 +0000 (07:03 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 8 Oct 2021 19:53:26 +0000 (15:53 -0400)
At present this function is full of preprocessor macros. Adjust it to
check for an unsupported algorithm after the switch(). This will allow
us to drop the macros.

Fix up the return-value path and an extra blank line while we are here.

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

index 2437223018312808410057f5ef5bf9c4affa7f31..1102483e0a31aeaaa07e05d3babfc1487165aa80 100644 (file)
@@ -446,7 +446,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
                 void *load_buf, void *image_buf, ulong image_len,
                 uint unc_len, ulong *load_end)
 {
-       int ret = 0;
+       int ret = -ENOSYS;
 
        *load_end = load;
        print_decomp_msg(comp, type, load == image_start);
@@ -458,6 +458,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
         */
        switch (comp) {
        case IH_COMP_NONE:
+               ret = 0;
                if (load == image_start)
                        break;
                if (image_len <= unc_len)
@@ -539,22 +540,23 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
                }
 
                image_len = ret;
-
                break;
        }
 #endif /* CONFIG_ZSTD */
 #endif
-       default:
+       }
+       if (ret == -ENOSYS) {
                printf("Unimplemented compression type %d\n", comp);
-               return -ENOSYS;
+               return ret;
        }
+       if (ret)
+               return ret;
 
        *load_end = load + image_len;
 
-       return ret;
+       return 0;
 }
 
-
 #ifndef USE_HOSTCC
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**