[PATCH] erofs-utils: lib: use another way to check power-of-2

Gao Xiang hsiangkao at linux.alibaba.com
Tue Sep 10 17:52:56 AEST 2024


Otherwise, Coverity will complain as "Operands don't affect result
(CONSTANT_EXPRESSION_RESULT)", which I don't think that is an issue.

Coverity-id: 508261
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/kite_deflate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kite_deflate.c b/lib/kite_deflate.c
index 4b1068b..592c4d1 100644
--- a/lib/kite_deflate.c
+++ b/lib/kite_deflate.c
@@ -834,7 +834,7 @@ static int kite_mf_init(struct kite_matchfinder *mf, unsigned int wsiz,
 		return -EINVAL;
 	cfg = &kite_mfcfg[level];
 
-	if (wsiz > kHistorySize32 || (1 << ilog2(wsiz)) != wsiz)
+	if (wsiz > kHistorySize32 || (wsiz & (wsiz - 1)))
 		return -EINVAL;
 
 	mf->hash = calloc(0x10000, sizeof(mf->hash[0]));
-- 
2.43.5



More information about the Linux-erofs mailing list