Skip to content

Fix Coverity CID-1420310: cast PY_TIMEOUT_MAX to _Py_time_t #4646

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

Merged
merged 1 commit into from
Nov 30, 2017
Merged

Fix Coverity CID-1420310: cast PY_TIMEOUT_MAX to _Py_time_t #4646

merged 1 commit into from
Nov 30, 2017

Conversation

vstinner
Copy link
Member

Fix the following false-alarm warning:

Result is not floating-point
(UNINTENDED_INTEGER_DIVISION)integer_division: Dividing integer
expressions 9223372036854775807LL and 1000LL, and then converting
the integer quotient to type double. Any remainder, or fractional
part of the quotient, is ignored.

To compute and use a non-integer quotient, change or cast either
operand to type double. If integer division is intended, consider
indicating that by casting the result to type long long .

@tiran
Copy link
Member

tiran commented Nov 30, 2017

I think you want (double)(((_Py_time_t)PY_TIMEOUT_MAX )* 1e-6)

Fix the following false-alarm Coverity warning:

    Result is not floating-point
    (UNINTENDED_INTEGER_DIVISION)integer_division: Dividing integer
    expressions 9223372036854775807LL and 1000LL, and then converting
    the integer quotient to type double. Any remainder, or fractional
    part of the quotient, is ignored.

    To compute and use a non-integer quotient, change or cast either
    operand to type double. If integer division is intended, consider
    indicating that by casting the result to type long long .
@vstinner
Copy link
Member Author

On IRC, @tiran and me agreed on timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6; :-)

@vstinner vstinner merged commit c319eee into python:master Nov 30, 2017
@vstinner vstinner deleted the coverity_timeout_max branch November 30, 2017 22:03
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.

4 participants