Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning
From: Junio C Hamano <hidden>
Date: 2017-08-22 18:12:32
René Scharfe [off-list ref] writes:
quoted
diff --git a/repository.c b/repository.c index 01af20dee..ceef73614 100644 --- a/repository.c +++ b/repository.c@@ -5,7 +5,7 @@ /* The main repository */ static struct repository the_repo = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0This line yells out "designated initializer" to me: + .index = &the_indexquoted
}; struct repository *the_repository = &the_repo;
Yes, but let's hold it off for a while, until at least what is
already in the tip of 'master' graduates to a released version at
the end of the current cycle. We picked reasonably quiecent parts
of the codebase and implanted uses of a few C99 features to ensure
that we get complaints and requests for revert from people on exotic
platforms, so that we can back them out easily.
cbc0f81d ("strbuf: use designated initializers in STRBUF_INIT",
2017-07-10) does the designated initializer for struct members.
512f41cf ("clean.c: use designated initializer", 2017-07-14) does
the same for array elements.
In addition, e1327023 ("grep: refactor the concept of "grep source"
into an object", 2012-02-02) inadvertently introduced the use of
trailing comma in enum definition about 5 years ago, so we know that
one is safe to use.