Skip to content

Commit 10a9ba2

Browse files
committed
Fix [-Wimplicit-fallthrough] warnings in Standard extension
1 parent 128fbd1 commit 10a9ba2

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
@@ -721,7 +721,7 @@ PHP_FUNCTION(count)
721721
return;
722722
}
723723
}
724-
/* fallthrough */
724+
fallthrough;
725725
default:
726726
zend_argument_type_error(1, "must be of type Countable|array, %s given", zend_zval_type_name(array));
727727
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
@@ -651,7 +651,7 @@ PHP_FUNCTION(file_put_contents)
651651
case IS_FALSE:
652652
case IS_TRUE:
653653
convert_to_string(data);
654-
654+
fallthrough;
655655
case IS_STRING:
656656
if (Z_STRLEN_P(data)) {
657657
numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
@@ -699,6 +699,7 @@ PHP_FUNCTION(file_put_contents)
699699
break;
700700
}
701701
}
702+
fallthrough;
702703
default:
703704
numbytes = -1;
704705
break;
@@ -1774,7 +1775,7 @@ static const char *php_fgetcsv_lookup_trailing_spaces(const char *ptr, size_t le
17741775
if (last_chars[0] == '\r') {
17751776
return ptr - 2;
17761777
}
1777-
/* break is omitted intentionally */
1778+
fallthrough;
17781779
case '\r':
17791780
return ptr - 1;
17801781
}
@@ -2074,7 +2075,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
20742075
memcpy(tptr, hunk_begin, bptr - hunk_begin);
20752076
tptr += (bptr - hunk_begin);
20762077
hunk_begin = bptr;
2077-
/* break is omitted intentionally */
2078+
fallthrough;
20782079

20792080
case 0: {
20802081
char *new_buf;
@@ -2126,7 +2127,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
21262127
case -2:
21272128
case -1:
21282129
php_mb_reset();
2129-
/* break is omitted intentionally */
2130+
fallthrough;
21302131
case 1:
21312132
/* we need to determine if the enclosure is
21322133
* 'real' or is it escaped */
@@ -2195,7 +2196,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
21952196
case -1:
21962197
inc_len = 1;
21972198
php_mb_reset();
2198-
/* break is omitted intentionally */
2199+
fallthrough;
21992200
case 1:
22002201
if (*bptr == delimiter) {
22012202
goto quit_loop_3;
@@ -2226,7 +2227,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
22262227
case -1:
22272228
inc_len = 1;
22282229
php_mb_reset();
2229-
/* break is omitted intentionally */
2230+
fallthrough;
22302231
case 1:
22312232
if (*bptr == delimiter) {
22322233
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
@@ -2490,7 +2490,7 @@ PHP_FUNCTION(quotemeta)
24902490
case '(':
24912491
case ')':
24922492
*q++ = '\\';
2493-
/* break is missing _intentionally_ */
2493+
fallthrough;
24942494
default:
24952495
*q++ = c;
24962496
}
@@ -3482,7 +3482,7 @@ PHPAPI void php_stripcslashes(zend_string *str)
34823482
*target++=(char)strtol(numtmp, NULL, 16);
34833483
break;
34843484
}
3485-
/* break is left intentionally */
3485+
fallthrough;
34863486
default:
34873487
i=0;
34883488
while (source < end && *source >= '0' && *source <= '7' && i<3) {
@@ -3749,7 +3749,7 @@ zend_string *php_addslashes_sse42(zend_string *str)
37493749
case '\"':
37503750
case '\\':
37513751
*target++ = '\\';
3752-
/* break is missing *intentionally* */
3752+
fallthrough;
37533753
default:
37543754
*target++ = *source;
37553755
break;
@@ -3890,7 +3890,7 @@ PHPAPI zend_string *php_addslashes(zend_string *str)
38903890
case '\"':
38913891
case '\\':
38923892
*target++ = '\\';
3893-
/* break is missing *intentionally* */
3893+
fallthrough;
38943894
default:
38953895
*target++ = *source;
38963896
break;
@@ -4511,7 +4511,7 @@ PHP_FUNCTION(nl2br)
45114511
if ((*tmp == '\r' && *(tmp+1) == '\n') || (*tmp == '\n' && *(tmp+1) == '\r')) {
45124512
*target++ = *tmp++;
45134513
}
4514-
/* lack of a break; is intentional */
4514+
fallthrough;
45154515
default:
45164516
*target++ = *tmp;
45174517
}

0 commit comments

Comments
 (0)