Re: Use C99 designated initializers for some structs

From: David Steele <david(at)pgmasters(dot)net>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use C99 designated initializers for some structs
Date: 2018-08-29 20:51:07
Message-ID: 04abaa9a-8d5d-c229-b239-21bfae184a65@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/29/18 5:14 AM, Peter Eisentraut wrote:
> On 29/08/2018 12:13, Peter Eisentraut wrote:
>> Here is a patch to change some struct initializations to use C99-style
>> designated initializers. These are just a few particularly egregious
>> cases that were hard to read and write, and error prone because of many
>> similar adjacent types.
>>
>> (The PL/Python changes currently don't compile with Python 3 because of
>> the situation described in the parallel thread "PL/Python: Remove use of
>> simple slicing API".)
>>
>> Thoughts?

+1. This is an incredible win for readability/maintainability.

One thing: I'm not sure that excluding the InvalidOid assignment in the
TopTransactionStateData initializer is a good idea. That is, it's not
clear that InvalidOid is 0.

NULL, false, and 0 seem like no-brainers, but maybe it would be better
to explicitly include constants that we define that are not obviously 0,
or maybe just all of them.

Regards,
--
-David
david(at)pgmasters(dot)net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-08-29 20:54:36 Re: BUG #15346: Replica fails to start after the crash
Previous Message Tom Lane 2018-08-29 20:41:42 Re: buildfarm: could not read block 3 in file "base/16384/2662": read only 0 of 8192 bytes