mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 12:46:14 +02:00
fs/squashfs: sqfs_decompressor: simplify code
Switch to if (CONFIG_IS_ENABLED()) instead of #if when possible and remove unnecessary cases. Signed-off-by: Richard Genoud <richard.genoud@bootlin.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: João Marcos Costa <joaomarcos.costa@bootlin.com>
This commit is contained in:
parent
f0b4f502bd
commit
0fe2801730
@ -33,57 +33,32 @@ int sqfs_decompressor_init(struct squashfs_ctxt *ctxt)
|
||||
{
|
||||
u16 comp_type = get_unaligned_le16(&ctxt->sblk->compression);
|
||||
|
||||
switch (comp_type) {
|
||||
#if CONFIG_IS_ENABLED(LZO)
|
||||
case SQFS_COMP_LZO:
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(ZLIB)
|
||||
case SQFS_COMP_ZLIB:
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(LZ4)
|
||||
case SQFS_COMP_LZ4:
|
||||
break;
|
||||
#endif
|
||||
if (((CONFIG_IS_ENABLED(LZO) && comp_type == SQFS_COMP_LZO)) ||
|
||||
((CONFIG_IS_ENABLED(ZLIB) && comp_type == SQFS_COMP_ZLIB)) ||
|
||||
((CONFIG_IS_ENABLED(LZ4) && comp_type == SQFS_COMP_LZ4)))
|
||||
return 0;
|
||||
|
||||
#if CONFIG_IS_ENABLED(ZSTD)
|
||||
case SQFS_COMP_ZSTD:
|
||||
if (comp_type == SQFS_COMP_ZSTD) {
|
||||
ctxt->zstd_workspace = malloc(zstd_dctx_workspace_bound());
|
||||
if (!ctxt->zstd_workspace)
|
||||
return -ENOMEM;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
printf("Error: unknown compression type.\n");
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
printf("Error: unknown compression type.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
void sqfs_decompressor_cleanup(struct squashfs_ctxt *ctxt)
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(ZSTD)
|
||||
u16 comp_type = get_unaligned_le16(&ctxt->sblk->compression);
|
||||
|
||||
switch (comp_type) {
|
||||
#if CONFIG_IS_ENABLED(LZO)
|
||||
case SQFS_COMP_LZO:
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(ZLIB)
|
||||
case SQFS_COMP_ZLIB:
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(LZ4)
|
||||
case SQFS_COMP_LZ4:
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(ZSTD)
|
||||
case SQFS_COMP_ZSTD:
|
||||
if (comp_type == SQFS_COMP_ZSTD)
|
||||
free(ctxt->zstd_workspace);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(ZLIB)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user