mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm raid: Remove unnecessary negation of a shift in raid10_format_to_md_layout
@ 2019-10-24 20:28 Nathan Chancellor
  2019-10-24 21:46 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2019-10-24 20:28 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer
  Cc: dm-devel, linux-kernel, clang-built-linux, 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 */
                                           ^
 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.

Link: https://github.com/ClangBuiltLinux/linux/issues/753
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/md/dm-raid.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index b0aa595e4375..13fabc6779e5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -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;
 
-- 
2.24.0.rc1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm raid: Remove unnecessary negation of a shift in raid10_format_to_md_layout
  2019-10-24 20:28 [PATCH] dm raid: Remove unnecessary negation of a shift in raid10_format_to_md_layout Nathan Chancellor
@ 2019-10-24 21:46 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2019-10-24 21:46 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Alasdair Kergon, Mike Snitzer, dm-devel, LKML, clang-built-linux

On Thu, Oct 24, 2019 at 1:28 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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;

Yep, thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
(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).

> remove it so that clang no longer warns.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/753
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/md/dm-raid.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> index b0aa595e4375..13fabc6779e5 100644
> --- a/drivers/md/dm-raid.c
> +++ b/drivers/md/dm-raid.c
> @@ -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;
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-24 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 20:28 [PATCH] dm raid: Remove unnecessary negation of a shift in raid10_format_to_md_layout Nathan Chancellor
2019-10-24 21:46 ` Nick Desaulniers

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®