Skip to content

Commit 59373a4

Browse files
committed
Merge branch 'jk/fallthrough'
Many codepaths have been updated to squelch -Wimplicit-fallthrough warnings from Gcc 7 (which is a good code hygiene). * jk/fallthrough: consistently use "fallthrough" comments in switches curl_trace(): eliminate switch fallthrough test-line-buffer: simplify command parsing
2 parents bfbc2fc + 1cf01a3 commit 59373a4

File tree

15 files changed

+30
-28
lines changed

15 files changed

+30
-28
lines changed

apply.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2920,14 +2920,15 @@ static int apply_one_fragment(struct apply_state *state,
29202920
if (plen && (ws_rule & WS_BLANK_AT_EOF) &&
29212921
ws_blank_line(patch + 1, plen, ws_rule))
29222922
is_blank_context = 1;
2923+
/* fallthrough */
29232924
case '-':
29242925
memcpy(old, patch + 1, plen);
29252926
add_line_info(&preimage, old, plen,
29262927
(first == ' ' ? LINE_COMMON : 0));
29272928
old += plen;
29282929
if (first == '-')
29292930
break;
2930-
/* Fall-through for ' ' */
2931+
/* fallthrough */
29312932
case '+':
29322933
/* --no-add does not add new lines */
29332934
if (first == '+' && state->no_add)

builtin/cat-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
113113

114114
if (textconv_object(path, obj_context.mode, &oid, 1, &buf, &size))
115115
break;
116+
/* else fallthrough */
116117

117118
case 'p':
118119
type = sha1_object_info(oid.hash, NULL);

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
436436
* update paths in the work tree, and we cannot revert
437437
* them.
438438
*/
439+
/* fallthrough */
439440
case 0:
440441
return 0;
441442
default:

builtin/remote-ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static char *strip_escapes(const char *str, const char *service,
5757
special = str[rpos];
5858
if (rpos == 1)
5959
break;
60-
/* Fall-through to error. */
60+
/* fallthrough */
6161
default:
6262
die("Bad remote-ext placeholder '%%%c'.",
6363
str[rpos]);

builtin/submodule--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,7 @@ static int push_check(int argc, const char **argv, const char *prefix)
11891189
break;
11901190
die("HEAD does not match the named branch in the superproject");
11911191
}
1192+
/* fallthrough */
11921193
default:
11931194
die("src refspec '%s' must name a ref",
11941195
rs->src);

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,7 @@ static ssize_t write_pair(int fd, const char *key, const char *value)
23552355
case '"':
23562356
case '\\':
23572357
strbuf_addch(&sb, '\\');
2358+
/* fallthrough */
23582359
default:
23592360
strbuf_addch(&sb, value[i]);
23602361
break;

convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,9 @@ static int ident_filter_fn(struct stream_filter *filter,
15451545
switch (ident->state) {
15461546
default:
15471547
strbuf_add(&ident->left, head, ident->state);
1548+
/* fallthrough */
15481549
case IDENT_SKIPPING:
1549-
/* fallthru */
1550+
/* fallthrough */
15501551
case IDENT_DRAINING:
15511552
ident_drain(ident, &output, osize_p);
15521553
}

fsck.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
588588
case S_IFREG | 0664:
589589
if (!options->strict)
590590
break;
591+
/* fallthrough */
591592
default:
592593
has_bad_modes = 1;
593594
}

http-push.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,7 @@ static int remote_exists(const char *path)
15231523
break;
15241524
case HTTP_ERROR:
15251525
error("unable to access '%s': %s", url, curl_errorstr);
1526+
/* fallthrough */
15261527
default:
15271528
ret = -1;
15281529
}

http.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,7 @@ static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size,
638638
switch (type) {
639639
case CURLINFO_TEXT:
640640
trace_printf_key(&trace_curl, "== Info: %s", data);
641-
default: /* we ignore unknown types by default */
642-
return 0;
643-
641+
break;
644642
case CURLINFO_HEADER_OUT:
645643
text = "=> Send header";
646644
curl_dump_header(text, (unsigned char *)data, size, DO_FILTER);
@@ -665,6 +663,9 @@ static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size,
665663
text = "<= Recv SSL data";
666664
curl_dump_data(text, (unsigned char *)data, size);
667665
break;
666+
667+
default: /* we ignore unknown types by default */
668+
return 0;
668669
}
669670
return 0;
670671
}

0 commit comments

Comments
 (0)