From: Al Viro <viro@zeniv.linux.org.uk>
To: David Laight <David.Laight@aculab.com>
Cc: Brahmajit Das <brahmajit.xyz@gmail.com>,
"brauner@kernel.org" <brauner@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] fs/qnx6: Fix building with GCC 15
Date: Sun, 6 Oct 2024 21:00:46 +0100 [thread overview]
Message-ID: <20241006200046.GF4017910@ZenIV> (raw)
In-Reply-To: <665bcd89cf5f4679a38e9a84fa0ba42a@AcuMS.aculab.com>
On Sun, Oct 06, 2024 at 07:38:07PM +0000, David Laight wrote:
> ...
> > 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.
memcmp(), please. strcmp() is _not_ guaranteed to be safe without both being
NUL-terminated; yes, compiler will almost simplify that in case when one of
the arguments is a string literal, but it's better to do straight memcmp() in
this case. It's not worth trying to be fancy there...
next prev parent reply other threads:[~2024-10-06 20:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 21:16 Build failure with GCC 15 due to -Werror=unterminated-string-initialization Brahmajit
2024-10-02 21:46 ` Al Viro
2024-10-02 21:54 ` Al Viro
2024-10-03 6:52 ` Brahmajit
2024-10-04 9:49 ` [PATCH 1/1] fs/qnx6: Fix building with GCC 15 Brahmajit Das
2024-10-04 18:44 ` Al Viro
2024-10-04 19:51 ` Brahmajit
2024-10-04 19:51 ` [PATCH v2 " Brahmajit Das
2024-11-15 5:03 ` Al Viro
2024-12-02 4:29 ` Al Viro
2024-12-03 9:41 ` Christian Brauner
2024-10-06 19:38 ` [PATCH " David Laight
2024-10-06 20:00 ` Al Viro [this message]
2024-10-06 23:05 ` Brahmajit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241006200046.GF4017910@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=David.Laight@aculab.com \
--cc=brahmajit.xyz@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.