Re: [PATCH 05/27] object-store: move packed_git and packed_git_mru to object store
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 21, 2018, 21:51 UTC
- Message-ID
- <xmqqy3jmxb8s.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180221015430.96054-6-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 9 quoted lines
> +
> +/*
> + * The mru list_head is supposed to be initialized using
> + * the LIST_HEAD macro, assigning prev/next to itself.
> + * However this doesn't work in this case as some compilers dislike
> + * that macro on member variables. Use NULL instead as that is defined
> + * and accepted, deferring the real init to prepare_packed_git_mru(). */
> +#define __MRU_INIT { NULL, NULL }
> +#define RAW_OBJECT_STORE_INIT { NULL, NULL, __MRU_INIT, NULL, NULL }I do not think it has to be this way to abuse two NULLs, if you faithfully mimicked how LIST_HEAD() macro is constructed. The reason why it does not try to introduce
struct list_head x = LIST_HEAD_INIT;
and instead, uses
LIST_HEAD(x);
is because of the need for self referral. If we learn from it, we can do the same, i.e. instead of doing
struct raw_object_store x = RAW_OBJECT_STORE_INIT;
we can do
RAW_OBJECT_STORE(x);
that expands to
struct raw_object_store x = {
...
{ &x.packed_git_mru, &x.packed_git_mru },
...
};no? Then we do not need such a lengthy comment that reads only like an excuse ;-)