Skip to content

Commit 1109118

Browse files
committed
Fix [-Wimplicit-fallthrough] warnings in SPL extension
1 parent d8003ec commit 1109118

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
@@ -2340,21 +2340,21 @@ PHP_METHOD(SplFileObject, fgetcsv)
23402340
} else {
23412341
escape = (unsigned char) esc[0];
23422342
}
2343-
/* no break */
2343+
fallthrough;
23442344
case 2:
23452345
if (e_len != 1) {
23462346
zend_argument_value_error(2, "must be a single character");
23472347
RETURN_THROWS();
23482348
}
23492349
enclosure = enclo[0];
2350-
/* no break */
2350+
fallthrough;
23512351
case 1:
23522352
if (d_len != 1) {
23532353
zend_argument_value_error(1, "must be a single character");
23542354
RETURN_THROWS();
23552355
}
23562356
delimiter = delim[0];
2357-
/* no break */
2357+
fallthrough;
23582358
case 0:
23592359
break;
23602360
}
@@ -2390,21 +2390,21 @@ PHP_METHOD(SplFileObject, fputcsv)
23902390
zend_argument_value_error(4, "must be empty or a single character");
23912391
RETURN_THROWS();
23922392
}
2393-
/* no break */
2393+
fallthrough;
23942394
case 3:
23952395
if (e_len != 1) {
23962396
zend_argument_value_error(3, "must be a single character");
23972397
RETURN_THROWS();
23982398
}
23992399
enclosure = enclo[0];
2400-
/* no break */
2400+
fallthrough;
24012401
case 2:
24022402
if (d_len != 1) {
24032403
zend_argument_value_error(2, "must be a single character");
24042404
RETURN_THROWS();
24052405
}
24062406
delimiter = delim[0];
2407-
/* no break */
2407+
fallthrough;
24082408
case 1:
24092409
case 0:
24102410
break;
@@ -2442,21 +2442,21 @@ PHP_METHOD(SplFileObject, setCsvControl)
24422442
zend_argument_value_error(3, "must be empty or a single character");
24432443
RETURN_THROWS();
24442444
}
2445-
/* no break */
2445+
fallthrough;
24462446
case 2:
24472447
if (e_len != 1) {
24482448
zend_argument_value_error(2, "must be a single character");
24492449
RETURN_THROWS();
24502450
}
24512451
enclosure = enclo[0];
2452-
/* no break */
2452+
fallthrough;
24532453
case 1:
24542454
if (d_len != 1) {
24552455
zend_argument_value_error(1, "must be a single character");
24562456
RETURN_THROWS();
24572457
}
24582458
delimiter = delim[0];
2459-
/* no break */
2459+
fallthrough;
24602460
case 0:
24612461
break;
24622462
}

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)