Re: [PATCH 7/9] virobject: Introduce VIR_CLASS_NEW() macro

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

 



On Fri, Apr 13, 2018 at 04:47:14PM +0200, Michal Privoznik wrote:
> So far we are repeating the following lines over and over:
>
>   virClassNew(virClassForObject(),
>               "virSomeObject",
>               sizeof(virSomeObject),
>               virSomeObjectDispose);
>
> While this works, it is impossible to do some checking. Firstly,
> the class name (the 2nd argument) doesn't match the name in the
> code in all cases (the 3rd argument). Secondly, the current style
> is needlessly verbose. This commit turns example into following:
>
>   VIR_CLASS_NEW(virClassForObject(),
>                 virSomeObject);
>
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>

...

> diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
> index cc2402febb..8acccf8940 100644
> --- a/src/interface/interface_backend_netcf.c
> +++ b/src/interface/interface_backend_netcf.c
> @@ -55,10 +55,8 @@ static void virNetcfDriverStateDispose(void *obj);
>  static int
>  virNetcfDriverStateOnceInit(void)
>  {
> -    if (!(virNetcfDriverStateClass = virClassNew(virClassForObjectLockable(),
> -                                       "virNetcfDriverState",
> -                                       sizeof(virNetcfDriverState),
> -                                       virNetcfDriverStateDispose)))
> +    if (!(virNetcfDriverStateClass = VIR_CLASS_NEW(virClassForObjectLockable(),
> +                                                   virNetcfDriverStat)))

There's a typo in the 2nd parameter which makes the patch fail the compilation.

Erik

--
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