mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yuwen Chen <ywen.chen@foxmail.com>
To: xiang@kernel.org
Cc: chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com,
	linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	Yuwen Chen <ywen.chen@foxmail.com>
Subject: [PATCH] erofs: print the names of unsupported compression algorithms
Date: Thu, 18 Dec 2025 11:18:58 +0800	[thread overview]
Message-ID: <tencent_D4F8982BC9797B5EE01759574F512CF7E506@qq.com> (raw)

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 <ywen.chen@foxmail.com>
---
 fs/erofs/decompressor.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index be1e19b620523..866bd9158615b 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -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,
-- 
2.34.1


             reply	other threads:[~2025-12-18  3:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  3:18 Yuwen Chen [this message]
2025-12-18  3:25 ` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_D4F8982BC9797B5EE01759574F512CF7E506@qq.com \
    --to=ywen.chen@foxmail.com \
    --cc=chao@kernel.org \
    --cc=huyue2@coolpad.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®