summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-09-25 16:03:11 +0300
committerTom Rini <trini@konsulko.com>2021-10-08 22:53:26 +0300
commitb876eb87e91d6705ef946090af16175dfb5ce1f9 (patch)
treee92064f47602172ef2779f87dc99b3eac663ce06 /common
parent918adf8e07337719750c57be0939824247973b1e (diff)
downloadu-boot-b876eb87e91d6705ef946090af16175dfb5ce1f9.tar.xz
image: Avoid switch default in image_decomp()
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>
Diffstat (limited to 'common')
-rw-r--r--common/image.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/common/image.c b/common/image.c
index 2437223018..1102483e0a 100644
--- a/common/image.c
+++ b/common/image.c
@@ -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)
/**