From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, armbru@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
Date: Fri, 29 May 2015 16:01:48 +0100 [thread overview]
Message-ID: <1432911708-22845-3-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1432911708-22845-1-git-send-email-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Newer glib has support for checking that applications aren't
using newer glib calls than they should be.
The support for the check only went into glib 2.32 and it only
has macros for version 2.26 upwards; although we only insist
on 2.22 at the moment, I set the glib checks to the earliest of 2.26,
it wont cause problems on anything <2.32 since the checks aren't
there.
While mainly we're interested in the check from GLIB_VERSION_MAX_ALLOWED
which checks we're not using anything too recent, the glib macros
require that if we set that then we must also define
GLIB_VERSION_MIN_REQUIRED which checks we're not using anything
deprecated too long ago.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
configure | 5 +++++
include/glib-compat.h | 6 ++++++
tests/test-qdev-global-props.c | 2 +-
tests/vhost-user-test.c | 2 ++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 24ee0a4..5c6230a 100755
--- a/configure
+++ b/configure
@@ -2781,6 +2781,11 @@ fi
glib_req_ver=2.22
glib_modules=gthread-2.0
+# Force warnings over use of newer glib features; 2.26 is the earliest
+# version macro that is defined; eventually we should match
+# glib_req_ver above
+QEMU_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 $QEMU_CFLAGS"
+QEMU_CFLAGS="-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_26 $QEMU_CFLAGS"
if test "$modules" = yes; then
glib_modules="$glib_modules gmodule-2.0"
fi
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 318e000..cbd660c 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -16,6 +16,12 @@
#ifndef QEMU_GLIB_COMPAT_H
#define QEMU_GLIB_COMPAT_H
+/*
+ * The source file including this compat header knows it's using newer glib
+ * functions than we generally allow, so don't warn about it.
+ */
+#undef GLIB_VERSION_MIN_REQUIRED
+#undef GLIB_VERSION_MAX_ALLOWED
#include <glib.h>
/* GLIB version compatibility flags */
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index 0be9835..896e6bf 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
-#include <glib.h>
+#include "glib-compat.h"
#include <stdint.h>
#include "hw/qdev.h"
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 75fedf0..7aeb927 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -8,6 +8,8 @@
*
*/
+#undef GLIB_VERSION_MIN_REQUIRED
+#undef GLIB_VERSION_MAX_ALLOWED
#define QEMU_GLIB_COMPAT_H
#include <glib.h>
--
2.4.1
next prev parent reply other threads:[~2015-05-29 15:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 15:01 [Qemu-devel] [PATCH 0/2] Use glib's checks for use of too-new functions Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 1/2] Fix glib_subprocess test Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` Dr. David Alan Gilbert (git) [this message]
2015-05-29 15:37 ` [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib Paolo Bonzini
2015-05-29 15:49 ` Dr. David Alan Gilbert
2015-05-29 15:53 ` Peter Maydell
2015-05-29 16:01 ` Dr. David Alan Gilbert
2015-06-01 18:01 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432911708-22845-3-git-send-email-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).