Skip to content

Commit e690c9e

Browse files
afs: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Notice that in many cases I placed a /* Fall through */ comment at the bottom of the case, which what GCC is expecting to find. In other cases I had to tweak a bit the format of the comments. This patch suppresses ALL missing-break-in-switch false positives in fs/afs Addresses-Coverity-ID: 115042 ("Missing break in switch") Addresses-Coverity-ID: 115043 ("Missing break in switch") Addresses-Coverity-ID: 115045 ("Missing break in switch") Addresses-Coverity-ID: 1357430 ("Missing break in switch") Addresses-Coverity-ID: 115047 ("Missing break in switch") Addresses-Coverity-ID: 115050 ("Missing break in switch") Addresses-Coverity-ID: 115051 ("Missing break in switch") Addresses-Coverity-ID: 1467806 ("Missing break in switch") Addresses-Coverity-ID: 1467807 ("Missing break in switch") Addresses-Coverity-ID: 1467811 ("Missing break in switch") Addresses-Coverity-ID: 115041 ("Missing break in switch") Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
1 parent 0a4c926 commit e690c9e

8 files changed

Lines changed: 71 additions & 29 deletions

File tree

‎fs/afs/cmservice.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
285285
call->unmarshall++;
286286

287287
/* extract the FID array and its count in two steps */
288+
/* fall through */
288289
case 1:
289290
_debug("extract FID count");
290291
ret = afs_extract_data(call, true);
@@ -304,6 +305,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
304305
afs_extract_to_buf(call, call->count * 3 * 4);
305306
call->unmarshall++;
306307

308+
/* Fall through */
307309
case 2:
308310
_debug("extract FID array");
309311
ret = afs_extract_data(call, true);
@@ -329,6 +331,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
329331
call->unmarshall++;
330332

331333
/* extract the callback array and its count in two steps */
334+
/* fall through */
332335
case 3:
333336
_debug("extract CB count");
334337
ret = afs_extract_data(call, true);
@@ -344,6 +347,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
344347
iov_iter_discard(&call->iter, READ, call->count2 * 3 * 4);
345348
call->unmarshall++;
346349

350+
/* Fall through */
347351
case 4:
348352
_debug("extract discard %zu/%u",
349353
iov_iter_count(&call->iter), call->count2 * 3 * 4);
@@ -422,6 +426,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
422426
afs_extract_to_buf(call, 11 * sizeof(__be32));
423427
call->unmarshall++;
424428

429+
/* Fall through */
425430
case 1:
426431
_debug("extract UUID");
427432
ret = afs_extract_data(call, false);
@@ -537,6 +542,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
537542
afs_extract_to_buf(call, 11 * sizeof(__be32));
538543
call->unmarshall++;
539544

545+
/* Fall through */
540546
case 1:
541547
_debug("extract UUID");
542548
ret = afs_extract_data(call, false);
@@ -673,6 +679,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
673679
call->unmarshall++;
674680

675681
/* extract the FID array and its count in two steps */
682+
/* Fall through */
676683
case 1:
677684
_debug("extract FID count");
678685
ret = afs_extract_data(call, true);
@@ -692,6 +699,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
692699
afs_extract_to_buf(call, size);
693700
call->unmarshall++;
694701

702+
/* Fall through */
695703
case 2:
696704
_debug("extract FID array");
697705
ret = afs_extract_data(call, false);

‎fs/afs/file.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ int afs_page_filler(void *data, struct page *page)
300300
/* page will not be cached */
301301
case -ENOBUFS:
302302
_debug("cache said ENOBUFS");
303+
304+
/* fall through */
303305
default:
304306
go_on:
305307
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),

‎fs/afs/flock.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ void afs_lock_work(struct work_struct *work)
303303
return;
304304
}
305305

306+
/* Fall through */
306307
default:
307308
/* Looks like a lock request was withdrawn. */
308309
spin_unlock(&vnode->lock);

‎fs/afs/fsclient.c‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
498498
afs_extract_to_tmp(call);
499499
}
500500

501-
/* extract the returned data length */
501+
/* Fall through - and extract the returned data length */
502502
case 1:
503503
_debug("extract data length");
504504
ret = afs_extract_data(call, true);
@@ -525,7 +525,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
525525
iov_iter_bvec(&call->iter, READ, call->bvec, 1, size);
526526
ASSERTCMP(size, <=, PAGE_SIZE);
527527

528-
/* extract the returned data */
528+
/* Fall through - and extract the returned data */
529529
case 2:
530530
_debug("extract data %zu/%llu",
531531
iov_iter_count(&call->iter), req->remain);
@@ -552,6 +552,8 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
552552
/* Discard any excess data the server gave us */
553553
iov_iter_discard(&call->iter, READ, req->actual_len - req->len);
554554
call->unmarshall = 3;
555+
556+
/* Fall through */
555557
case 3:
556558
_debug("extract discard %zu/%llu",
557559
iov_iter_count(&call->iter), req->actual_len - req->len);
@@ -564,7 +566,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
564566
call->unmarshall = 4;
565567
afs_extract_to_buf(call, (21 + 3 + 6) * 4);
566568

