Prefer __containerof() above member2struct().

The first does proper checking of the argument types, while the latter
does not.
This commit is contained in:
Ed Schouten 2012-09-15 19:28:54 +00:00
parent 1913678b8d
commit 7cbef24e1a
4 changed files with 4 additions and 4 deletions
sys
dev/drm2
fs/devfs
mips/mips

@ -396,7 +396,7 @@ drm_gem_object_from_offset(struct drm_device *dev, vm_ooffset_t offset)
(uintmax_t)offset);
return (NULL);
}
obj = member2struct(drm_gem_object, map_list, map_list);
obj = __containerof(map_list, struct drm_gem_object, map_list);
return (obj);
}

@ -889,7 +889,7 @@ struct drm_i915_gem_object {
int pending_flip;
};
#define to_intel_bo(x) member2struct(drm_i915_gem_object, base, (x))
#define to_intel_bo(x) __containerof(x, struct drm_i915_gem_object, base)
/**
* Request queue structure.

@ -69,7 +69,7 @@ struct cdev_priv {
LIST_HEAD(, cdev_privdata) cdp_fdpriv;
};
#define cdev2priv(c) member2struct(cdev_priv, cdp_c, c)
#define cdev2priv(c) __containerof(c, struct cdev_priv, cdp_c)
struct cdev *devfs_alloc(int);
int devfs_dev_exists(const char *);

@ -1629,7 +1629,7 @@ pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va)
pv = pmap_pvh_remove(pvh, pmap, va);
KASSERT(pv != NULL, ("pmap_pvh_free: pv not found, pa %lx va %lx",
(u_long)VM_PAGE_TO_PHYS(member2struct(vm_page, md, pvh)),
(u_long)VM_PAGE_TO_PHYS(__containerof(pvh, struct vm_page, md)),
(u_long)va));
free_pv_entry(pmap, pv);
}