[virt-tools-list] [virt-viewer v2] ovirt: Improve handling of g_strv_contains()
Eduardo Lima (Etrunko)
etrunko at redhat.com
Fri Jun 29 15:18:15 UTC 2018
Acked-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
On 29/06/18 05:13, Christophe Fergeau wrote:
> The ovirt code uses g_strv_contains() with fallback code in
> glib-compat.h when we are using a glib version where it's not available.
> However, when we use a glib version where g_strv_contains is available,
> we get a compilation warning since we are compiling GLIB_VERSION_MAX_ALLOWED
> set to 2.38.
>
> This commit wraps both the compat code and the g_strv_contains() call in
> a strv_contains() helper where we can hide the magic needed to avoid
> deprecation warnings.
>
> Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> ---
> src/ovirt-foreign-menu.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index cd1b8bd..f212861 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -100,7 +100,6 @@ enum {
> PROP_VM_GUID,
> };
>
> -
> gchar *
> ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu)
> {
> @@ -623,6 +622,13 @@ static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
> }
>
> #ifdef HAVE_OVIRT_DATA_CENTER
> +static gboolean strv_contains(const gchar * const *strv, const gchar *str)
> +{
> +G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> + return g_strv_contains (strv, str);
> +G_GNUC_END_IGNORE_DEPRECATIONS
> +}
> +
> static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain *domain,
> OvirtDataCenter *data_center)
> {
> @@ -632,7 +638,7 @@ static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain *domai
>
> g_object_get(domain, "data-center-ids", &data_center_ids, NULL);
> g_object_get(data_center, "guid", &data_center_guid, NULL);
> - match = g_strv_contains((const gchar * const *) data_center_ids, data_center_guid);
> + match = strv_contains((const gchar * const *) data_center_ids, data_center_guid);
> g_strfreev(data_center_ids);
> g_free(data_center_guid);
>
>
--
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko at redhat.com
More information about the virt-tools-list
mailing list