[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXJAmzxOxYHR+nM8qhFx2DrCD8dbPyzF-xsv40p3tO6EdDP2g@mail.gmail.com>
Date: Wed, 21 May 2025 22:31:24 -0700
From: John Ousterhout <ouster@...stanford.edu>
To: Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, edumazet@...gle.com, horms@...nel.org,
kuba@...nel.org
Subject: Re: [PATCH net-next v8 02/15] net: homa: create homa_wire.h
One small follow-up:
On Mon, May 5, 2025 at 1:28 AM Paolo Abeni <pabeni@...hat.com> wrote:
> [...]
> > +_Static_assert(sizeof(struct homa_data_hdr) <= HOMA_MAX_HEADER,
> > + "homa_data_hdr too large for HOMA_MAX_HEADER; must adjust HOMA_MAX_HEADER");
> > +_Static_assert(sizeof(struct homa_data_hdr) >= HOMA_MIN_PKT_LENGTH,
> > + "homa_data_hdr too small: Homa doesn't currently have code to pad data packets");
> > +_Static_assert(((sizeof(struct homa_data_hdr) - sizeof(struct homa_seg_hdr)) &
> > + 0x3) == 0,
> > + " homa_data_hdr length not a multiple of 4 bytes (required for TCP/TSO compatibility");
>
> Please use BUILD_BUG_ON() in a .c file instead. Many other cases below.
BUILD_BUG_ON expands to code, so it only works in contexts where there
can be code. I see that you said to put this in a .c file, but these
assertions are closely related to the structure declaration, so they
really belong right next to the structure (there's no natural place to
put them in a .c file).
I see that "static_assert" is used in several places in the kernel,
and it will work in headers; is it OK if I switch from _Static_assert
to static_assert?
-John-
Powered by blists - more mailing lists