Re: pg_archivecleanup bug

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin Grittner <kgrittn(at)ymail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_archivecleanup bug
Date: 2014-03-19 18:02:50
Message-ID: 20140319180250.GD16122@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 19, 2014 at 09:59:19AM +0200, Heikki Linnakangas wrote:
> >Would people accept?
> >
> > for (errno = 0; (dirent = readdir(dir)) != NULL; errno = 0)
> >
> >That would keep the errno's together and avoid the 'continue' additions.
>
> That's clever. A less clever way would be:
>
> for (;;)
> {
> errno = 0;
> if ((dirent = readdir(dir)) != NULL)
> break;
>
> ...
> }
>
> I'm fine with either, but that's how I would naturally write it.
>
> Yet another way would be to have a wrapper function for readdir that
> resets errno, and just replace the current readdir() calls with
> that.
>
> And now that I look at initdb.c, walkdir is using the comma
> expression for this already. So there's some precedence, and it
> doesn't actually look that bad. So I withdraw my objection for that
> approach; I'm fine with any of the discussed alternatives, really.

OK, let's go with the comma. Ironically, the for() loop would be an odd
way to avoid commas as 'for' uses commas often:

for (i = 0, j = 1; i < 10; i++, j++)

The attached patch is slightly updated. I will apply it to head and all
the back branches, including the stylistic change to pg_resetxlog (for
consistency) and remove the MinGW block in head.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
readdir.diff text/x-diff 15.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-03-19 18:12:59 Re: Patch: show relation and tuple infos of a lock to acquire
Previous Message Alvaro Herrera 2014-03-19 17:37:50 Re: Wiki Page Draft for upcoming release