Re: [PATCH v2 4/5] virobject: Check if @parent is the first member in class

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

 



On Tue, Apr 17, 2018 at 10:20:52AM +0200, Michal Privoznik wrote:
> 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@xxxxxxxxxx>
> ---
>  src/util/virobject.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/util/virobject.h b/src/util/virobject.h
> index 128d3ba2d2..e174c17eb8 100644
> --- a/src/util/virobject.h
> +++ b/src/util/virobject.h
> @@ -76,10 +76,12 @@ virClassPtr virClassForObjectRWLockable(void);
>  # endif
>  
>  # define VIR_CLASS_NEW(prnt, name) \
> +    verify(offsetof(name, parent) == 0); \
>      if (!(name##Class = virClassNew(prnt, #name, sizeof(name), name##Dispose))) \
>          return -1;
>  
>  # define VIR_CLASS_NEW_GOTO(prnt, name, label) \
> +    verify(offsetof(name, parent) == 0); \
>      if (!(name##Class = virClassNew(prnt, #name, sizeof(name), name##Dispose))) \
>          goto label;

With the suggestion in my previous patch, you wuold need to use
verify_expr() instead of verify, to allow VIR_CLASS_NEW to be used
in an expression.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux