Skip to content

Commit 1283cc3

Browse files
committed
Fix [-Wimplicit-fallthrough] warnings in Standard extension
1 parent 1a7f830 commit 1283cc3

File tree

10 files changed

+35
-23
lines changed

10 files changed

+35
-23
lines changed

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ PHP_FUNCTION(count)
770770
return;
771771
}
772772
}
773-
/* fallthrough */
773+
fallthrough;
774774
default:
775775
zend_argument_type_error(1, "must be of type Countable|array, %s given", zend_zval_type_name(array));
776776
RETURN_THROWS();

ext/standard/dns.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,17 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
497497
add_assoc_string(subarray, "type", "MX");
498498
GETSHORT(n, cp);
499499
add_assoc_long(subarray, "pri", n);
500-
/* no break; */
500+
fallthrough;
501501
case DNS_T_CNAME:
502502
if (type == DNS_T_CNAME) {
503503
add_assoc_string(subarray, "type", "CNAME");
504504
}
505-
/* no break; */
505+
fallthrough;
506506
case DNS_T_NS:
507507
if (type == DNS_T_NS) {
508508
add_assoc_string(subarray, "type", "NS");
509509
}
510-
/* no break; */
510+
fallthrough;
511511
case DNS_T_PTR:
512512
if (type == DNS_T_PTR) {
513513
add_assoc_string(subarray, "type", "PTR");

ext/standard/exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ PHPAPI zend_string *php_escape_shell_cmd(const char *str)
358358
#else
359359
ZSTR_VAL(cmd)[y++] = '\\';
360360
#endif
361-
/* fall-through */
361+
fallthrough;
362362
default:
363363
ZSTR_VAL(cmd)[y++] = str[x];
364364

@@ -432,7 +432,7 @@ PHPAPI zend_string *php_escape_shell_arg(const char *str)
432432
ZSTR_VAL(cmd)[y++] = '\\';
433433
ZSTR_VAL(cmd)[y++] = '\'';
434434
#endif
435-
/* fall-through */
435+
fallthrough;
436436
default:
437437
ZSTR_VAL(cmd)[y++] = str[x];
438438
}

ext/standard/file.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ PHP_FUNCTION(file_put_contents)
655655
case IS_FALSE:
656656
case IS_TRUE:
657657
convert_to_string_ex(data);
658-
658+
fallthrough;
659659
case IS_STRING:
660660
if (Z_STRLEN_P(data)) {
661661
numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
@@ -703,6 +703,7 @@ PHP_FUNCTION(file_put_contents)
703703
break;
704704
}
705705
}
706+
fallthrough;
706707
default:
707708
numbytes = -1;
708709
break;
@@ -1782,7 +1783,7 @@ static const char *php_fgetcsv_lookup_trailing_spaces(const char *ptr, size_t le
17821783
if (last_chars[0] == '\r') {
17831784
return ptr - 2;
17841785
}
1785-
/* break is omitted intentionally */
1786+
fallthrough;
17861787
case '\r':
17871788
return ptr - 1;
17881789
}
@@ -2082,7 +2083,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
20822083
memcpy(tptr, hunk_begin, bptr - hunk_begin);
20832084
tptr += (bptr - hunk_begin);
20842085
hunk_begin = bptr;
2085-
/* break is omitted intentionally */
2086+
fallthrough;
20862087

