open-vm-tools: Avoid GLib g_free macro redefinition error

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2025-11-21 00:32:23 -08:00
parent 3789c3be6d
commit 2d33949443
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,31 @@
From c21c9a7c1ef89c63c1b124a0f49d95ed6ae8f19d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 21 Nov 2025 00:29:10 -0800
Subject: [PATCH] glib_stubs: avoid GLib g_free macro redefinition error
glib 2.78+ defines g_free as an object-size checking macro.
open-vm-tools overrides g_free(), leading to preprocessor expansion
inside the function signature and breaking the build.
Undefine the macro before defining the stub.
Upstream-Status: Submitted [https://github.com/vmware/open-vm-tools/pull/779]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
open-vm-tools/lib/rpcChannel/glib_stubs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/open-vm-tools/lib/rpcChannel/glib_stubs.c b/open-vm-tools/lib/rpcChannel/glib_stubs.c
index c32deb073..cb89c6a87 100644
--- a/open-vm-tools/lib/rpcChannel/glib_stubs.c
+++ b/open-vm-tools/lib/rpcChannel/glib_stubs.c
@@ -35,6 +35,9 @@
void *g_malloc0(size_t s) { return Util_SafeCalloc(1, s); }
void *g_malloc0_n(size_t n, size_t s) { return Util_SafeCalloc(n, s); }
+/* GLib defines g_free as a macro, so undefine it before providing
+ * our own stub implementation. */
+#undef g_free
void g_free(void *p) { free(p); }
void g_mutex_init(GMutex *mutex) { }

View File

@ -43,6 +43,7 @@ SRC_URI = "git://github.com/vmware/open-vm-tools.git;protocol=https;branch=stabl
file://0012-hgfsServerLinux-Consider-64bit-time_t-possibility.patch;patchdir=.. \
file://0013-open-vm-tools-Correct-include-path-for-poll.h.patch;patchdir=.. \
file://0014-timeSync-Portable-way-to-print-64bit-time_t.patch;patchdir=.. \
file://0001-glib_stubs-avoid-GLib-g_free-macro-redefinition-erro.patch;patchdir=.. \
"
UPSTREAM_CHECK_GITTAGREGEX = "stable-(?P<pver>\d+(\.\d+)+)"