Skip to content

Gmp warning to error #5882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed

Gmp warning to error #5882

wants to merge 14 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 21, 2020

This gets rids of most false returns.

@Girgias Girgias force-pushed the gmp-warning-to-error branch 3 times, most recently from 4c07065 to a0d7f93 Compare July 22, 2020 12:31
@Girgias Girgias force-pushed the gmp-warning-to-error branch from a0d7f93 to c3789cf Compare July 31, 2020 12:39
@Girgias
Copy link
Member Author

Girgias commented Jul 31, 2020

@kocsismate can you have a look at some of the error messages in here?

@Girgias
Copy link
Member Author

Girgias commented Aug 3, 2020

Are there other issues/objections to this? Or can I merge this before FF gets tagged on Tuesday?

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the signature changes :)

@Girgias Girgias force-pushed the gmp-warning-to-error branch from e1c3356 to 85a4dbe Compare August 4, 2020 15:46
ext/gmp/gmp.c Outdated
@@ -381,6 +384,10 @@ static int gmp_do_operation_ex(zend_uchar opcode, zval *result, zval *op1, zval
DO_BINARY_UI_OP_EX(mpz_tdiv_q, gmp_mpz_tdiv_q_ui, 1);
case ZEND_MOD:
DO_BINARY_UI_OP_EX(mpz_mod, gmp_mpz_mod_ui, 1);
if (UNEXPECTED(EG(exception))) {
return FAILURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually necessary to return failure on exception here? I think if we throw, this should still be success, otherwise we're going to try calling do_operation on the second operand again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to drop this again but the DO_BINARY_UI_OP_EX macro does exactly that:

#define DO_BINARY_UI_OP_EX(op, uop, check_b_zero)       \
	gmp_zval_binary_ui_op(                              \
		result, op1, op2, op, uop, check_b_zero         \
	);                                                  \
	if (UNEXPECTED(EG(exception))) { return FAILURE; }  \
	return SUCCESS;

ext/gmp/gmp.c Outdated
RETURN_FALSE;
}
FETCH_GMP_ZVAL(gmpnum, a_arg, temp_a, 1);
FREE_GMP_TEMP(temp_a);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this function just accept int instead? Makes little sense to convert to GMP first and then convert back to integer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the function should be able to accept a GMP object, but it's true that this code makes little sense atm.

@Girgias Girgias force-pushed the gmp-warning-to-error branch from 85a4dbe to b0c77ff Compare August 6, 2020 12:18
@php-pulls php-pulls closed this in e208cb2 Aug 7, 2020
@Girgias Girgias deleted the gmp-warning-to-error branch August 7, 2020 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants