avoid negating LONG_MIN in cash_out() - Mailing list pgsql-hackers

From Zhihong Yu
Subject avoid negating LONG_MIN in cash_out()
Date
Msg-id CALNJ-vTVL6JKvEjHOnNxp50r8Tx6meKJ=GdP3ACwVOOkXhudLQ@mail.gmail.com
Whole thread Raw
Responses Re: avoid negating LONG_MIN in cash_out()
List pgsql-hackers
Hi,
In cash_out(), we have the following code:

    if (value < 0)
    {
        /* make the amount positive for digit-reconstruction loop */
        value = -value;

The negation cannot be represented in type long when the value is LONG_MIN.
It seems we can error out when LONG_MIN is detected instead of continuing with computation.

Please take a look at the patch and provide your feedback.

Thanks

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Cleaning up historical portability baggage
Next
From: Tom Lane
Date:
Subject: Re: avoid negating LONG_MIN in cash_out()