Skip to content

Commit e6d303f

Browse files
committed
Avoid boolean arg for clarity
1 parent 69e6ff4 commit e6d303f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Zend/zend_ini.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,12 @@ ZEND_API bool zend_ini_parse_bool(zend_string *str)
541541
}
542542
}
543543

544-
static zend_long zend_ini_parse_quantity_internal(zend_string *value, bool signed_result, zend_string **errstr) /* {{{ */
544+
typedef enum {
545+
ZEND_INI_PARSE_QUANTITY_SIGNED,
546+
ZEND_INI_PARSE_QUANTITY_UNSIGNED,
547+
} zend_ini_parse_quantity_signed_result_t;
548+
549+
static zend_long zend_ini_parse_quantity_internal(zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
545550
{
546551
char *digits_end = NULL;
547552
char *str = ZSTR_VAL(value);
@@ -568,15 +573,15 @@ static zend_long zend_ini_parse_quantity_internal(zend_string *value, bool signe
568573
zend_ulong retval;
569574
errno = 0;
570575

571-
if (signed_result) {
576+
if (signed_result == ZEND_INI_PARSE_QUANTITY_SIGNED) {
572577
retval = (zend_ulong) ZEND_STRTOL(digits, &digits_end, 0);
573578
} else {
574579
retval = ZEND_STRTOUL(digits, &digits_end, 0);
575580
}
576581

577582
if (errno == ERANGE) {
578583
overflow = true;
579-
} else if (!signed_result) {
584+
} else if (signed_result == ZEND_INI_PARSE_QUANTITY_UNSIGNED) {
580585
/* ZEND_STRTOUL() does not report a range error when the subject starts
581586
* with a minus sign, so we check this here. Ignore "-1" as it is
582587
* commonly used as max value, for instance in memory_limit=-1. */
@@ -641,7 +646,7 @@ static zend_long zend_ini_parse_quantity_internal(zend_string *value, bool signe
641646
}
642647

643648
if (!overflow) {
644-
if (signed_result) {
649+
if (signed_result == ZEND_INI_PARSE_QUANTITY_SIGNED) {
645650
zend_long sretval = (zend_long)retval;
646651
if (sretval > 0) {
647652
overflow = (zend_long)retval > ZEND_LONG_MAX / (zend_long)factor;
@@ -689,23 +694,23 @@ static zend_long zend_ini_parse_quantity_internal(zend_string *value, bool signe
689694
smart_str_free(&interpreted);
690695
smart_str_free(&chr);
691696

692-
return (zend_long) retval;
697+
return retval;
693698
}
694699

695700
*errstr = NULL;
696-
return (zend_long) retval;
701+
return retval;
697702
}
698703
/* }}} */
699704

700705
ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr) /* {{{ */
701706
{
702-
return zend_ini_parse_quantity_internal(value, true, errstr);
707+
return zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_SIGNED, errstr);
703708
}
704709
/* }}} */
705710

706711
ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr) /* {{{ */
707712
{
708-
return (zend_ulong) zend_ini_parse_quantity_internal(value, false, errstr);
713+
return (zend_ulong) zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_UNSIGNED, errstr);
709714
}
710715
/* }}} */
711716

0 commit comments

Comments
 (0)