diff mbox series

[net-next] rxrpc: Mark expected switch fall-through

Message ID 20190401193931.GA1135@embeddedor
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] rxrpc: Mark expected switch fall-through | expand

Commit Message

Gustavo A. R. Silva April 1, 2019, 7:39 p.m. UTC
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

This patch fixes the following warning:

net/rxrpc/local_object.c: In function ‘rxrpc_open_socket’:
net/rxrpc/local_object.c:175:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (ret < 0) {
      ^
net/rxrpc/local_object.c:184:2: note: here
  case AF_INET:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Currently, GCC is expecting to find the fall-through annotations
at the very bottom of the case and on its own line. That's why
I had to add the annotation, although the intentional fall-through
is already mentioned in a few lines above.

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/rxrpc/local_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller April 4, 2019, 4:39 a.m. UTC | #1
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Mon, 1 Apr 2019 14:39:31 -0500

> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> This patch fixes the following warning:
> 
> net/rxrpc/local_object.c: In function ‘rxrpc_open_socket’:
> net/rxrpc/local_object.c:175:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (ret < 0) {
>       ^
> net/rxrpc/local_object.c:184:2: note: here
>   case AF_INET:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> Currently, GCC is expecting to find the fall-through annotations
> at the very bottom of the case and on its own line. That's why
> I had to add the annotation, although the intentional fall-through
> is already mentioned in a few lines above.
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.
Gustavo A. R. Silva April 4, 2019, 3:31 p.m. UTC | #2
On 4/3/19 11:39 PM, David Miller wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> Date: Mon, 1 Apr 2019 14:39:31 -0500
> 
>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>> where we are expecting to fall through.
>>
>> This patch fixes the following warning:
>>
>> net/rxrpc/local_object.c: In function ‘rxrpc_open_socket’:
>> net/rxrpc/local_object.c:175:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>    if (ret < 0) {
>>       ^
>> net/rxrpc/local_object.c:184:2: note: here
>>   case AF_INET:
>>   ^~~~
>>
>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>
>> Currently, GCC is expecting to find the fall-through annotations
>> at the very bottom of the case and on its own line. That's why
>> I had to add the annotation, although the intentional fall-through
>> is already mentioned in a few lines above.
>>
>> This patch is part of the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Applied.
> 

Thanks, Dave.

--
Gustavo
David Howells April 5, 2019, 3:15 p.m. UTC | #3
Gustavo A. R. Silva <gustavo@embeddedor.com> wrote:

>  		/* Fall through and set IPv4 options too otherwise we don't get
>  		 * errors from IPv4 packets sent through the IPv6 socket.
>  		 */
> -
> +		/* Fall through */

Er, no.  Please (a) don't remove the blank line that's providing visual
separation and (b) observe that the previous comment already says "Fall
through" right at the beginning, so NAK.

If the compiler doesn't recognise this, then fix the compiler please.

David
diff mbox series

Patch

diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index 15cf42d5b53a..9157fd00dce3 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -180,7 +180,7 @@  static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
 		/* Fall through and set IPv4 options too otherwise we don't get
 		 * errors from IPv4 packets sent through the IPv6 socket.
 		 */
-
+		/* Fall through */
 	case AF_INET:
 		/* we want to receive ICMP errors */
 		opt = 1;