Re: [PATCH v4 12/23] iommufd/driver: Add iommufd_hw_queue_depend/undepend() helpers

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

 



On Thu, May 08, 2025 at 08:02:33PM -0700, Nicolin Chen wrote:

> +/*
> + * Helpers for IOMMU driver to build/destroy a dependency between two sibling
> + * structures created by one of the allocators above
> + */
> +#define iommufd_hw_queue_depend(dependent, depended, member)                   \
> +	({                                                                     \
> +		static_assert(__same_type(struct iommufd_hw_queue,             \
> +					  dependent->member));                 \
> +		static_assert(offsetof(typeof(*dependent), member.obj) == 0);  \
> +		static_assert(__same_type(struct iommufd_hw_queue,             \
> +					  depended->member));                  \
> +		static_assert(offsetof(typeof(*depended), member.obj) == 0);   \
> +		_iommufd_object_depend(&dependent->member.obj,                 \
> +				       &depended->member.obj);                 \
> +	})

This doesn't need the offsetof == 0 checks, it isn't an allocator. And
you want to check that the two structs have the same type:

static_assert(__same_type(struct iommufd_hw_queue, dependent->member));
static_assert(__same_type(typeof(*dependent), *dependend));

Jason




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux