Re: [PATCH][next] iio: cros_ec: Avoid -Wflex-array-member-not-at-end warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On March 17, 2025 6:51:50 PM PDT, Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
>On Mon, Mar 17, 2025 at 12:04:47PM +0000, Jonathan Cameron wrote:
>> On Mon, 17 Mar 2025 15:10:38 +1030
>> "Gustavo A. R. Silva" <gustavo@xxxxxxxxxxxxxx> wrote:
>> 
>> > On 17/03/25 12:02, Tzung-Bi Shih wrote:
>> > > On Mon, Mar 17, 2025 at 11:24:59AM +1030, Gustavo A. R. Silva wrote:  
>> > >>   static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
>> > >>   					     u16 cmd_offset, u16 cmd, u32 *mask)
>> > >>   {
>> > >> +	DEFINE_RAW_FLEX(struct cros_ec_command, buf, data,
>> > >> +			sizeof(struct ec_response_get_cmd_versions));  
>> > > 
>> > > max(sizeof(struct ec_params_get_cmd_versions),
>> > >      sizeof(struct ec_response_get_cmd_versions))?  
>> > 
>> > I considered that, but DEFINE_RAW_FLEX() complains about it due to the
>> > 
>> > _Static_assert(__builtin_constant_p(count),				\
>> > 		       "onstack flex array members require compile-time const count");
>> > 
>> Maybe add an assert that you indeed have the larger of the two + a comment
>> on why it matters?
>
>Or, is there a way for using compiler-time MAX()?  I failed to find so.

Did MAX() not work? I would expect it to do compile time comparison of two sizeof()s. It can do other arithmetic no problem, e.g.:
https://elixir.bootlin.com/linux/v6.13.7/source/lib/vsprintf.c#L1097

-- 
Kees Cook





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux