RE: [PATCH 1/1] fs/qnx6: Fix building with GCC 15

From: David Laight
Date: Sun Oct 06 2024 - 15:39:13 EST


...
> would explain what was really going on - the point is not to make gcc STFU, it's
> to make the code more straightforward. The warning is basically "it smells
> somewhat fishy around >here<, might be worth taking a look". And yes, it turned
> out to be fishy; minimal "make it STFU" would be to strip those NULs from
> the initializers (i.e. just go for static char match_root[2][3] = {".", ".."}; -
> an array initializer is zero-padded if it's shorter than the array), but that
> wasn't the only, er, oddity in that code.

Indeed - looks like it is checking that the first two directory entries
are "." and ".." in about the most complex way possible.

I have vague recollections on some code that ignored the first two entries
because they 'must be "." and ".."' - and then failed because some filesystem
(and I can't even remember the O/S) didn't meet its expectations!

A simple:
if (strcmp(dir_entry[0].de_fname, ".") || strcmp(dir_entry[1].de_fname, ".."))
error = 1;
would suffice.
The compiler ought to completely inline them.
On x86 to:
error |= *(u16 *)dir_entry[0].de_fname ^ '.';
error |= (*(u32 *)dir_entry[1].de_fname & 0xffffff) ^ ('.' * 0x101);
but I bet it doesn't!
(and it isn't quite the same)

David.

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)