567-
/* extract the metadata */
569+
/* Fall through - and extract the metadata */
568570
case 4:
569571
ret = afs_extract_data(call, false);
570572
if (ret < 0)
@@ -1634,7 +1636,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
16341636
call->unmarshall++;
16351637
afs_extract_to_buf(call, 12 * 4);
16361638

1637-
/* extract the returned status record */
1639+
/* Fall through - and extract the returned status record */
16381640
case 1:
16391641
_debug("extract status");
16401642
ret = afs_extract_data(call, true);
@@ -1646,7 +1648,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
16461648
call->unmarshall++;
16471649
afs_extract_to_tmp(call);
16481650

1649-
/* extract the volume name length */
1651+
/* Fall through - and extract the volume name length */
16501652
case 2:
16511653
ret = afs_extract_data(call, true);
16521654
if (ret < 0)
@@ -1661,7 +1663,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
16611663
afs_extract_begin(call, call->reply[2], size);
16621664
call->unmarshall++;
16631665

1664-
/* extract the volume name */
1666+
/* Fall through - and extract the volume name */
16651667
case 3:
16661668
_debug("extract volname");
16671669
ret = afs_extract_data(call, true);
@@ -1674,7 +1676,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
16741676
afs_extract_to_tmp(call);
16751677
call->unmarshall++;
16761678

1677-
/* extract the offline message length */
1679+
/* Fall through - and extract the offline message length */
16781680
case 4:
16791681
ret = afs_extract_data(call, true);
16801682
if (ret < 0)
@@ -1689,7 +1691,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
16891691
afs_extract_begin(call, call->reply[2], size);
16901692
call->unmarshall++;
16911693

1692-
/* extract the offline message */
1694+
/* Fall through - and extract the offline message */
16931695
case 5:
16941696
_debug("extract offline");
16951697
ret = afs_extract_data(call, true);
@@ -1703,7 +1705,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
17031705
afs_extract_to_tmp(call);
17041706
call->unmarshall++;
17051707

1706-
/* extract the message of the day length */
1708+
/* Fall through - and extract the message of the day length */
17071709
case 6:
17081710
ret = afs_extract_data(call, true);
17091711
if (ret < 0)
@@ -1718,7 +1720,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
17181720
afs_extract_begin(call, call->reply[2], size);
17191721
call->unmarshall++;
17201722

1721-
/* extract the message of the day */
1723+
/* Fall through - and extract the message of the day */
17221724
case 7:
17231725
_debug("extract motd");
17241726
ret = afs_extract_data(call, false);
@@ -2016,7 +2018,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
20162018
afs_extract_to_tmp(call);
20172019
call->unmarshall++;
20182020

2019-
/* Extract the capabilities word count */
2021+
/* Fall through - and extract the capabilities word count */
20202022
case 1:
20212023
ret = afs_extract_data(call, true);
20222024
if (ret < 0)
@@ -2029,7 +2031,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
20292031
iov_iter_discard(&call->iter, READ, count * sizeof(__be32));
20302032
call->unmarshall++;
20312033

2032-
/* Extract capabilities words */
2034+
/* Fall through - and extract capabilities words */
20332035
case 2:
20342036
ret = afs_extract_data(call, false);
20352037
if (ret < 0)
@@ -2206,6 +2208,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
22062208
call->unmarshall++;
22072209

22082210
/* Extract the file status count and array in two steps */
2211+
/* Fall through */
22092212
case 1:
22102213
_debug("extract status count");
22112214
ret = afs_extract_data(call, true);
@@ -2223,6 +2226,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
22232226
more_counts:
22242227
afs_extract_to_buf(call, 21 * sizeof(__be32));
22252228

2229+
/* Fall through */
22262230
case 2:
22272231
_debug("extract status array %u", call->count);
22282232
ret = afs_extract_data(call, true);
@@ -2246,6 +2250,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
22462250
afs_extract_to_tmp(call);
22472251

22482252
/* Extract the callback count and array in two steps */
2253+
/* Fall through */
22492254
case 3:
22502255
_debug("extract CB count");
22512256
ret = afs_extract_data(call, true);
@@ -2262,6 +2267,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
22622267
more_cbs:
22632268
afs_extract_to_buf(call, 3 * sizeof(__be32));
22642269

2270+
/* Fall through */
22652271
case 4:
22662272
_debug("extract CB array");
22672273
ret = afs_extract_data(call, true);
@@ -2284,6 +2290,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
22842290
afs_extract_to_buf(call, 6 * sizeof(__be32));
22852291
call->unmarshall++;
22862292

2293+
/* Fall through */
22872294
case 5:
22882295
ret = afs_extract_data(call, false);
22892296
if (ret < 0)

