Skip to contentSkip to conversation

ice: Fix clang -Wimplicit-fallthrough in ice_pull_qvec_from_rc()

PATCH In review Nathan Chancellor 3 participants 3 messages Oct 19, 2021 – Oct 21, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Fix clang -Wimplicit-fallthrough in ice_pull_qvec_from_rc()

Clang warns:

drivers/net/ethernet/intel/ice/ice_lib.c:1906:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

        default:
        ^
drivers/net/ethernet/intel/ice/ice_lib.c:1906:2: note: insert 'break;' to avoid fall-through
        default:
        ^
        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.

---
 drivers/net/ethernet/intel/ice/ice_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/ice/ice_lib.c +1 -0
index f981e77f72ad..03443c060507 100644
@@ -1903,6 +1903,7 @@ static struct ice_q_vector *ice_pull_qvec_from_rc(struct ice_ring_container *rc)
 	case ICE_TX_CONTAINER:
 		if (rc->tx_ring)
 			return rc->tx_ring->q_vector;
+		break;
 	default:
 		break;
 	}

base-commit: 939a6567f976efb8b3e6d601ce35eb56b17babd0

Signature · 1 line
2.33.1.637.gf443b226ca
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Nathan Chancellor

Clang warns:

drivers/net/ethernet/intel/ice/ice_lib.c:1906:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

         default:
         ^
drivers/net/ethernet/intel/ice/ice_lib.c:1906:2: note: insert 'break;' to avoid fall-through
         default:
         ^
         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.

Quoted 2 lines
Tested-by on v1 1/1
#2 lore raw
In reply to Nathan Chancellor
Quoted 34 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nathan Chancellor
Sent: Tuesday, October 19, 2021 7:12 AM
To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>
Cc: [email protected]; [email protected]; Nick Desaulniers <[email protected]>; [email protected]; Nathan Chancellor <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: Fix clang -Wimplicit-fallthrough in ice_pull_qvec_from_rc()

Clang warns:

drivers/net/ethernet/intel/ice/ice_lib.c:1906:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

        default:
        ^
drivers/net/ethernet/intel/ice/ice_lib.c:1906:2: note: insert 'break;' to avoid
fall-through
        default:
        ^
        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.

Quoted 6 lines
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 1 +
 1 file changed, 1 insertion(+)