Skip to content

Commit 7aebffa

Browse files
committed
Fix [-Wimplicit-fallthrough] warnings in SPL extension
1 parent 50dd081 commit 7aebffa

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

ext/spl/spl_array.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,22 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, spl_array_object *
300300
offset_key = Z_STR_P(offset);
301301
fetch_dim_string:
302302
retval = zend_symtable_find(ht, offset_key);
303+
/* TODO Combine both branches as only the RW case is different? */
303304
if (retval) {
304305
if (Z_TYPE_P(retval) == IS_INDIRECT) {
305306
retval = Z_INDIRECT_P(retval);
306307
if (Z_TYPE_P(retval) == IS_UNDEF) {
307308
switch (type) {
308309
case BP_VAR_R:
309310
zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset_key));
311+
fallthrough;
310312
case BP_VAR_UNSET:
311313
case BP_VAR_IS:
312314
retval = &EG(uninitialized_zval);
313315
break;
314316
case BP_VAR_RW:
315317
zend_error(E_WARNING,"Undefined array key \"%s\"", ZSTR_VAL(offset_key));
318+
fallthrough;
316319
case BP_VAR_W: {
317320
ZVAL_NULL(retval);
318321
}
@@ -323,12 +326,14 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, spl_array_object *
323326
switch (type) {
324327
case BP_VAR_R:
325328
zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset_key));
329+
fallthrough;
326330
case BP_VAR_UNSET:
327331
case BP_VAR_IS:
328332
retval = &EG(uninitialized_zval);
329333
break;
330334
case BP_VAR_RW:
331335
zend_error(E_WARNING,"Undefined array key \"%s\"", ZSTR_VAL(offset_key));
336+
fallthrough;
332337
case BP_VAR_W: {
333338
zval value;
334339
ZVAL_NULL(&value);
@@ -357,12 +362,14 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, spl_array_object *
357362
switch (type) {
358363
case BP_VAR_R:
359364
zend_error(E_WARNING, "Undefined array key " ZEND_LONG_FMT, index);
365+
fallthrough;
360366
case BP_VAR_UNSET:
361367
case BP_VAR_IS:
362368
retval = &EG(uninitialized_zval);
363369
break;
364370
case BP_VAR_RW:
365371
zend_error(E_WARNING, "Undefined array key " ZEND_LONG_FMT, index);
372+
fallthrough;
366373
case BP_VAR_W: {
367374
zval value;
368375
ZVAL_UNDEF(&value);

ext/spl/spl_directory.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,21 +2355,21 @@ PHP_METHOD(SplFileObject, fgetcsv)
23552355
} else {
23562356
escape = (unsigned char) esc[0];
23572357
}
2358-
/* no break */
2358+
fallthrough;
23592359
case 2:
23602360
if (e_len != 1) {
23612361
zend_argument_value_error(2, "must be a single character");
23622362
RETURN_THROWS();
23632363
}
23642364
enclosure = enclo[0];
2365-
/* no break */
2365+
fallthrough;
23662366
case 1:
23672367
if (d_len != 1) {
23682368
zend_argument_value_error(1, "must be a single character");
23692369
RETURN_THROWS();
23702370
}
23712371
delimiter = delim[0];
2372-
/* no break */
2372+
fallthrough;
23732373
case 0:
23742374
break;
23752375
}
@@ -2405,21 +2405,21 @@ PHP_METHOD(SplFileObject, fputcsv)
24052405
zend_argument_value_error(4, "must be empty or a single character");
24062406
RETURN_THROWS();
24072407
}
2408-
/* no break */
2408+
fallthrough;
24092409
case 3:
24102410
if (e_len != 1) {
24112411
zend_argument_value_error(3, "must be a single character");
24122412
RETURN_THROWS();
24132413
}
24142414
enclosure = enclo[0];
2415-
/* no break */
2415+
fallthrough;
24162416
case 2:
24172417
if (d_len != 1) {
24182418
zend_argument_value_error(2, "must be a single character");
24192419
RETURN_THROWS();
24202420
}
24212421
delimiter = delim[0];
2422-
/* no break */
2422+
fallthrough;
24232423
case 1:
24242424
case 0:
24252425
break;
@@ -2457,21 +2457,21 @@ PHP_METHOD(SplFileObject, setCsvControl)
24572457
zend_argument_value_error(3, "must be empty or a single character");
24582458
RETURN_THROWS();
24592459
}
2460-
/* no break */
2460+
fallthrough;
24612461
case 2:
24622462
if (e_len != 1) {
24632463
zend_argument_value_error(2, "must be a single character");
24642464
RETURN_THROWS();
24652465
}
24662466
enclosure = enclo[0];
2467-
/* no break */
2467+
fallthrough;
24682468
case 1:
24692469
if (d_len != 1) {
24702470
zend_argument_value_error(1, "must be a single character");
24712471
RETURN_THROWS();
24722472
}
24732473
delimiter = delim[0];
2474-
/* no break */
2474+
fallthrough;
24752475
case 0:
24762476
break;
24772477
}

ext/spl/spl_iterators.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,15 @@ static void spl_recursive_it_move_forward_ex(spl_recursive_it_object *object, zv
243243
zend_clear_exception();
244244
}
245245
}
246-
/* fall through */
246+
fallthrough;
247247
case RS_START:
248248
if (iterator->funcs->valid(iterator) == FAILURE) {
249249
break;
250250
}
251251
object->iterators[object->level].state = RS_TEST;
252252
/* break; */
253+
/* TODO: Check this is correct */
254+
fallthrough;
253255
case RS_TEST:
254256
ce = object->iterators[object->level].ce;
255257
zobject = &object->iterators[object->level].zobject;

0 commit comments

Comments
 (0)