From: Joe Slater <joe.slater@windriver.com>
To: <qemu-devel@nongnu.org>
Cc: qemu-trivial@nongnu.org, qemu-stable@nongnu.org
Subject: [PATCH 2/2] lockable: do not rely on optimization for null lockables
Date: Wed, 3 Jun 2020 15:49:03 -0700 [thread overview]
Message-ID: <20200603224903.26268-3-joe.slater@windriver.com> (raw)
In-Reply-To: <20200603224903.26268-1-joe.slater@windriver.com>
If we use QLNULL for null lockables, we can always
use referencing unknown_lock_type as a link time
error indicator.
Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
include/qemu/lockable.h | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h
index 7f7aebb..7fc5750 100644
--- a/include/qemu/lockable.h
+++ b/include/qemu/lockable.h
@@ -24,21 +24,14 @@ struct QemuLockable {
QemuLockUnlockFunc *unlock;
};
-#define QLNULL ((QemuLockable *)0)
-
-
-/* This function gives an error if an invalid, non-NULL pointer type is passed
- * to QEMU_MAKE_LOCKABLE. For optimized builds, we can rely on dead-code elimination
- * from the compiler, and give the errors already at link time.
+/*
+ * If unknown_lock_type() is referenced, it means we have tried to passed something
+ * not recognized as lockable to the macros below. Use QLNULL to intentionally pass
+ * a null lockable.
*/
-#if defined(__OPTIMIZE__) && !defined(__SANITIZE_ADDRESS__)
+#define QLNULL ((QemuLockable *)0)
void unknown_lock_type(void *);
-#else
-static inline void unknown_lock_type(void *unused)
-{
- abort();
-}
-#endif
+
static inline __attribute__((__always_inline__)) QemuLockable *
qemu_make_lockable(void *x, QemuLockable *lockable)
--
2.7.4
next prev parent reply other threads:[~2020-06-03 23:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 22:49 [PATCH 0/2] Use QLNULL for null lockable Joe Slater
2020-06-03 22:49 ` [PATCH 1/2] lockable: use QLNULL for a " Joe Slater
2020-06-04 16:22 ` Eric Blake
2020-06-03 22:49 ` Joe Slater [this message]
2020-06-04 16:31 ` [PATCH 2/2] lockable: do not rely on optimization for null lockables Eric Blake
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=20200603224903.26268-3-joe.slater@windriver.com \
--to=joe.slater@windriver.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=qemu-trivial@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).