From: | Tomas Vondra <tv(at)fuzzy(dot)cz> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Silly coding in pgcrypto |
Date: | 2014-11-02 21:51:31 |
Message-ID: | 5456A763.90206@fuzzy.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2.11.2014 22:34, Noah Misch wrote:
> On Sun, Nov 02, 2014 at 05:10:25AM +0100, Marko Tiikkaja wrote:
>> *** a/contrib/pgcrypto/pgp-decrypt.c
>> --- b/contrib/pgcrypto/pgp-decrypt.c
>> ***************
>> *** 1069,1075 **** pgp_skip_packet(PullFilter *pkt)
>>
>> while (res > 0)
>> res = pullf_read(pkt, 32 * 1024, &tmp);
>> ! return res < 0 ? res : 0;
>> }
>>
>> /*
>> --- 1069,1075 ----
>>
>> while (res > 0)
>> res = pullf_read(pkt, 32 * 1024, &tmp);
>> ! return res;
>
> Why is the old code silly and the new code correct?
The loop only terminates when (res > 0) is false, i.e. (res <= 0), which
makes the expression after the return statement pointless:
(res == 0) -> 0
(res < 0) -> res
So it's 'res' all the time.
Tomas
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Tiikkaja | 2014-11-02 21:53:27 | Re: Silly coding in pgcrypto |
Previous Message | Noah Misch | 2014-11-02 21:34:34 | Re: Silly coding in pgcrypto |