Stefan Beller <sbel...@google.com> writes:

> +
> +/*
> + * 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 ;-)

Reply via email to