From nobody Sun Feb 8 23:57:56 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1715093163731803.8645497387053; Tue, 7 May 2024 07:46:03 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8607B1F3B; Tue, 7 May 2024 10:46:02 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 74B6A1EDD; Tue, 7 May 2024 10:29:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2955C1EE9; Tue, 7 May 2024 10:28:59 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3169C1DA2 for ; Tue, 7 May 2024 10:28:43 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326-Pw9eO8VlPJqjIJ5gDwfs9w-1; Tue, 07 May 2024 10:28:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58A9E85FAD0 for ; Tue, 7 May 2024 14:28:39 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 039543C36 for ; Tue, 7 May 2024 14:28:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: Pw9eO8VlPJqjIJ5gDwfs9w-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH v2 09/10] meson: Bump glib version to 2.58.0 Date: Tue, 7 May 2024 16:28:31 +0200 Message-ID: <75c1ec4f71a95bff9b8bd0f9bbe3321dc28a955c.1715091914.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: HH4TCDD5YKYQCWXK7KMM6PUXEVI7DOI6 X-Message-ID-Hash: HH4TCDD5YKYQCWXK7KMM6PUXEVI7DOI6 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1715093163960100001 Now that we don't have any distro stuck with glib-2.56.0, we can bump the glib version. In fact, this is needed, because of g_clear_pointer. Since v7.4.0-rc1~301 we declare at compile time what version of glib APIs we want to use (by setting GLIB_VERSION_MIN_REQUIRED =3D GLIB_VERSION_MAX_ALLOWED =3D 2.56.0), regardless of actual glib version in the host. And since we currently require glib-2.56.0 and force glib to use APIs of that version, some newer bits are slipping from us. For instance: regular function version of g_clear_pointer() is used instead of a fancy macro. So what? Well, g_clear_pointer() function typecasts passed free function to void (*)(void *) and then calls it. Well, this triggers UBSAN, understandably. But with glib-2.58.0 the g_clear_pointer() becomes a macro which calls the free function directly, with no typecasting and thus no undefined behavior. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- meson.build | 2 +- src/libvirt_private.syms | 1 - src/util/glibcompat.c | 125 --------------------------------------- src/util/glibcompat.h | 10 ---- 4 files changed, 1 insertion(+), 137 deletions(-) diff --git a/meson.build b/meson.build index cb374ab118..583383b0d3 100644 --- a/meson.build +++ b/meson.build @@ -978,7 +978,7 @@ else endif endif =20 -glib_version =3D '2.56.0' +glib_version =3D '2.58.0' glib_dep =3D dependency('glib-2.0', version: '>=3D' + glib_version) gobject_dep =3D dependency('gobject-2.0', version: '>=3D' + glib_version) if host_machine.system() =3D=3D 'windows' diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 947294cb2b..1c8f3f902d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1848,7 +1848,6 @@ virStorageSourceUpdatePhysicalSize; =20 =20 # util/glibcompat.h -vir_g_canonicalize_filename; vir_g_fsync; vir_g_source_unref; vir_g_strdup_printf; diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index fdc32af5e2..d8912b323b 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -63,136 +63,11 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" =20 -#undef g_canonicalize_filename -#undef g_hash_table_steal_extended #undef g_fsync #undef g_strdup_printf #undef g_strdup_vprintf =20 =20 -gchar * -vir_g_canonicalize_filename(const gchar *filename, - const gchar *relative_to) -{ -#if GLIB_CHECK_VERSION(2, 58, 0) - return g_canonicalize_filename(filename, relative_to); -#else /* ! GLIB_CHECK_VERSION(2, 58, 0) */ - gchar *canon, *start, *p, *q; - guint i; - - g_return_val_if_fail(relative_to =3D=3D NULL || g_path_is_absolute(rel= ative_to), NULL); - - if (!g_path_is_absolute(filename)) { - gchar *cwd_allocated =3D NULL; - const gchar *cwd; - - if (relative_to !=3D NULL) - cwd =3D relative_to; - else - cwd =3D cwd_allocated =3D g_get_current_dir(); - - canon =3D g_build_filename(cwd, filename, NULL); - g_free(cwd_allocated); - } else { - canon =3D g_strdup(filename); - } - - start =3D (char *)g_path_skip_root(canon); - - if (start =3D=3D NULL) { - /* This shouldn't really happen, as g_get_current_dir() should - return an absolute pathname, but bug 573843 shows this is - not always happening */ - g_free(canon); - return g_build_filename(G_DIR_SEPARATOR_S, filename, NULL); - } - - /* POSIX allows double slashes at the start to - * mean something special (as does windows too). - * So, "//" !=3D "/", but more than two slashes - * is treated as "/". - */ - i =3D 0; - for (p =3D start - 1; - (p >=3D canon) && - G_IS_DIR_SEPARATOR(*p); - p--) - i++; - if (i > 2) { - i -=3D 1; - start -=3D i; - memmove(start, start+i, strlen(start+i) + 1); - } - - /* Make sure we're using the canonical dir separator */ - p++; - while (p < start && G_IS_DIR_SEPARATOR(*p)) - *p++ =3D G_DIR_SEPARATOR; - - p =3D start; - while (*p !=3D 0) { - if (p[0] =3D=3D '.' && (p[1] =3D=3D 0 || G_IS_DIR_SEPARATOR(p[1]))= ) { - memmove(p, p+1, strlen(p+1)+1); - } else if (p[0] =3D=3D '.' && p[1] =3D=3D '.' && - (p[2] =3D=3D 0 || G_IS_DIR_SEPARATOR(p[2]))) { - q =3D p + 2; - /* Skip previous separator */ - p =3D p - 2; - if (p < start) - p =3D start; - while (p > start && !G_IS_DIR_SEPARATOR(*p)) - p--; - if (G_IS_DIR_SEPARATOR(*p)) - *p++ =3D G_DIR_SEPARATOR; - memmove(p, q, strlen(q)+1); - } else { - /* Skip until next separator */ - while (*p !=3D 0 && !G_IS_DIR_SEPARATOR(*p)) - p++; - - if (*p !=3D 0) { - /* Canonicalize one separator */ - *p++ =3D G_DIR_SEPARATOR; - } - } - - /* Remove additional separators */ - q =3D p; - while (*q && G_IS_DIR_SEPARATOR(*q)) - q++; - - if (p !=3D q) - memmove(p, q, strlen(q) + 1); - } - - /* Remove trailing slashes */ - if (p > start && G_IS_DIR_SEPARATOR(*(p-1))) - *(p-1) =3D 0; - - return canon; -#endif /* ! GLIB_CHECK_VERSION(2, 58, 0) */ -} - - -gboolean -vir_g_hash_table_steal_extended(GHashTable *hash_table, - gconstpointer lookup_key, - gpointer *stolen_key, - gpointer *stolen_value) -{ -#if GLIB_CHECK_VERSION(2, 58, 0) - return g_hash_table_steal_extended(hash_table, lookup_key, stolen_key,= stolen_value); -#else /* ! GLIB_CHECK_VERSION(2, 58, 0) */ - if (!(g_hash_table_lookup_extended(hash_table, lookup_key, stolen_key,= stolen_value))) - return FALSE; - - g_hash_table_steal(hash_table, lookup_key); - - return TRUE; -#endif /* ! GLIB_CHECK_VERSION(2, 58, 0) */ -} - - /* Drop when min glib >=3D 2.63.0 */ gint vir_g_fsync(gint fd) diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 178fea3cf3..2542b4d5dc 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -68,15 +68,6 @@ =20 #endif /* GLib < 2.67.0 */ =20 -gchar * vir_g_canonicalize_filename(const gchar *filename, - const gchar *relative_to); - -gboolean -vir_g_hash_table_steal_extended(GHashTable *hash_table, - gconstpointer lookup_key, - gpointer *stolen_key, - gpointer *stolen_value); -#define g_hash_table_steal_extended vir_g_hash_table_steal_extended =20 gint vir_g_fsync(gint fd); char *vir_g_strdup_printf(const char *msg, ...) @@ -89,7 +80,6 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args) # define g_strdup_vprintf vir_g_strdup_vprintf #endif =20 -#define g_canonicalize_filename vir_g_canonicalize_filename #undef g_fsync #define g_fsync vir_g_fsync =20 --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org