Re: [PATCH v3 3/5] virobject: Introduce VIR_CLASS_NEW() macro

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

 



On Tue, Apr 17, 2018 at 06:01:04PM +0200, Michal Privoznik wrote:
> So far we are repeating the following lines over and over:
> 
>   if (!(virSomeObjectClass = virClassNew(virClassForObject(),
>                              "virSomeObject",
>                              sizeof(virSomeObject),
>                              virSomeObjectDispose)))
>       return -1;
> 
> 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:
> 
>   if (!(VIR_CLASS_NEW(virSomeObject,
>                       virClassForObject)))
>       return -1;
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/access/viraccessmanager.c           |   5 +-
>  src/bhyve/bhyve_conf.c                  |   5 +-
>  src/conf/capabilities.c                 |   5 +-
>  src/conf/domain_capabilities.c          |  11 +--
>  src/conf/domain_conf.c                  |  20 +---
>  src/conf/domain_event.c                 | 166 ++++++++------------------------
>  src/conf/network_event.c                |  14 +--
>  src/conf/node_device_event.c            |  21 ++--
>  src/conf/object_event.c                 |  12 +--
>  src/conf/secret_event.c                 |  21 ++--
>  src/conf/storage_event.c                |  21 ++--
>  src/conf/virdomainobjlist.c             |   5 +-
>  src/conf/virinterfaceobj.c              |  10 +-
>  src/conf/virnetworkobj.c                |  11 +--
>  src/conf/virnodedeviceobj.c             |  10 +-
>  src/conf/virsecretobj.c                 |  10 +-
>  src/conf/virstorageobj.c                |  20 +---
>  src/datatypes.c                         |   5 +-
>  src/interface/interface_backend_netcf.c |   6 +-
>  src/libvirt-admin.c                     |   5 +-
>  src/libxl/libxl_conf.c                  |   5 +-
>  src/libxl/libxl_domain.c                |   5 +-
>  src/libxl/libxl_migration.c             |   5 +-
>  src/logging/log_handler.c               |   5 +-
>  src/lxc/lxc_conf.c                      |   5 +-
>  src/lxc/lxc_monitor.c                   |   5 +-
>  src/node_device/node_device_udev.c      |   5 +-
>  src/qemu/qemu_agent.c                   |   5 +-
>  src/qemu/qemu_capabilities.c            |   5 +-
>  src/qemu/qemu_conf.c                    |  11 +--
>  src/qemu/qemu_domain.c                  |  51 +++-------
>  src/qemu/qemu_monitor.c                 |   5 +-
>  src/rpc/virkeepalive.c                  |   5 +-
>  src/rpc/virnetclient.c                  |   5 +-
>  src/rpc/virnetclientprogram.c           |   5 +-
>  src/rpc/virnetclientstream.c            |   5 +-
>  src/rpc/virnetdaemon.c                  |   5 +-
>  src/rpc/virnetlibsshsession.c           |   5 +-
>  src/rpc/virnetsaslcontext.c             |  10 +-
>  src/rpc/virnetserver.c                  |   5 +-
>  src/rpc/virnetserverclient.c            |   5 +-
>  src/rpc/virnetserverprogram.c           |   5 +-
>  src/rpc/virnetserverservice.c           |   5 +-
>  src/rpc/virnetsocket.c                  |   5 +-
>  src/rpc/virnetsshsession.c              |   5 +-
>  src/rpc/virnettlscontext.c              |  10 +-
>  src/security/security_manager.c         |   5 +-
>  src/util/virclosecallbacks.c            |  11 +--
>  src/util/virdnsmasq.c                   |   6 +-
>  src/util/virfdstream.c                  |   5 +-
>  src/util/virfilecache.c                 |   5 +-
>  src/util/virhash.c                      |  11 +--
>  src/util/virhostdev.c                   |   5 +-
>  src/util/viridentity.c                  |   5 +-
>  src/util/virmacmap.c                    |   5 +-
>  src/util/virmdev.c                      |   5 +-
>  src/util/virobject.c                    |  10 +-
>  src/util/virobject.h                    |   4 +
>  src/util/virpci.c                       |   5 +-
>  src/util/virportallocator.c             |   5 +-
>  src/util/virresctrl.c                   |  10 +-
>  src/util/virscsi.c                      |   5 +-
>  src/util/virscsivhost.c                 |   5 +-
>  src/util/virusb.c                       |   5 +-
>  src/vbox/vbox_common.c                  |   5 +-
>  src/vz/vz_driver.c                      |   5 +-
>  tests/virfilecachetest.c                |   5 +-
>  67 files changed, 167 insertions(+), 535 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>


but i can't claim I looked closely at anything except the virobject.h
change - i'm assuming the compile time validation is doing the right
thing :-)


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