virobject: Check if @parent is the first member in class

Our virObject code relies heavily on the fact that the first
member of the class struct is type of virObject (or some
derivation of if). Let's check for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2018-04-17 17:52:03 +02:00
parent 10f94828ea
commit 76ae74b1d1

View File

@ -76,7 +76,8 @@ virClassPtr virClassForObjectRWLockable(void);
# endif
# define VIR_CLASS_NEW(name, prnt) \
(name##Class = virClassNew(prnt, #name, sizeof(name), name##Dispose))
verify_expr(offsetof(name, parent) == 0, \
(name##Class = virClassNew(prnt, #name, sizeof(name), name##Dispose)))
virClassPtr
virClassNew(virClassPtr parent,