Re: [PATCH 1/2] iio: adc: ad4130: Fix comparison of channel setups

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

 



On Thu, Jan 30, 2025 at 06:45:01PM +0100, Uwe Kleine-König wrote:

...

> +	BUILD_BUG_ON(sizeof(*a) !=
> +		     sizeof(struct {
> +				    unsigned int iout0_val;
> +				    unsigned int iout1_val;
> +				    unsigned int burnout;
> +				    unsigned int pga;
> +				    unsigned int fs;
> +				    u32 ref_sel;
> +				    enum ad4130_filter_mode filter_mode;
> +				    bool ref_bufp;
> +				    bool ref_bufm;
> +			    }));

Is I shuffle the fields (for whatever reason) this may give false positive
warnings. I think this BUILD_BUG_ON() is unreliable and ugly looking
(static_assert() won't help much here either), so on the second though I think
it's better to simply add a comments in both places (here and near to the
structure definition) to explain that these needs to be in sync.

> +	if (a->iout0_val != b->iout0_val ||
> +	    a->iout1_val != b->iout1_val ||
> +	    a->burnout != b->burnout ||
> +	    a->pga != b->pga ||
> +	    a->fs != b->fs ||
> +	    a->ref_sel != b->ref_sel ||
> +	    a->filter_mode != b->filter_mode ||
> +	    a->ref_bufp != b->ref_bufp ||
> +	    a->ref_bufm != b->ref_bufm)
> +		return false;
> +
> +	return true;

-- 
With Best Regards,
Andy Shevchenko






[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