[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87plaieexu.fsf@prevas.dk>
Date: Sun, 19 Oct 2025 23:53:33 +0200
From: Rasmus Villemoes <ravi@...vas.dk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [GIT PULL] Btrfs fixes for 6.18-rc2
On Thu, Oct 16 2025, Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> On Thu, 16 Oct 2025 at 10:00, David Sterba <dsterba@...e.com> wrote:
>>
>> - reorder send context structure to avoid -Wflex-array-member-not-at-end
>> warning
>
> Ok, I took a look because this sounded like a bad bug, but that flex
> array member really isn't a flex array at all.
>
> It's clearly intended to be a fixed-size inline array, just using a
> flex array for syntacting reasons.
>
[...]
>
> Sadly, I can't think of a way to have the compiler just calculate the
> right size at structure definition time without just having to repeat
> the whole structure definition twice.
>
> So that flex array may be the best approach even if it has these downsides.
>
> Does anybody know of some C language trick to get the remaining
> padding size without repeating the struct definition?
>
> "offsetof()" sadly does not work until the structure has been fully
> defined, so you can't use the "obvious" trick
>
> char buffer[256 - offsetof(struct .., buffer)];
>
I think this has come up before [*]. Doesn't -fms-extensions allow one
to do
struct __fs_path {
char *start;
char *end;
...
};
static_assert(sizeof(struct __fs_path) < 256);
struct fs_path {
struct __fs_path;
char inline_buf[256 - sizeof(struct __fs_path)];
};
and access every member of fs_path as one used to? With the bonus that
it's a real array with known size.
Rasmus
[*]
https://lore.kernel.org/lkml/CAHk-=wh6Ra8=dBUTo1vKT5Wao1hFq3+2x1mDwmBcVx2Ahp_rag@mail.gmail.com/
Powered by blists - more mailing lists