Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Fix some sparse warnings

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:58:13

Jonathan Nieder [off-list ref] writes:
quoted hunk
How about something like the following?
diff --git i/cache.h w/cache.h
index f2915509..ba028b75 100644
--- i/cache.h
+++ w/cache.h
@@ -1124,6 +1124,7 @@ struct object_info {
 		} packed;
 	} u;
 };
+#define OBJECT_INFO_INIT { NULL, NULL, OI_CACHED, { { NULL, 0, 0 } } }
There are quite a many hits from

	$ git grep '= { *NULL *};'

only some of which are "char *var[] = { NULL }", which is perfectly
fine, but others are to initialise "struct foo" (or "foo_t" which is
typedef'ed) that share the same "writing NULL means the initialiser
knows the order of the fields".

I doubt if the above #define is a maintainable solution, and worse
yet, thinking about the fact that such a macro is necessary only for
a structure whose first field happens to be of a pointer type, it
strongly suggests me that it is not conceptually the right thing to
do.

Can't we have sparse fixed (or skip this specific warning) instead?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help