[PATCH] domain_conf: make virDomainDiskSetSource() void

Michal Prívozník mprivozn at redhat.com
Thu Nov 5 16:26:52 UTC 2020


On 11/5/20 7:23 AM, Matt Coleman wrote:
> The function only returns zero or aborts, so it might as well be void.
> This has the added benefit of simplifying the code that calls it.
> 
> Signed-off-by: Matt Coleman <matt at datto.com>
> ---
>   src/conf/domain_conf.c   |  3 +--
>   src/conf/domain_conf.h   |  3 +--
>   src/libxl/libxl_driver.c |  6 ++----
>   src/libxl/xen_xl.c       |  3 +--
>   src/libxl/xen_xm.c       | 13 ++++---------
>   src/lxc/lxc_controller.c | 13 ++-----------
>   src/vbox/vbox_common.c   |  6 +-----
>   src/vmx/vmx.c            | 36 ++++++++++++------------------------
>   src/vz/vz_sdk.c          |  4 ++--
>   9 files changed, 26 insertions(+), 61 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 7696b12ef9..5c8ec19da8 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2241,13 +2241,12 @@ virDomainDiskGetSource(virDomainDiskDef const *def)
>   }
>   
>   
> -int
> +void
>   virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
>   {
>       char *tmp = g_strdup(src);
>       g_free(def->src->path);
>       def->src->path = tmp;
> -    return 0;
>   }
>   
>   
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 8a487e9de3..c164b28ea1 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -3040,8 +3040,7 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
>   int virDomainDiskGetType(virDomainDiskDefPtr def);
>   void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
>   const char *virDomainDiskGetSource(virDomainDiskDef const *def);
> -int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
> -    G_GNUC_WARN_UNUSED_RESULT;
> +void virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src);

With us adopting glib more and more cleanups like these will be 
desirable more. Any plans on continuing?

Michal




More information about the libvir-list mailing list