erofs-utils: lib: use another way to check power-of-2
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 10 Sep 2024 07:52:56 +0000 (15:52 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 10 Sep 2024 08:14:37 +0000 (16:14 +0800)
Otherwise, Coverity will complain with "Operands don't affect result
(CONSTANT_EXPRESSION_RESULT)", which I don't think is an issue.

Coverity-id: 508261
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240910075256.3423180-1-hsiangkao@linux.alibaba.com
lib/kite_deflate.c

index 4b1068b50b48f9d94f4550aba7efc9e64dbc9c7b..592c4d10548e109e28fe475f9033529ff01dc680 100644 (file)
@@ -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]));