Re: return values of backend sub-main functions

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: return values of backend sub-main functions
Date: 2012-06-19 11:31:16
Message-ID: 1340105476.26286.17.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On ons, 2012-01-18 at 21:21 +0200, Peter Eisentraut wrote:
> On lör, 2012-01-07 at 16:41 -0500, Tom Lane wrote:
> > Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > > I suggest that we change PostgresMain(), PostmasterMain(), BackendRun(),
> > > WalSenderMain(), and WalSndLoop() to return void as well.
> >
> > I agree this code is not very consistent or useful, but one question:
> > what should the callers do if one of these functions *does* return?
>
> I was thinking of a two-pronged approach: First, add
> __attribute__((noreturn)) to the functions. This will cause a suitable
> compiler to verify on a source-code level that nothing actually returns
> from the function. And second, at the call site, put an abort(); /*
> not reached */. Together, this will make the code cleaner and more
> consistent, and will also help the compiler out a bit about the control
> flow.

Patch for 9.3 attached.

Attachment Content-Type Size
pg-noreturn-backend.patch text/x-patch 11.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dickson S. Guedes 2012-06-19 11:40:30 Re: pgsql_fdw in contrib
Previous Message Boszormenyi Zoltan 2012-06-19 11:13:26 Re: [PATCH] lock_timeout and common SIGALRM framework