Re: return values of backend sub-main functions - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: return values of backend sub-main functions
Date
Msg-id 1326914505.9180.6.camel@vanquo.pezone.net
Whole thread Raw
In response to Re: return values of backend sub-main functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: return values of backend sub-main functions  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On lör, 2012-01-07 at 16:41 -0500, Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.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.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: lots of unused variable warnings in assert-free builds
Next
From: Andres Freund
Date:
Subject: Re: Command Triggers