linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] nfs: remove incorrect fallthrough label
@ 2020-09-17  6:21 linmiaohe
  0 siblings, 0 replies; 7+ messages in thread
From: linmiaohe @ 2020-09-17  6:21 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Gustavo A . R . Silva, Joe Perches, Nathan Chancellor,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	clang-built-linux@googlegroups.com, Trond Myklebust,
	Anna Schumaker

Nick Desaulniers <ndesaulniers@google.com> wrote:
> There is no case after the default from which to fallthrough to. Clang will error in this case (unhelpfully without context, see link below) and GCC will with -Wswitch-unreachable.
>
>The previous commit should have just replaced the comment with a break statement.
>
>If we consider implicit fallthrough to be a design mistake of C, then all case statements should be terminated with one of the following
>statements:
>* break
>* continue
>* return
>* __attribute__(__fallthrough__)
>* goto (plz no)
>* (call of function with __attribute__(__noreturn__))
>
>Fixes: 2a1390c95a69 ("nfs: Convert to use the preferred fallthrough macro")
>Link: https://bugs.llvm.org/show_bug.cgi?id=47539
>Suggested-by: Joe Perches <joe@perches.com>
>Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
>---

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH] nfs: remove incorrect fallthrough label
@ 2020-09-15 23:29 Joe Perches
  2020-09-16 20:02 ` [PATCH v2] " Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2020-09-15 23:29 UTC (permalink / raw)
  To: Nick Desaulniers, Trond Myklebust, Anna Schumaker
  Cc: Gustavo A . R . Silva, Nathan Chancellor, Miaohe Lin,
	Hongxiang Lou, linux-nfs, linux-kernel, clang-built-linux

On Tue, 2020-09-15 at 15:57 -0700, Nick Desaulniers wrote:
> There is no case after the default from which to fallthrough to. Clang
> will error in this case (unhelpfully without context, see link below)
> and GCC will with -Wswitch-unreachable.
> 
> The previous commit should have just removed the comment.
[]
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
[]
> @@ -889,7 +889,6 @@ static struct nfs_server *nfs_try_mount_request(struct fs_context *fc)
>  		default:
>  			if (rpcauth_get_gssinfo(flavor, &info) != 0)
>  				continue;
> -			fallthrough;

My preference would be to convert the fallthrough
to a break here so if someone ever adds another
label after default: for any reason, the code would
still work as expected.

>  		}
> 


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

end of thread, other threads:[~2020-09-18  1:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-17  6:21 [PATCH v2] nfs: remove incorrect fallthrough label linmiaohe
  -- strict thread matches above, loose matches on Subject: below --
2020-09-15 23:29 [PATCH] " Joe Perches
2020-09-16 20:02 ` [PATCH v2] " Nick Desaulniers
2020-09-16 20:18   ` Gustavo A. R. Silva
2020-09-16 20:19   ` Joe Perches
2020-09-17 21:41     ` Nick Desaulniers
2020-09-18  1:36       ` Joe Perches
2020-09-17  4:35   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).