erofs: print the names of unsupported compression algorithms
PATCH 1/1 erofs: print the names of unsupported compression algorithms
After simplifying the implementation of z_erofs_parse_cfgs, the names of unsupported algorithms can now be directly output. Moreover, some unnecessary additional judgments can be removed.
Signed-off-by Yuwen Chen <[email protected]>
--- fs/erofs/decompressor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/erofs/decompressor.c +8 -8
@@ -385,21 +385,22 @@ const struct z_erofs_decompressor erofs_decompressors[] = { .decompress = z_erofs_lz4_decompress, .name = "lz4" }, -#ifdef CONFIG_EROFS_FS_ZIP_LZMA [Z_EROFS_COMPRESSION_LZMA] = { +#ifdef CONFIG_EROFS_FS_ZIP_LZMA .config = z_erofs_load_lzma_config, .decompress = z_erofs_lzma_decompress, +#endif .name = "lzma" }, -#endif -#ifdef CONFIG_EROFS_FS_ZIP_DEFLATE [Z_EROFS_COMPRESSION_DEFLATE] = { +#ifdef CONFIG_EROFS_FS_ZIP_DEFLATE .config = z_erofs_load_deflate_config, .decompress = z_erofs_deflate_decompress, +#endif .name = "deflate" }, -#endif }; +static_assert(Z_EROFS_COMPRESSION_RUNTIME_MAX == ARRAY_SIZE(erofs_decompressors)); int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb) {
@@ -433,10 +434,9 @@ int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb)break ; } -if (alg >=ARRAY_SIZE (erofs_decompressors) || - !erofs_decompressors[alg].config) { -erofs_err (sb,"algorithm %ld isn't enabled on this kernel" , - alg); +if (!erofs_decompressors[alg].config) { +erofs_err (sb,"algorithm %s isn't enabled on this kernel" , + erofs_decompressors[alg].name); ret = -EOPNOTSUPP ; }else { ret = erofs_decompressors[alg].config(sb,
Signature · 1 line
2.34.1
Quoted 5 lines · Yuwen Chen
After simplifying the implementation of
z_erofs_parse_cfgs, the names of unsupported algorithms can now be directly output. Moreover, some unnecessary additional judgments can be removed.Signed-off-by Yuwen Chen <[email protected]>
It seems that you're working on outdated codebase.
There is no erofs_decompressors at all.
Thanks,
Gao Xiang
Quoted 52 lines
--- fs/erofs/decompressor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)fs/erofs/decompressor.c +8
-8@@ -385,21 +385,22 @@ const struct z_erofs_decompressor erofs_decompressors[] = { .decompress = z_erofs_lz4_decompress, .name = "lz4" }, -#ifdef CONFIG_EROFS_FS_ZIP_LZMA [Z_EROFS_COMPRESSION_LZMA] = { +#ifdef CONFIG_EROFS_FS_ZIP_LZMA .config = z_erofs_load_lzma_config, .decompress = z_erofs_lzma_decompress, +#endif .name = "lzma" }, -#endif -#ifdef CONFIG_EROFS_FS_ZIP_DEFLATE [Z_EROFS_COMPRESSION_DEFLATE] = { +#ifdef CONFIG_EROFS_FS_ZIP_DEFLATE .config = z_erofs_load_deflate_config, .decompress = z_erofs_deflate_decompress, +#endif .name = "deflate" }, -#endif }; +static_assert(Z_EROFS_COMPRESSION_RUNTIME_MAX == ARRAY_SIZE(erofs_decompressors)); int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb) {@@ -433,10 +434,9 @@ int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb)break ; } -if (alg >=ARRAY_SIZE (erofs_decompressors) || - !erofs_decompressors[alg].config) { -erofs_err (sb,"algorithm %ld isn't enabled on this kernel" , - alg); +if (!erofs_decompressors[alg].config) { +erofs_err (sb,"algorithm %s isn't enabled on this kernel" , + erofs_decompressors[alg].name); ret = -EOPNOTSUPP ;} else { ret = erofs_decompressors[alg].config(sb,