Re: [PATCH v4 01/14] iommufd/viommu: Introduce IOMMUFD_OBJ_VDEVICE and its related struct

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

 



On Fri, Oct 25, 2024 at 10:20:54AM -0300, Jason Gunthorpe wrote:
> On Fri, Oct 25, 2024 at 06:53:01PM +1100, Alexey Kardashevskiy wrote:
> > > +#define iommufd_vdevice_alloc(ictx, drv_struct, member)                        \
> > > +	({                                                                     \
> > > +		static_assert(                                                 \
> > > +			__same_type(struct iommufd_vdevice,                    \
> > > +				    ((struct drv_struct *)NULL)->member));     \
> > > +		static_assert(offsetof(struct drv_struct, member.obj) == 0);   \
> > > +		container_of(_iommufd_object_alloc(ictx,                       \
> > > +						   sizeof(struct drv_struct),  \
> > > +						   IOMMUFD_OBJ_VDEVICE),       \
> > > +			     struct drv_struct, member.obj);                   \
> > > +	})
> > >   #endif
> > 
> > A nit: it hurts eyes to read:
> > 
> > mock_vdev = iommufd_vdevice_alloc(viommu->ictx, mock_vdevice, core);
> > 
> > vs.
> > 
> > mock_vdev = iommufd_vdevice_alloc(viommu->ictx, struct mock_vdevice, core);
> > 
> > as for the former I go searching for a "mock_vdevice" variable and for the
> > latter it is clear it is 1) a macro 2) which does some type checking.
> > 
> > also, it makes it impossible to pass things like typeof(..) or a type from
> > typedef. Thanks,
> 
> Makes sense to me

Ack. Will change accordingly.

> And the container_of() should not be used in these macros, the point
> was to avoid it to make the PTR_ERR behavior cleraer. Just put a force
> type cast

I recall that I changed it for a compiler complaint. But it seems
to be gone now. Will change it back.

Thanks
Nicolin




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux