Re: Silly coding in pgcrypto

Поиск
Список
Период
Сортировка
От Noah Misch
Тема Re: Silly coding in pgcrypto
Дата
Msg-id 20141103025329.GA537868@tornado.leadboat.com
обсуждение исходный текст
Ответ на Re: Silly coding in pgcrypto  (Marko Tiikkaja <marko@joh.to>)
Список pgsql-hackers
On Sun, Nov 02, 2014 at 10:53:27PM +0100, Marko Tiikkaja wrote:
> On 11/2/14, 10:34 PM, 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?
> 
> When the loop terminates, res can only be <= 0.  If res is less than 0, res
> is returned.  In all other cases (i.e. when res == 0), 0 is returned.  The
> ternary expression is completely unnecessary.

Quite so.  Committed.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Scott Harrington
Дата:
Сообщение: Re: [JDBC] Pipelining executions to postgresql server
Следующее
От: Rushabh Lathia
Дата:
Сообщение: Re: CINE in CREATE TABLE AS ... and CREATE MATERIALIZED VIEW ...