20872088
case 0: {
20882089
char *new_buf;
@@ -2134,7 +2135,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
21342135
case -2:
21352136
case -1:
21362137
php_mb_reset();
2137-
/* break is omitted intentionally */
2138+
fallthrough;
21382139
case 1:
21392140
/* we need to determine if the enclosure is
21402141
* 'real' or is it escaped */
@@ -2203,7 +2204,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
22032204
case -1:
22042205
inc_len = 1;
22052206
php_mb_reset();
2206-
/* break is omitted intentionally */
2207+
fallthrough;
22072208
case 1:
22082209
if (*bptr == delimiter) {
22092210
goto quit_loop_3;
@@ -2234,7 +2235,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
22342235
case -1:
22352236
inc_len = 1;
22362237
php_mb_reset();
2237-
/* break is omitted intentionally */
2238+
fallthrough;
22382239
case 1:
22392240
if (*bptr == delimiter) {
22402241
goto quit_loop_4;

ext/standard/filters.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static php_conv_err_t php_conv_qprint_decode_convert(php_conv_qprint_decode *ins
951951
ps++, icnt--;
952952
break;
953953
}
954-
} /* break is missing intentionally */
954+
} fallthrough;
955955

956956
case 2: {
957957
if (icnt == 0) {
@@ -968,7 +968,7 @@ static php_conv_err_t php_conv_qprint_decode_convert(php_conv_qprint_decode *ins
968968
if (scan_stat != 3) {
969969
break;
970970
}
971-
} /* break is missing intentionally */
971+
} fallthrough;
972972

973973
case 3: {
974974
if (ocnt < 1) {
@@ -1763,6 +1763,8 @@ static size_t php_dechunk(char *buf, size_t len, php_chunked_filter_data *data)
17631763
if (p == end) {
17641764
return out_len;
17651765
}
1766+
/* TODO: Check if Intentional? */
1767+
fallthrough;
17661768
case CHUNK_SIZE_CR:
17671769
if (*p == '\r') {
17681770
p++;
@@ -1771,6 +1773,8 @@ static size_t php_dechunk(char *buf, size_t len, php_chunked_filter_data *data)
17711773
return out_len;
17721774
}
17731775
}
1776+
/* TODO: Check if Intentional? */
1777+
fallthrough;
17741778
case CHUNK_SIZE_LF:
17751779
if (*p == '\n') {
17761780
p++;
@@ -1786,6 +1790,8 @@ static size_t php_dechunk(char *buf, size_t len, php_chunked_filter_data *data)
17861790
data->state = CHUNK_ERROR;
17871791
continue;
17881792
}
1793+
/* TODO: Check if Intentional? */
1794+
fallthrough;
17891795
case CHUNK_BODY:
17901796
if ((size_t) (end - p) >= data->chunk_size) {
17911797
if (p != out) {
@@ -1807,6 +1813,8 @@ static size_t php_dechunk(char *buf, size_t len, php_chunked_filter_data *data)
18071813
out_len += end - p;
18081814
return out_len;
18091815
}
1816+
/* TODO: Check if Intentional? */
1817+
fallthrough;
18101818
case CHUNK_BODY_CR:
18111819
if (*p == '\r') {
18121820
p++;
@@ -1815,6 +1823,8 @@ static size_t php_dechunk(char *buf, size_t len, php_chunked_filter_data *data)
18151823
return out_len;
18161824
}
18171825
}
1826+
/* TODO: Check if Intentional? */
1827+
fallthrough;
18181828
case CHUNK_BODY_LF:
18191829
if (*p == '\n') {
18201830
p++;

ext/standard/formatted_print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
704704
zend_value_error("Missing format specifier at end of string");
705705
goto fail;
706706
}
707-
/* break missing intentionally */
707+
fallthrough;
708708

709709
default:
710710
zend_value_error("Unknown format specifier \"%c\"", *format);

ext/standard/head.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ PHP_FUNCTION(headers_sent)
313313
switch(ZEND_NUM_ARGS()) {
314314
case 2:
315315
ZEND_TRY_ASSIGN_REF_LONG(arg2, line);
316+
fallthrough;
316317
case 1:
317318
if (file) {
318319
ZEND_TRY_ASSIGN_REF_STRING(arg1, file);

ext/standard/math.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ PHP_FUNCTION(round)
300300
if (places >= 0) {
301301
RETURN_DOUBLE((double) Z_LVAL_P(value));
302302
}
303-
/* break omitted intentionally */
303+
fallthrough;
304304

305305
case IS_DOUBLE:
306306
return_val = (Z_TYPE_P(value) == IS_LONG) ? (double)Z_LVAL_P(value) : Z_DVAL_P(value);
@@ -773,7 +773,7 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
773773
fnum = (double)num;
774774
mode = 1;
775775
}
776-
/* fall-through */
776+
fallthrough;
777777
case 1: /* Float */
778778
fnum = fnum * base + c;
779779
}

ext/standard/net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr) {
7777
#ifdef AF_INET6
7878
case AF_INET6:
7979
addrlen = sizeof(struct sockaddr_in6);
80-
/* fallthrough */
80+
fallthrough;
8181
#endif
8282
case AF_INET: {
8383
zend_string *ret = zend_string_alloc(NI_MAXHOST, 0);

ext/standard/string.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,7 +2487,7 @@ PHP_FUNCTION(quotemeta)
24872487
case '(':
24882488
case ')':
24892489
*q++ = '\\';
2490-
/* break is missing _intentionally_ */
2490+
fallthrough;
24912491
default:
24922492
*q++ = c;
24932493
}
@@ -3479,7 +3479,7 @@ PHPAPI void php_stripcslashes(zend_string *str)
34793479
*target++=(char)strtol(numtmp, NULL, 16);
34803480
break;
34813481
}
3482-
/* break is left intentionally */
3482+
fallthrough;
34833483
default:
34843484
i=0;
34853485
while (source < end && *source >= '0' && *source <= '7' && i<3) {
@@ -3746,7 +3746,7 @@ zend_string *php_addslashes_sse42(zend_string *str)
37463746
case '\"':
37473747
case '\\':
37483748
*target++ = '\\';
3749-
/* break is missing *intentionally* */
3749+
fallthrough;
37503750
default:
37513751
*target++ = *source;
37523752
break;
@@ -3887,7 +3887,7 @@ PHPAPI zend_string *php_addslashes(zend_string *str)
38873887
case '\"':
38883888
case '\\':
38893889
*target++ = '\\';
3890-
/* break is missing *intentionally* */
3890+
fallthrough;
38913891
default:
38923892
*target++ = *source;
38933893
break;
@@ -4508,7 +4508,7 @@ PHP_FUNCTION(nl2br)
45084508
if ((*tmp == '\r' && *(tmp+1) == '\n') || (*tmp == '\n' && *(tmp+1) == '\r')) {
45094509
*target++ = *tmp++;
45104510
}
4511-
/* lack of a break; is intentional */
4511+
fallthrough;
45124512
default:
45134513
*target++ = *tmp;
45144514
}

0 commit comments

Comments
 (0)