Skip to contentSkip to conversation

rds: send: mark expected switch fall-through in rds_rm_size

PATCH Applied Gustavo A. R. Silva 5 participants 9 messages Feb 19, 2018 – Feb 21, 2018

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

PATCH 1/1 rds: send: mark expected switch fall-through in rds_rm_size

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

Addresses-Coverity-ID: 1465362 ("Missing break in switch")

---
 net/rds/send.c | 2 ++
 1 file changed, 2 insertions(+)
net/rds/send.c +2 -0
index 028ab59..79d158b 100644
@@ -902,6 +902,8 @@ static int rds_rm_size(struct msghdr *msg, int num_sgs)
 
 		case RDS_CMSG_ZCOPY_COOKIE:
 			zcopy_cookie = true;
+			/* fall through */
+
 		case RDS_CMSG_RDMA_DEST:
 		case RDS_CMSG_RDMA_MAP:
 			cmsg_groups |= 2;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#2 lore raw
In reply to Gustavo A. R. Silva

Hi,

Quoted 15 lines · Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

Addresses-Coverity-ID: 1465362 ("Missing break in switch")

---
  net/rds/send.c | 2 ++
  1 file changed, 2 insertions(+)
net/rds/send.c +0 -0
index 028ab59..79d158b 100644

net/rds/send.c static int rds_rm_size(struct msghdr *msg, int num_sgs) · line 909

Quoted 8 lines
net/rds/send.c +2 -0
@@ -902,6 +902,8 @@ static int rds_rm_size(struct msghdr *msg, int num_sgs)
 
  		case RDS_CMSG_ZCOPY_COOKIE:
  			zcopy_cookie = true;
+			/* fall through */
+
  		case RDS_CMSG_RDMA_DEST:
  		case RDS_CMSG_RDMA_MAP:
  			cmsg_groups |= 2;

So coverity greps for commet as "fall through" for -Wimplicit-fallthrough build ?

Adding that comments itself if fine but was curious about it if some one makes a spell error in this comment what happens ;-)

For patch itself,

maintainer
#3 lore raw

From: Santosh Shilimkar <[email protected]>
Date: Tue, 20 Feb 2018 09:54:09 -0800

Quoted 4 lines

So coverity greps for commet as "fall through" for -Wimplicit-fallthrough build ?

From what I understand, 'gcc' does in the latest versions. Coverity

might as well, I don't know.

#6 lore raw
In reply to Santosh Shilimkar

Hi Santosh,

Quoted 12 lines · Santosh Shilimkar

Hi,

Quoted 9 lines · Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

Addresses-Coverity-ID: 1465362 ("Missing break in switch")

---
  net/rds/send.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 17 lines
Quoted 6 lines
net/rds/send.c +0 -0
index 028ab59..79d158b 100644
@@ -902,6 +902,8 @@ static int rds_rm_size(struct msghdr *msg, int 
 num_sgs)
Quoted 8 lines

          case RDS_CMSG_ZCOPY_COOKIE:
              zcopy_cookie = true;
+            /* fall through */
+
          case RDS_CMSG_RDMA_DEST:
          case RDS_CMSG_RDMA_MAP:
              cmsg_groups |= 2;

So coverity greps for commet as "fall through" for -Wimplicit-fallthrough build ?

No. Basically, Coverity only reports cases in which a break, return or continue statement is missing.

Now, if the statements I mention above are missing and if you add the following line to your Makefile:

KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough)

You will get a warning if a fall-through comment is missing.

Quoted 4 lines

Adding that comments itself if fine but was curious about it if some one makes a spell error in this comment what happens ;-)

In this case, Coverity would still report the same "Missing break in switch" error, but you'll get a GCC warning.

Quoted 2 lines

For patch itself,

--
Gustavo

#4 lore raw
In reply to David Miller
Quoted 9 lines · David Miller

From: Santosh Shilimkar <[email protected]>
Date: Tue, 20 Feb 2018 09:54:09 -0800

Quoted 2 lines

So coverity greps for commet as "fall through" for -Wimplicit-fallthrough build ?

From what I understand, 'gcc' does in the latest versions. Coverity
might as well, I don't know.

Yeah, the one that reports those warnings is GCC.

Coverity only knows about missing break, return and continue.

--
Gustavo

#5 lore raw
In reply to David Miller
Quoted 9 lines · David Miller

From: Santosh Shilimkar <[email protected]>
Date: Tue, 20 Feb 2018 09:54:09 -0800

Quoted 2 lines

So coverity greps for commet as "fall through" for -Wimplicit-fallthrough build ?

From what I understand, 'gcc' does in the latest versions. Coverity
might as well, I don't know.

Good to know about 'gcc' adding such option. Thanks !!

#7 lore raw
In reply to Gustavo A. R. Silva
Quoted 33 lines · Gustavo A. R. Silva

Hi Santosh,

Quoted 12 lines · Santosh Shilimkar

Hi,

Quoted 9 lines · Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

Addresses-Coverity-ID: 1465362 ("Missing break in switch")

---
  net/rds/send.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 17 lines
Quoted 6 lines
net/rds/send.c +0 -0
index 028ab59..79d158b 100644
@@ -902,6 +902,8 @@ static int rds_rm_size(struct msghdr *msg, int 
 num_sgs)
Quoted 8 lines

          case RDS_CMSG_ZCOPY_COOKIE:
              zcopy_cookie = true;
+            /* fall through */
+
          case RDS_CMSG_RDMA_DEST:
          case RDS_CMSG_RDMA_MAP:
              cmsg_groups |= 2;

So coverity greps for commet as "fall through" for -Wimplicit-fallthrough build ?

Quoted 8 lines

No. Basically, Coverity only reports cases in which a break, return or continue statement is missing.

Now, if the statements I mention above are missing and if you add the following line to your Makefile:

KBUILD_CFLAGS  += $(call cc-option,-Wimplicit-fallthrough)

You will get a warning if a fall-through comment is missing.

That make sense.

Quoted 7 lines
Quoted 4 lines

Adding that comments itself if fine but was curious about it if some one makes a spell error in this comment what happens ;-)

In this case, Coverity would still report the same "Missing break in switch" error, but you'll get a GCC warning.

Got it. Thanks !!