Re: [PATCH 0/5] cleaning up read_object() family of functions
- From
Jeff King <peff@peff.net>
- Date
- Jan 11, 2023, 20:30 UTC
- Message-ID
- <Y78cWKKXz944pWBS@coredump.intra.peff.net>
- In-Reply-To
- <6c896cc8-2da9-a448-4ab6-2dc535fb0e2b@github.com>
On Wed, Jan 11, 2023 at 03:17:58PM -0500, Derrick Stolee wrote:
Show 17 quoted lines
> > For example, here's an attempt to let the caller use designated
> > initializers to set up the query struct:
>
> > + struct object_info oi = OBJECT_INFO(.typep = type,
> > + .sizep = size,
> > + .contentp = &data);
>
> Your macro expansion creates this format:
>
> struct object_info oi = {
> .type = type,
> .sizep = size,
> .contentp = &data,
> };
>
> And even this expansion looks a bit better than the inline
> updates:There's a subtle assumption in the expanded initializer, though, which is that everything not specified is OK to be zero-initialized. That works for object_info, but not for arbitrary structs (which is why we have these INIT macros in the first place).
-Peff