From: Kees Cook <keescook@chromium.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] treewide: Remove unnamed static initializations to 0
Date: Tue, 14 Sep 2021 09:50:53 -0700 [thread overview]
Message-ID: <202109140938.65A989239@keescook> (raw)
In-Reply-To: <CAHk-=wiyq84MKRd1F4d8SGTcTgdd3ktwPr7_9s8tjgKRx_+2kA@mail.gmail.com>
On Mon, Sep 13, 2021 at 12:40:41PM -0700, Linus Torvalds wrote:
> On Fri, Sep 10, 2021 at 3:52 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > Since "= { 0 }" and "= { }" have the same meaning ("incomplete
> > initializer") they will both initialize the given variable to zero
> > (modulo padding games).
> >
> > After this change, I can almost build the "allmodconfig" target with
> > GCC 4.9 again.
> >
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> > With this patch and the following three, I can build with gcc 4.9 again:
> > https://lore.kernel.org/lkml/20210910223332.3224851-1-keescook@chromium.org/
> > https://lore.kernel.org/lkml/20210910223409.3225001-1-keescook@chromium.org/
> > https://lore.kernel.org/lkml/20210910223613.3225685-1-keescook@chromium.org/
> > I look forward to raising our minimum GCC version again! :)
>
> So this was one of the patches I left in my pending queue, and I don't
> exactly hate it, but given the option to just say "don't use gcc-4.9"
> and applying this big patch, I did the former.
Yeah, I think that's best.
> That said, one of the reasons I didn't like the patch that much is
> that it seems to be a mindless "just search-and-replace everything",
> very much for initializers that didn't complain even with gcc-4.9, and
> that were entirely correct.
I was using Coccinelle to minimize the impact.
> I would _not_ mind a patch that actually fixed only the places where
> it actually _is_ a question of missing braces, and we have an unnamed
> union or something like that.
>
> So some of the gcc-4.9 warnings certainly looked at least _somewhat_
> reasonable for a compiler that didn't do unnamed unions or structures
> very well.
>
> And I wouldn't mind replacing those. But this patch seems to then
> change entirely correct code that no reasonable compiler could
> possibly warn about. I wonder if some coccinelle script or other would
> find a much more reasonable subset?
Right -- for example I excluded all 1-dimensional scalar array
initializers. The warning comes from (IIUC) compound types (i.e. a
struct or union within another struct or union).
> With the gcc-4.9 support being dropped, that probably doesn't matter
> any more, of course. But I just wanted to say that I didn't hate the
> patch, but that it seemed to be too much of an automated hammer for
> the problem that could be solved a lot more surgically.
Yup, I'd much rather just leave all this as-is. It's effectively a
20,000 line white-space change, since there should be no actual binary
output difference. When I spot-checked this, it was true, which is what
I was expecting.
> The three remaining patches you point at look interesting, although I
> think that third one looks decidedly odd. Why not add the 'const' in
> the callers instead of removing it from the function? And why don't I
> see those warnings - is this some compiler bug?
Looks like a GCC 4.9 bug, yes. The other two I'll continue to pursue,
since they're general correctness fixes, even if modern GCC deals with
them happily:
> > https://lore.kernel.org/lkml/20210910223332.3224851-1-keescook@chromium.org/
> > https://lore.kernel.org/lkml/20210910223409.3225001-1-keescook@chromium.org/
-Kees
--
Kees Cook
prev parent reply other threads:[~2021-09-14 16:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-10 22:52 [PATCH] treewide: Remove unnamed static initializations to 0 Kees Cook
2021-09-10 23:23 ` Alexei Starovoitov
2021-09-11 2:08 ` Kees Cook
2021-09-13 19:40 ` Linus Torvalds
2021-09-14 16:50 ` Kees Cook [this message]
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=202109140938.65A989239@keescook \
--to=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox