]> xenbits.xensource.com Git - libvirt.git/commitdiff
meson: Bump glib version to 2.58.0
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 3 May 2024 13:48:54 +0000 (15:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 May 2024 13:17:20 +0000 (15:17 +0200)
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 = GLIB_VERSION_MAX_ALLOWED = 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 <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
libvirt.spec.in
meson.build
src/libvirt_private.syms
src/util/glibcompat.c
src/util/glibcompat.h

index 521ecebf056a728b7562d3ebd0ccb8bcf6c9f2ef..f7c128d80967738f95b7e0b3744a7902b39dfe04 100644 (file)
@@ -337,7 +337,7 @@ BuildRequires: gcc
     %if %{with_libxl}
 BuildRequires: xen-devel
     %endif
-BuildRequires: glib2-devel >= 2.56
+BuildRequires: glib2-devel >= 2.58
 BuildRequires: libxml2-devel
 BuildRequires: readline-devel
 BuildRequires: pkgconfig(bash-completion) >= 2.0
index 9cc0620e7889731e399dd1688e123c0e68b556e2..063233e05eead222faa8198d2768abccb7817039 100644 (file)
@@ -985,7 +985,7 @@ else
   endif
 endif
 
-glib_version = '2.56.0'
+glib_version = '2.58.0'
 glib_dep = dependency('glib-2.0', version: '>=' + glib_version)
 gobject_dep = dependency('gobject-2.0', version: '>=' + glib_version)
 if host_machine.system() == 'windows'
index 947294cb2b83ddff220eceb4b2167014319360c9..1c8f3f902d17efaeba1b4805cce248beca6cd244 100644 (file)
@@ -1848,7 +1848,6 @@ virStorageSourceUpdatePhysicalSize;
 
 
 # util/glibcompat.h
-vir_g_canonicalize_filename;
 vir_g_fsync;
 vir_g_source_unref;
 vir_g_strdup_printf;
index fdc32af5e2b3464deb72b684383b58370abcf94b..d8912b323b72d41737a68c51e76fdd1a39362879 100644 (file)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 
-#undef g_canonicalize_filename
-#undef g_hash_table_steal_extended
 #undef g_fsync
 #undef g_strdup_printf
 #undef g_strdup_vprintf
 
 
-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 == NULL || g_path_is_absolute(relative_to), NULL);
-
-    if (!g_path_is_absolute(filename)) {
-        gchar *cwd_allocated = NULL;
-        const gchar  *cwd;
-
-        if (relative_to != NULL)
-            cwd = relative_to;
-        else
-            cwd = cwd_allocated = g_get_current_dir();
-
-        canon = g_build_filename(cwd, filename, NULL);
-        g_free(cwd_allocated);
-    } else {
-        canon = g_strdup(filename);
-    }
-
-    start = (char *)g_path_skip_root(canon);
-
-    if (start == 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, "//" != "/", but more than two slashes
-     * is treated as "/".
-     */
-    i = 0;
-    for (p = start - 1;
-         (p >= canon) &&
-             G_IS_DIR_SEPARATOR(*p);
-         p--)
-        i++;
-    if (i > 2) {
-        i -= 1;
-        start -= 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++ = G_DIR_SEPARATOR;
-
-    p = start;
-    while (*p != 0) {
-        if (p[0] == '.' && (p[1] == 0 || G_IS_DIR_SEPARATOR(p[1]))) {
-            memmove(p, p+1, strlen(p+1)+1);
-        } else if (p[0] == '.' && p[1] == '.' &&
-                   (p[2] == 0 || G_IS_DIR_SEPARATOR(p[2]))) {
-            q = p + 2;
-            /* Skip previous separator */
-            p = p - 2;
-            if (p < start)
-                p = start;
-            while (p > start && !G_IS_DIR_SEPARATOR(*p))
-                p--;
-            if (G_IS_DIR_SEPARATOR(*p))
-                *p++ = G_DIR_SEPARATOR;
-            memmove(p, q, strlen(q)+1);
-        } else {
-            /* Skip until next separator */
-            while (*p != 0 && !G_IS_DIR_SEPARATOR(*p))
-                p++;
-
-            if (*p != 0) {
-                /* Canonicalize one separator */
-                *p++ = G_DIR_SEPARATOR;
-            }
-        }
-
-        /* Remove additional separators */
-        q = p;
-        while (*q && G_IS_DIR_SEPARATOR(*q))
-            q++;
-
-        if (p != q)
-            memmove(p, q, strlen(q) + 1);
-    }
-
-    /* Remove trailing slashes */
-    if (p > start && G_IS_DIR_SEPARATOR(*(p-1)))
-        *(p-1) = 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 >= 2.63.0 */
 gint
 vir_g_fsync(gint fd)
index 178fea3cf3f102a690fe910122b2cdae0426c012..2542b4d5dc30b73169d9b39d2cff69a68e6d3eff 100644 (file)
 
 #endif /* GLib < 2.67.0 */
 
-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
 
 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
 
-#define g_canonicalize_filename vir_g_canonicalize_filename
 #undef g_fsync
 #define g_fsync vir_g_fsync