On Sat, Jul 13, 2019 at 3:46 AM Johannes Sixt <j6t@xxxxxxxx> wrote: > > Using only = { 0 } for zero-initialization makes the code immune to > rearrangements of the struct members. But only by forcing to set whichever is the first element to 0, which is exactly what sparse is complaining about, since it happens to be a pointer. > That is not the case with = { NULL > } because it requires that the first member is a pointer; if > rearrangement makes the first member a non-pointer, the initializations > must be adjusted. luckily sparse will complain loudly in that case as well as shown by: $ cat t.c #include <stddef.h> int main(int argc, char *argv[]) { struct { char i; char *p; } s = {NULL}; return 0; } $ sparse t.c t.c:7:10: warning: incorrect type in initializer (different base types) t.c:7:10: expected char i t.c:7:10: got void * Carlo