‎fs/afs/misc.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,33 +131,42 @@ void afs_prioritise_error(struct afs_error *e, int error, u32 abort_code)
131131
if (e->error == -ETIMEDOUT ||
132132
e->error == -ETIME)
133133
return;
134+
/* Fall through */
134135
case -ETIMEDOUT:
135136
case -ETIME:
136137
if (e->error == -ENOMEM ||
137138
e->error == -ENONET)
138139
return;
140+
/* Fall through */
139141
case -ENOMEM:
140142
case -ENONET:
141143
if (e->error == -ERFKILL)
142144
return;
145+
/* Fall through */
143146
case -ERFKILL:
144147
if (e->error == -EADDRNOTAVAIL)
145148
return;
149+
/* Fall through */
146150
case -EADDRNOTAVAIL:
147151
if (e->error == -ENETUNREACH)
148152
return;
153+
/* Fall through */
149154
case -ENETUNREACH:
150155
if (e->error == -EHOSTUNREACH)
151156
return;
157+
/* Fall through */
152158
case -EHOSTUNREACH:
153159
if (e->error == -EHOSTDOWN)
154160
return;
161+
/* Fall through */
155162
case -EHOSTDOWN:
156163
if (e->error == -ECONNREFUSED)
157164
return;
165+
/* Fall through */
158166
case -ECONNREFUSED:
159167
if (e->error == -ECONNRESET)
160168
return;
169+
/* Fall through */
161170
case -ECONNRESET: /* Responded, but call expired. */
162171
if (e->responded)
163172
return;

‎fs/afs/rxrpc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ void afs_send_empty_reply(struct afs_call *call)
909909
_debug("oom");
910910
rxrpc_kernel_abort_call(net->socket, call->rxcall,
911911
RX_USER_ABORT, -ENOMEM, "KOO");
912+
/* Fall through */
912913
default:
913914
_leave(" [error]");
914915
return;

‎fs/afs/vlclient.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
195195
sizeof(struct afs_uuid__xdr) + 3 * sizeof(__be32));
196196
call->unmarshall++;
197197

198-
/* Extract the returned uuid, uniquifier, nentries and blkaddrs size */
198+
/* Extract the returned uuid, uniquifier, nentries and
199+
* blkaddrs size */
200+
/* Fall through */
199201
case 1:
200202
ret = afs_extract_data(call, true);
201203
if (ret < 0)
@@ -220,7 +222,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
220222
count = min(call->count, 4U);
221223
afs_extract_to_buf(call, count * sizeof(__be32));
222224

223-
/* Extract entries */
225+
/* Fall through - and extract entries */
224226
case 2:
225227
ret = afs_extract_data(call, call->count > 4);
226228
if (ret < 0)
@@ -323,7 +325,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
323325
afs_extract_to_tmp(call);
324326
call->unmarshall++;
325327

326-
/* Extract the capabilities word count */
328+
/* Fall through - and extract the capabilities word count */
327329
case 1:
328330
ret = afs_extract_data(call, true);
329331
if (ret < 0)
@@ -336,7 +338,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
336338
call->unmarshall++;
337339
afs_extract_discard(call, count * sizeof(__be32));
338340

339-
/* Extract capabilities words */
341+
/* Fall through - and extract capabilities words */
340342
case 2:
341343
ret = afs_extract_data(call, false);
342344
if (ret < 0)
@@ -436,6 +438,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
436438
/* Extract the returned uuid, uniquifier, fsEndpoints count and
437439
* either the first fsEndpoint type or the volEndpoints
438440
* count if there are no fsEndpoints. */
441+
/* Fall through */
439442
case 1:
440443
ret = afs_extract_data(call, true);
441444
if (ret < 0)
@@ -476,7 +479,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
476479
afs_extract_to_buf(call, size);
477480
call->unmarshall = 2;
478481

479-
/* Extract fsEndpoints[] entries */
482+
/* Fall through - and extract fsEndpoints[] entries */
480483
case 2:
481484
ret = afs_extract_data(call, true);
482485
if (ret < 0)
@@ -529,6 +532,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
529532
* extract the type of the next endpoint when we extract the
530533
* data of the current one, but this is the first...
531534
*/
535+
/* Fall through */
532536
case 3:
533537
ret = afs_extract_data(call, true);
534538
if (ret < 0)
@@ -555,7 +559,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
555559
afs_extract_to_buf(call, size);
556560
call->unmarshall = 4;
557561

558-
/* Extract volEndpoints[] entries */
562+
/* Fall through - and extract volEndpoints[] entries */
559563
case 4:
560564
ret = afs_extract_data(call, true);
561565
if (ret < 0)
@@ -591,7 +595,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
591595
afs_extract_discard(call, 0);
592596
call->unmarshall = 5;
593597

594-
/* Done */
598+
/* Fall through - Done */
595599
case 5:
596600
ret = afs_extract_data(call, false);
597601
if (ret < 0)

0 commit comments

Comments
 (0)