Re: do {} while (0) nitpick

From: Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, John Naylor <john(dot)naylor(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: do {} while (0) nitpick
Date: 2020-05-04 08:38:03
Message-ID: CACACo5Q-cfkChVzRMjAi=uvoPe4MLM8V=SUpAkPbDr=n3iB01A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 1, 2020 at 3:52 AM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
> On Thu, Apr 30, 2020 at 09:51:10PM -0400, Tom Lane wrote:
> > John Naylor <john(dot)naylor(at)2ndquadrant(dot)com> writes:
> > > As I understand it, the point of having "do {} while (0)" in a
> > > multi-statement macro is to turn it into a simple statement.
> >
> > Right.
> >
> > > As such,
> > > ending with a semicolon in both the macro definition and the
> > > invocation will turn it back into multiple statements, creating
> > > confusion if someone were to invoke the macro in an "if" statement.
> >
> > Yeah. I'd call these actual bugs, and perhaps even back-patch worthy.
>
> Agreed. Those semicolons could easily create bugs.

It was a while ago that I last checked our Developer guide over at
PostgreSQL wiki website, but I wonder if this is a sort of issue that
modern linters would be able to recognize?

The only hit for "linting" search on the wiki is this page referring to the
developer meeting in Ottawa about a year ago:
https://wiki.postgresql.org/wiki/PgCon_2019_Developer_Meeting

> Other major projects include:
> ...
> Code linting

Anybody aware what's the current status of that effort?

Cheers,
--
Alex

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-05-04 09:24:26 Re: tablespace_map code cleanup
Previous Message Juan José Santamaría Flecha 2020-05-04 07:45:54 Re: Postgres Windows build system doesn't work with python installed in Program Files