Re: [PATCH 3/5] mlx5: Avoid that sparse complains about dubious !x & y expressions

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

 



On 12/8/2016 12:53 PM, Jason Gunthorpe wrote:
> On Thu, Dec 08, 2016 at 11:26:32AM +0200, Or Gerlitz wrote:
>>  /* insert a value to a struct */
>>  #define MLX5_SET(typ, p, fld, v) do { \
>> +       typeof( v ) _v = v; \
>>         BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32);             \
>>         *((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
>>         cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
>> -                    (~__mlx5_dw_mask(typ, fld))) | (((v) &
>> __mlx5_mask(typ, fld)) \
>> +                    (~__mlx5_dw_mask(typ, fld))) | (((_v) &
>> __mlx5_mask(typ, fld)) \
>>                      << __mlx5_dw_bit_off(typ, fld))); \
>>  } while (0)
> 
> Ugh, that is ugly.
> 
> This is better, it has proper type safety :|
> 
> static inline _mlx5_set(__be32 *p, u32 dw_mask,
>                         u32 mask, u32 dw_off,
> 			unsigned int bit_off, u32 val)
> {
> 	*(p + dw_off) = cpu_to_b32((be32_to_cpu_p(p + dw_off) &
> 	             ~dw_mask) | ((val & mask) << bit_off));
> }
> 
> #define MLX5_SET(typ, p, fld, v) \
> 	_mlx5_set(p, __mlx5_dw_mask(typ, fld),
> 	           __mlx5_mask(typ, fld),
> 	           __mlx5_dw_off(typ, fld),
> 		   __mlx5_dw_bit_off(typ, fld), v)
> 
> Jason
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Dropped this patch and will wait for fixed up version from Mellanox.

-- 
Doug Ledford <dledford@xxxxxxxxxx>
    GPG Key ID: 0E572FDD

Attachment: signature.asc
Description: OpenPGP digital signature


[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