Re: return values of backend sub-main functions

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: return values of backend sub-main functions
Дата
Msg-id CA+Tgmob1TOMLuBdVb8fGVe8yg7uO6wR+kZksgQRKUZnxuRes9w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: return values of backend sub-main functions  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
On Tue, Jun 19, 2012 at 7:31 AM, Peter Eisentraut <peter_e@gmx.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@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.
>
> Patch for 9.3 attached.

Seems reasonable on a quick read-through.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: pl/perl and utf-8 in sql_ascii databases
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [PATCH 04/16] Add embedded list interface (header only)