Re: return values of backend sub-main functions

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: return values of backend sub-main functions
Date: 2012-06-20 04:29:31
Message-ID: CAK3UJRG3xLBcm1njL3y34gnUZZpgpbGX2oWc8FyT5CFLwRL=rg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 19, 2012 at 4:31 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> 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.

+1. Should this call around line 4114 of postmaster.c not bother with
proc_exit() anymore:

/* And run the backend */
proc_exit(BackendRun(&port));

I was hoping that some of the clang static analyzer complaints would
go away with these changes, though it looks like only one[1] did. I
would be interested to see the similar elog/ereport patch you
mentioned previously, perhaps that will eliminate a bunch of warnings.

Josh

[1] this one goes away with the patch:
http://kupershmidt.org/pg/scan-build-2012-06-19-master/report-E2cUqJ.html#EndPath

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2012-06-20 04:39:30 Re: Allow WAL information to recover corrupted pg_controldata
Previous Message Greg Smith 2012-06-20 04:06:16 Re: Backport of fsync queue compaction