lkml.org 
[lkml]   [2021]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC PATCH 4/8] mm: Separate fault info out of 'struct vm_fault'
On Thu, Jan 14, 2021 at 11:00 AM Will Deacon <will@kernel.org> 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

\
 
 \ /
  Last update: 2021-01-14 20:12    [W:0.049 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site