Thread (9 messages) 9 messages, 3 authors, 2021-01-20

Re: [RFC PATCH 4/8] mm: Separate fault info out of 'struct vm_fault'

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2021-01-14 19:10:14
Also in: linux-mm, lkml

On Thu, Jan 14, 2021 at 11:00 AM Will Deacon [off-list ref] wrote:
I tried that initially, but I found that I had to make all of the
members const to get it to work, at which point the anonymous struct
wasn't really adding anything. Did I just botch the syntax?
I'm not sure what you tried. But this stupid test-case sure works for me:

    struct hello {
        const struct {
                unsigned long address;
        };
        unsigned int flags;
    };

    extern int fn(struct hello *);

    int test(void)
    {
        struct hello a = {
                .address = 1,
        };
        a.flags = 0;
        return fn(&a);
    }

and because "address" is in that unnamed constant struct, you can only
set it within that initializer, and cannot do

        a.address = 0;

without an error (the way you _can_ do "a.flags = 0").

I don't see naming the struct making a difference - apart from forcing
that big rename patch, of course.

But maybe we're talking about different issues?

            Linus

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help