[PATCH 13/36] admin: convert virAdmServer to GObject

Rafael Fonseca r4f4rfs at gmail.com
Wed Apr 8 21:02:16 UTC 2020


On Wed, Apr 8, 2020 at 10:47 PM Jonathon Jongsma <jjongsma at redhat.com> wrote:
>
> On Fri, 2020-04-03 at 17:15 +0200, Rafael Fonseca wrote:
> >
> >  #define virCheckAdmServerReturn(obj, retval) \
> >      do { \
> > -        virAdmServerPtr _srv = (obj); \
> > -        if (!virObjectIsClass(_srv, virAdmServerClass) || \
> > +        virAdmServerPtr _srv = VIR_ADM_SERVER(obj); \
> > +        if (!G_IS_OBJECT(_srv) || !(G_OBJECT_TYPE(_srv) ==
> > VIR_TYPE_ADM_SERVER) || \
>
> This additional check is unnecessary with GObject. The VIR_ADM_SERVER()
> casting macro that is provided by G_DECLARE_FINAL_TYPE() does this
> internally. This function already checks that the type of obj is
> correct and castable. If the pointer is not castable to the type, it
> emits a warning and returns NULL. So you can just check for (_srv ==
> NULL).

Thank you for the reviews and comments!

I'm afraid all the patches related to `datatypes.c` will have this
same problem. They'll be fixed in v2.


Att.
-- 
Rafael Fonseca





More information about the libvir-list mailing list