linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/maple_tree: Fix clang -Wimplicit-fallthrough in mte_set_pivot()
@ 2022-02-24 16:17 Nathan Chancellor
  2022-02-24 17:40 ` Liam Howlett
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2022-02-24 16:17 UTC (permalink / raw)
  To: Liam R. Howlett; +Cc: linux-mm, llvm, patches, Nathan Chancellor

Clang warns:

  lib/maple_tree.c:764:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
          case maple_dense:
          ^
  lib/maple_tree.c:764:2: note: insert 'break;' to avoid fall-through
          case maple_dense:
          ^
          break;
  1 error generated.

Clang is a little more pedantic than GCC, which does not warn when
falling through to a case that is just break or return. Clang's version
is more in line with the kernel's own stance in deprecated.rst, which
states that all switch/case blocks must end in either break,
fallthrough, continue, goto, or return. Add the missing break to silence
the warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/1604
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 lib/maple_tree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 5132495f86a6..5d8c39cbd517 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -761,6 +761,7 @@ static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
 		break;
 	case maple_arange_64:
 		(&node->ma64)->pivot[piv] = val;
+		break;
 	case maple_dense:
 		break;
 	}

base-commit: 7ec16b08f9e0b656c96d20424b1cbbff4c78329c
-- 
2.35.1



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

* Re: [PATCH] lib/maple_tree: Fix clang -Wimplicit-fallthrough in mte_set_pivot()
  2022-02-24 16:17 [PATCH] lib/maple_tree: Fix clang -Wimplicit-fallthrough in mte_set_pivot() Nathan Chancellor
@ 2022-02-24 17:40 ` Liam Howlett
  0 siblings, 0 replies; 2+ messages in thread
From: Liam Howlett @ 2022-02-24 17:40 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: linux-mm, llvm, patches

* Nathan Chancellor <nathan@kernel.org> [220224 11:17]:
> Clang warns:
> 
>   lib/maple_tree.c:764:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
>           case maple_dense:
>           ^
>   lib/maple_tree.c:764:2: note: insert 'break;' to avoid fall-through
>           case maple_dense:
>           ^
>           break;
>   1 error generated.
> 
> Clang is a little more pedantic than GCC, which does not warn when
> falling through to a case that is just break or return. Clang's version
> is more in line with the kernel's own stance in deprecated.rst, which
> states that all switch/case blocks must end in either break,
> fallthrough, continue, goto, or return. Add the missing break to silence
> the warning.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1604
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  lib/maple_tree.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 5132495f86a6..5d8c39cbd517 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -761,6 +761,7 @@ static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
>  		break;
>  	case maple_arange_64:
>  		(&node->ma64)->pivot[piv] = val;
> +		break;

I will add this to linux-next and clean up the line above while I'm at
it.

>  	case maple_dense:
>  		break;
>  	}
> 
> base-commit: 7ec16b08f9e0b656c96d20424b1cbbff4c78329c
> -- 
> 2.35.1
> 

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

end of thread, other threads:[~2022-02-24 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24 16:17 [PATCH] lib/maple_tree: Fix clang -Wimplicit-fallthrough in mte_set_pivot() Nathan Chancellor
2022-02-24 17:40 ` Liam Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox