netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Łukasz Stelmach" <l.stelmach@samsung.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 1/2] net: ax88796c: Fix clang -Wimplicit-fallthrough in ax88796c_set_mac()
Date: Mon, 25 Oct 2021 14:12:38 -0700	[thread overview]
Message-ID: <20211025211238.178768-1-nathan@kernel.org> (raw)

Clang warns:

drivers/net/ethernet/asix/ax88796c_main.c:696:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        case SPEED_10:
        ^
drivers/net/ethernet/asix/ax88796c_main.c:696:2: note: insert 'break;' to avoid fall-through
        case SPEED_10:
        ^
        break;
drivers/net/ethernet/asix/ax88796c_main.c:706:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        case DUPLEX_HALF:
        ^
drivers/net/ethernet/asix/ax88796c_main.c:706:2: note: insert 'break;' to avoid fall-through
        case DUPLEX_HALF:
        ^
        break;

Clang is a little more pedantic than GCC, which permits implicit
fallthroughs to cases that contain 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 breaks to fix
the warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/1491
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/net/ethernet/asix/ax88796c_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/asix/ax88796c_main.c b/drivers/net/ethernet/asix/ax88796c_main.c
index cfc597f72e3d..cf0f96f93f3b 100644
--- a/drivers/net/ethernet/asix/ax88796c_main.c
+++ b/drivers/net/ethernet/asix/ax88796c_main.c
@@ -693,6 +693,7 @@ static void ax88796c_set_mac(struct  ax88796c_device *ax_local)
 	switch (ax_local->speed) {
 	case SPEED_100:
 		maccr |= MACCR_SPEED_100;
+		break;
 	case SPEED_10:
 	case SPEED_UNKNOWN:
 		break;
@@ -703,6 +704,7 @@ static void ax88796c_set_mac(struct  ax88796c_device *ax_local)
 	switch (ax_local->duplex) {
 	case DUPLEX_FULL:
 		maccr |= MACCR_SPEED_100;
+		break;
 	case DUPLEX_HALF:
 	case DUPLEX_UNKNOWN:
 		break;

base-commit: dcd63d4326802cec525de2a4775019849958125c
-- 
2.33.1.637.gf443b226ca


             reply	other threads:[~2021-10-25 21:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 21:12 Nathan Chancellor [this message]
2021-10-25 21:12 ` [PATCH 2/2] net: ax88796c: Remove pointless check in ax88796c_open() Nathan Chancellor
2021-10-26 14:10 ` [PATCH 1/2] net: ax88796c: Fix clang -Wimplicit-fallthrough in ax88796c_set_mac() patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211025211238.178768-1-nathan@kernel.org \
    --to=nathan@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=l.stelmach@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).