Re: [PATCH v3 for-next 1/8] RDMA/hns: Use temporary variables to fix warning about hr_reg_write()

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

 



On 2021/6/18 6:41, Jason Gunthorpe wrote:
> On Thu, Jun 17, 2021 at 03:31:44PM +0800, Weihang Li wrote:
>> From: Lang Cheng <chenglang@xxxxxxxxxx>
>>
>> Fix complains from sparse about "dubious: x & !y" when calling
>> hr_reg_write(ctx, field, !!val).
> 
> Where is this from?
> 
> I'm not convinced you should have the temporary here given how much
> magics are involved in this stuff that rely on builtin_constant_p
> 
> Jason
> 

The warning comes from:

#define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx)			\
		...

		BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?		\
				 ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
				 _pfx "value too large for the field"); \

I will change 'hr_reg_write(ctx, field, !!val)' to 'hr_reg_write(ctx, field, val
? 1 : 0)'. The latter is not as succinct as the former, but can avoid the sparse
warning.

Thanks
Weihang



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux