Re: Build failure with GCC 15 due to -Werror=unterminated-string-initialization
From: Al Viro
Date: Wed Oct 02 2024 - 17:54:24 EST
On Wed, Oct 02, 2024 at 10:46:56PM +0100, Al Viro wrote:
> Huh? That makes no sense whatsoever - you get a single-element
> array of 3-element arrays of pointers to char.
>
> What you have written is equivalent to
> static char *s1 = ".\0\0";
> static char *s2 = "..\0";
> static char *match_root[1][3] = {[0][0] = s1, [0][1] = s2, [0][2] = NULL};
>
> and match_root[0] is *NOT* a pointer to char anymore.
>
> Just lose the last \0 in each of those string literals...
... and looking at the actual code using that, just lose the entire
array -
if (memcmp(dir_entry[0].de_fname, ".", 2) ||
memcmp(dir_entry[1].de_fname, "..", 3))
error = 1;
and be done with that.