Skip to contentSkip to conversation

afs: Mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jul 31, 2018 – Aug 2, 2018 Afs filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 afs: Mark expected switch fall-throughs

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

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

---
 fs/afs/cmservice.c | 10 ++++++++--
 fs/afs/file.c      |  2 ++
 fs/afs/fsclient.c  | 41 +++++++++++++++++++++++++++--------------
 fs/afs/rxrpc.c     |  1 +
 fs/afs/vlclient.c  | 29 ++++++++++++++++-------------
 5 files changed, 54 insertions(+), 29 deletions(-)
fs/afs/cmservice.c +8 -2
index 9e51d6f..c06fcda 100644
@@ -179,7 +179,8 @@ static int afs_deliver_cb_callback(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
-		/* extract the FID array and its count in two steps */
+		/* Fall through and extract the FID array and its count
+		 * in two steps. */
 	case 1:
 		_debug("extract FID count");
 		ret = afs_extract_data(call, &call->tmp, 4, true);
@@ -198,6 +199,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
+		/* Fall through */
 	case 2:
 		_debug("extract FID array");
 		ret = afs_extract_data(call, call->buffer,
@@ -224,7 +226,8 @@ static int afs_deliver_cb_callback(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
-		/* extract the callback array and its count in two steps */
+		/* Fall through and extract the callback array and its count
+		 * in two steps. */
 	case 3:
 		_debug("extract CB count");
 		ret = afs_extract_data(call, &call->tmp, 4, true);
@@ -238,6 +241,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
+		/* Fall through */
 	case 4:
 		_debug("extract CB array");
 		ret = afs_extract_data(call, call->buffer,
@@ -336,6 +340,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
 			return -ENOMEM;
 		call->unmarshall++;
 
+		/* Fall through */
 	case 1:
 		_debug("extract UUID");
 		ret = afs_extract_data(call, call->buffer,
@@ -459,6 +464,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
 			return -ENOMEM;
 		call->unmarshall++;
 
+		/* Fall through */
 	case 1:
 		_debug("extract UUID");
 		ret = afs_extract_data(call, call->buffer,
fs/afs/file.c +2 -0
index 7d4f261..4a853ba 100644
@@ -299,6 +299,8 @@ int afs_page_filler(void *data, struct page *page)
 		/* page will not be cached */
 	case -ENOBUFS:
 		_debug("cache said ENOBUFS");
+
+		/* fall through */
 	default:
 	go_on:
 		req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),
fs/afs/fsclient.c +27 -14

167 lines not on this page · raw message

fs/afs/rxrpc.c +1 -0
index 183cc54..d0f915a 100644
@@ -842,6 +842,7 @@ void afs_send_empty_reply(struct afs_call *call)
 		_debug("oom");
 		rxrpc_kernel_abort_call(net->socket, call->rxcall,
 					RX_USER_ABORT, -ENOMEM, "KOO");
+		/* Fall through */
 	default:
 		_leave(" [error]");
 		return;
fs/afs/vlclient.c +16 -13
index c3b7408..e94735c 100644
@@ -195,7 +195,9 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
-		/* Extract the returned uuid, uniquifier, nentries and blkaddrs size */
+
+		/* Fall through and extract the returned uuid, uniquifier,
+		 * nentries and blkaddrs size. */
 	case 1:
 		ret = afs_extract_data(call, call->buffer,
 				       sizeof(struct afs_uuid__xdr) + 3 * sizeof(__be32),
@@ -219,7 +221,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
-		/* Extract entries */
+		/* Fall through and extract entries */
 	case 2:
 		count = min(call->count, 4U);
 		ret = afs_extract_data(call, call->buffer,
@@ -326,7 +328,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
-		/* Extract the capabilities word count */
+		/* Fall through and extract the capabilities word count */
 	case 1:
 		ret = afs_extract_data(call, &call->tmp,
 				       1 * sizeof(__be32),
@@ -341,7 +343,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall++;
 
-		/* Extract capabilities words */
+		/* Fall through and extract capabilities words */
 	case 2:
 		count = min(call->count, 16U);
 		ret = afs_extract_data(call, call->buffer,
@@ -434,9 +436,9 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall = 1;
 
-		/* Extract the returned uuid, uniquifier, fsEndpoints count and
-		 * either the first fsEndpoint type or the volEndpoints
-		 * count if there are no fsEndpoints. */
+		/* Fall through and extract the returned uuid, uniquifier,
+		 * fsEndpoints count and either the first fsEndpoint type
+		 * or the volEndpoints count if there are no fsEndpoints. */
 	case 1:
 		ret = afs_extract_data(call, call->buffer,
 				       sizeof(uuid_t) +
@@ -465,7 +467,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
 
 		call->unmarshall = 2;
 
-		/* Extract fsEndpoints[] entries */
+		/* Fall through and extract fsEndpoints[] entries */
 	case 2:
 		switch (call->count2) {
 		case YFS_ENDPOINT_IPV4:
@@ -522,9 +524,10 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
 
 		call->unmarshall = 3;
 
-		/* Extract the type of volEndpoints[0].  Normally we would
-		 * extract the type of the next endpoint when we extract the
-		 * data of the current one, but this is the first...
+		/* Fall through and extract the type of volEndpoints[0].
+		 * Normally we would extract the type of the next endpoint
+		 * when we extract the data of the current one, but this is
+		 * the first...
 		 */
 	case 3:
 		ret = afs_extract_data(call, call->buffer, sizeof(__be32), true);
@@ -536,7 +539,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
 		call->offset = 0;
 		call->unmarshall = 4;
 
-		/* Extract volEndpoints[] entries */
+		/* Fall through and extract volEndpoints[] entries */
 	case 4:
 		switch (call->count2) {
 		case YFS_ENDPOINT_IPV4:
@@ -584,7 +587,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
 	end:
 		call->unmarshall = 5;
 
-		/* Done */
+		/* Fall through - Done */
 	case 5:
 		ret = afs_extract_data(call, call->buffer, 0, false);
 		if (ret < 0)
Signature · 1 line
2.7.4
maintainer
#1 lore raw

fs/afs/fsclient.c static int afs_deliver_fs_fetch_data(struct afs_call *call) · line 505

Quoted 4 lines · Gustavo A. R. Silva
fs/afs/fsclient.c +1 -0
+		/* Fall through */
 	no_msw:
 		/* extract the returned data length */
 	case 2:

That would appear to be added in the wrong place. The fall-through is after the no_msw label.

fs/afs/fsclient.c static int afs_deliver_fs_get_volume_status(struct afs_call *call) · line 1655

Quoted 3 lines
fs/afs/fsclient.c +2 -0
+
+		/* Fall through */
 	no_volname_padding:

Ditto - and several other dittos too.

fs/afs/vlclient.c static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · line 590

Quoted 2 lines
fs/afs/vlclient.c +1 -1
-		/* Done */
+		/* Fall through - Done */

Yuck.

fs/afs/file.c int afs_page_filler(void *data, struct page *page) · line 303

Quoted 2 lines
fs/afs/file.c +2 -0
+
+		/* fall through */

Capital 'F' for consistency please.

Whilst I understand the argument for explicitly marking the fall-throughs to catch missing breaks, it's a bit irritating at times. Can we have an additional annotation that tells the compiler that every case in a switch statement is going to fall through (so no break before case) except the last? That would be more useful in this case.

David