On Tue, 23 Jun 2026 17:09:40 +0300
Andy Shevchenko <[email protected]> wrote:
> On Mon, Jun 22, 2026 at 01:16:29PM +0200, Johannes Berg wrote:
> > On Sat, 2026-06-20 at 09:56 +0300, Andy Shevchenko wrote:
> > > Johannes, are you okay to take a new version (I assume the wish is to have
> > > the balanced additions)? If so, I will prepare one.
> >
> > Sure, I can take the patches, sounds good to me.
>
> Will send soon, for the record the *.i file is 61 character less with the
> patch.
>
> Was
>
> size = __builtin_choose_expr((sizeof(int) == sizeof(*(8 ? ((void
> *)((long)(n_channels) * 0l)) : (int *)8))), sizeof(*(request)) +
> __builtin_choose_expr((sizeof(int) == sizeof(*(8 ? ((void
> *)((long)(n_channels) * 0l)) : (int *)8))), (n_channels) *
> sizeof(*(request)->channels) + ((int)sizeof(struct
> {_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
> typeof(&((request)->channels)[0])))), "must be array");})),
> size_mul(n_channels, sizeof(*(request)->channels) + ((int)sizeof(struct
> {_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
> typeof(&((request)->channels)[0])))), "must be array");})))),
> __size_add(sizeof(*(request)), __builtin_choose_expr((sizeof(int) ==
> sizeof(*(8 ? ((void *)((long)(n_channels) * 0l)) : (int *)8))), (n_channels)
> * sizeof(*(request)->channels) + ((int)sizeof(struct
> {_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
> typeof(&((request)->channels)[0])))), "must be array");})), si
ze_mul(n_channels, sizeof(*(request)->channels) + ((int)sizeof(struct
{_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
typeof(&((request)->channels)[0])))), "must be array");}))))));
> - size = __size_add(size, size_mul(sizeof(*request->ssids), n_ssids));
> - size = __size_add(size, size_mul(sizeof(*request->match_sets),
> n_match_sets));
> - size = __size_add(size, size_mul(sizeof(*request->scan_plans), n_plans));
> - size = __size_add(size, ie_len);
>
> Now
>
> size = __size_add(__size_add(__size_add(__builtin_choose_expr((sizeof(int) ==
> sizeof(*(8 ? ((void *)((long)(n_channels) * 0l)) : (int *)8))),
> sizeof(*(request)) + __builtin_choose_expr((sizeof(int) == sizeof(*(8 ?
> ((void *)((long)(n_channels) * 0l)) : (int *)8))), (n_channels) *
> sizeof(*(request)->channels) + ((int)sizeof(struct
> {_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
> typeof(&((request)->channels)[0])))), "must be array");})),
> size_mul(n_channels, sizeof(*(request)->channels) + ((int)sizeof(struct
> {_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
> typeof(&((request)->channels)[0])))), "must be array");})))),
> __size_add(sizeof(*(request)), __builtin_choose_expr((sizeof(int) ==
> sizeof(*(8 ? ((void *)((long)(n_channels) * 0l)) : (int *)8))), (n_channels)
> * sizeof(*(request)->channels) + ((int)sizeof(struct
> {_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
> typeof(&((request)->channels)
[0])))), "must be array");})), size_mul(n_channels,
sizeof(*(request)->channels) + ((int)sizeof(struct
{_Static_assert(!(!(!__builtin_types_compatible_p(typeof(((request)->channels)),
typeof(&((request)->channels)[0])))), "must be array");})))))), ie_len),
size_mul(sizeof(*request->ssids), n_ssids)),
__size_add(size_mul(sizeof(*request->match_sets), n_match_sets),
size_mul(sizeof(*request->scan_plans), n_plans)));
>
Both those seem to contain multiple expansions of is_constexpr().
I'd be surprised if __builtin_constant_p() wasn't good enough.
I also wonder what kind of mess the object code looks like.
I'd also worry whether the saturating maths in any way performs the correct
check.
I suspect the (non-saturated) value gets used for a kmalloc(),
but that has much smaller valid (and sane) limits than can come out of the
above.
David