Skip to content

Commit ac2f487

Browse files
committed
ext/gmp: Refactor gmp_import_export_validate()
1 parent 31c65da commit ac2f487

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ext/gmp/gmp.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,12 @@ ZEND_FUNCTION(gmp_init)
919919
}
920920
/* }}} */
921921

922-
int gmp_import_export_validate(zend_long size, zend_long options, int *order, int *endian)
922+
static bool gmp_import_export_validate(zend_long size, zend_long options, int *order, int *endian)
923923
{
924924
if (size < 1) {
925925
/* size argument is in second position */
926926
zend_argument_value_error(2, "must be greater than or equal to 1");
927-
return FAILURE;
927+
return false;
928928
}
929929

930930
switch (options & (GMP_LSW_FIRST | GMP_MSW_FIRST)) {
@@ -936,9 +936,9 @@ int gmp_import_export_validate(zend_long size, zend_long options, int *order, in
936936
*order = 1;
937937
break;
938938
default:
939-
/* options argument is in second position */
939+
/* options argument is in third position */
940940
zend_argument_value_error(3, "cannot use multiple word order options");
941-
return FAILURE;
941+
return false;
942942
}
943943

944944
switch (options & (GMP_LITTLE_ENDIAN | GMP_BIG_ENDIAN | GMP_NATIVE_ENDIAN)) {
@@ -953,12 +953,12 @@ int gmp_import_export_validate(zend_long size, zend_long options, int *order, in
953953
*endian = 0;
954954
break;
955955
default:
956-
/* options argument is in second position */
956+
/* options argument is in third position */
957957
zend_argument_value_error(3, "cannot use multiple endian options");
958-
return FAILURE;
958+
return false;
959959
}
960960

961-
return SUCCESS;
961+
return true;
962962
}
963963

964964
/* {{{ Imports a GMP number from a binary string */
@@ -975,7 +975,7 @@ ZEND_FUNCTION(gmp_import)
975975
RETURN_THROWS();
976976
}
977977

978-
if (gmp_import_export_validate(size, options, &order, &endian) == FAILURE) {
978+
if (!gmp_import_export_validate(size, options, &order, &endian)) {
979979
RETURN_THROWS();
980980
}
981981

@@ -1004,7 +1004,7 @@ ZEND_FUNCTION(gmp_export)
10041004
RETURN_THROWS();
10051005
}
10061006

1007-
if (gmp_import_export_validate(size, options, &order, &endian) == FAILURE) {
1007+
if (!gmp_import_export_validate(size, options, &order, &endian)) {
10081008
RETURN_THROWS();
10091009
}
10101010

0 commit comments

Comments
 (0)