On Wed, Jan 29, 2025 at 10:29:24AM +0300, Dan Carpenter wrote: > drivers/iommu/iommufd/iommufd_private.h > 243 static inline struct iommufd_ioas *iommufd_get_ioas(struct > iommufd_ctx *ictx, > 244 u32 id) > 245 { > 246 return container_of(iommufd_get_object(ictx, id, > 247 IOMMUFD_OBJ_IOAS), > 248 struct iommufd_ioas, obj); > 249 } > > It's just a cast like you say, but it looks like pointer math. It would > be more readable as container_of_first().
I left out the important bit... iommufd_get_object() returns error pointers. It doesn't make sense to pass error pointers to container_of() unless the offset is zero. Smatch could check that the offset is zero, but Coccinelle can't. There are a bunch of advantages to Coccinelle at times so this will improve the readability and make it easier for static checkers as well. regards, dan carpenter