2015-07-23 15:48:34

by Colin King

[permalink] [raw]
Subject: [PATCH] dm cache: fix alloc_bitset check that always evaluates as false

From: Colin Ian King <[email protected]>

static analysis by cppcheck has found a check on alloc_bitset that
always evaluates as false and hence never finds an allocation failure:

[drivers/md/dm-cache-policy-smq.c:1689]: (warning) Logical conjunction
always evaluates to false: !EXPR && EXPR.

Fix this by removing the incorrect mq->cache_hit_bits check

Signed-off-by: Colin Ian King <[email protected]>
---
drivers/md/dm-cache-policy-smq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c
index b6f2265..48a4a82 100644
--- a/drivers/md/dm-cache-policy-smq.c
+++ b/drivers/md/dm-cache-policy-smq.c
@@ -1686,7 +1686,7 @@ static struct dm_cache_policy *smq_create(dm_cblock_t cache_size,

if (from_cblock(cache_size)) {
mq->cache_hit_bits = alloc_bitset(from_cblock(cache_size));
- if (!mq->cache_hit_bits && mq->cache_hit_bits) {
+ if (!mq->cache_hit_bits) {
DMERR("couldn't allocate cache hit bitset");
goto bad_cache_hit_bits;
}
--
2.1.4


2015-07-27 12:15:32

by Mike Snitzer

[permalink] [raw]
Subject: Re: dm cache: fix alloc_bitset check that always evaluates as false

On Thu, Jul 23 2015 at 11:47P -0400,
Colin King <[email protected]> wrote:

> From: Colin Ian King <[email protected]>
>
> static analysis by cppcheck has found a check on alloc_bitset that
> always evaluates as false and hence never finds an allocation failure:
>
> [drivers/md/dm-cache-policy-smq.c:1689]: (warning) Logical conjunction
> always evaluates to false: !EXPR && EXPR.
>
> Fix this by removing the incorrect mq->cache_hit_bits check
>
> Signed-off-by: Colin Ian King <[email protected]>

Applied for 4.2-rc5 inclussion, thanks:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=for-next&id=134bf30c06f057d6b8d90132e8f8b3cd2be79572