Skip to contentSkip to conversation

dm raid: Remove unnecessary negation of a shift in raid10_format_to_md_layout

PATCH In review Nathan Chancellor 2 participants 2 messages Oct 24, 2019 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm raid: Remove unnecessary negation of a shift in raid10_format_to_md_layout

When building with Clang + -Wtautological-constant-compare:

drivers/md/dm-raid.c:619:8: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]

                 r = !RAID10_OFFSET;
                      ^
 drivers/md/dm-raid.c:517:28: note: expanded from macro 'RAID10_OFFSET'
 #define RAID10_OFFSET                   (1 << 16) /* stripes with data
 copies area adjacent on devices */
                                           ^

1 warning generated.

Negating a non-zero number will always make it zero, which is the default value of r in this function so this statement is unnecessary; remove it so that clang no longer warns.

---
 drivers/md/dm-raid.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-raid.c +0 -1
index b0aa595e4375..13fabc6779e5 100644
@@ -616,7 +616,6 @@ static int raid10_format_to_md_layout(struct raid_set *rs,
 
 	} else if (algorithm == ALGORITHM_RAID10_FAR) {
 		f = copies;
-		r = !RAID10_OFFSET;
 		if (!test_bit(__CTR_FLAG_RAID10_USE_NEAR_SETS, &rs->ctr_flags))
 			r |= RAID10_USE_FAR_SETS;
 
Signature · 1 line
2.24.0.rc1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Nathan Chancellor

When building with Clang + -Wtautological-constant-compare:

drivers/md/dm-raid.c:619:8: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]

                 r = !RAID10_OFFSET;
                      ^
 drivers/md/dm-raid.c:517:28: note: expanded from macro 'RAID10_OFFSET'
 #define RAID10_OFFSET                   (1 << 16) /* stripes with data
 copies area adjacent on devices */
                                           ^
Quoted 4 lines

1 warning generated.

Negating a non-zero number will always make it zero, which is the default value of r in this function so this statement is unnecessary;

Yep, thanks for the patch.

(algorithm should be an enum, and there's some code duplication between ALGORITHM_RAID10_OFFSET and ALGORITHM_RAID10_FAR cases, but this patch is good enough).

Quoted 20 lines

remove it so that clang no longer warns.

---
 drivers/md/dm-raid.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-raid.c +0 -1
index b0aa595e4375..13fabc6779e5 100644
@@ -616,7 +616,6 @@ static int raid10_format_to_md_layout(struct raid_set *rs,
 
        } else if (algorithm == ALGORITHM_RAID10_FAR) {
                f = copies;
-               r = !RAID10_OFFSET;
                if (!test_bit(__CTR_FLAG_RAID10_USE_NEAR_SETS, &rs->ctr_flags))
                        r |= RAID10_USE_FAR_SETS;
 
Signature · 2 lines
Thanks,
~Nick Desaulniers