From: Boaz Harrosh <bharrosh@panasas.com>
To: Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>,
"David S. Miller" <davem@davemloft.net>,
Ivo van Doorn <IvDoorn@gmail.com>,
"John W. Linville" <linville@tuxdriver.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Theodore Tso <tytso@mit.edu>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jan Beulich <jbeulich@novell.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/5 ver2] virtio: Fix non-const BUILD_BUG_ON usage
Date: Tue, 02 Sep 2008 18:53:52 +0300 [thread overview]
Message-ID: <48BD6190.7070006@panasas.com> (raw)
In-Reply-To: <48BBEA82.4020903@panasas.com>
In virtio_has_feature() BUILD_BUG_ON can not be used cross inline
parametrization boundary. I've put the BUILD_BUG_ON(_ZERO) in a
macro outside of the inline definition. (So it is in the caller scope).
However It is no longer legal to pass BUILD_BUG_ON a non-const
expression so users like virtio_config_buf() should caller
__virtio_has_feature() which does the actual code minus the
check.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Rusty Russell <rusty@rustcorp.com.au>
---
include/linux/virtio_config.h | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index bf8ec28..7accb1d 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -92,17 +92,18 @@ void virtio_check_driver_offered_feature(const struct virtio_device *vdev,
* @vdev: the device
* @fbit: the feature bit
*/
-static inline bool virtio_has_feature(const struct virtio_device *vdev,
+static inline bool __virtio_has_feature(const struct virtio_device *vdev,
unsigned int fbit)
{
- /* Did you forget to fix assumptions on max features? */
- if (__builtin_constant_p(fbit))
- BUILD_BUG_ON(fbit >= 32);
-
virtio_check_driver_offered_feature(vdev, fbit);
return test_bit(fbit, vdev->features);
}
+/* Did you forget to fix assumptions on max features? */
+#define virtio_has_feature(vdev, fbit) \
+ (BUILD_BUG_ON_ZERO(fbit >= 32) + __virtio_has_feature(vdev, fbit))
+
+
/**
* virtio_config_val - look for a feature and get a virtio config entry.
* @vdev: the virtio device
@@ -120,7 +121,7 @@ static inline int virtio_config_buf(struct virtio_device *vdev,
unsigned int offset,
void *buf, unsigned len)
{
- if (!virtio_has_feature(vdev, fbit))
+ if (!__virtio_has_feature(vdev, fbit))
return -ENOENT;
vdev->config->get(vdev, offset, buf, len);
--
1.5.6.rc1.5.gadf6
next prev parent reply other threads:[~2008-09-02 15:54 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 13:00 [PATCHSET 0/5] BUILD_BUG_ON: error on none-const expressions Boaz Harrosh
2008-09-01 13:07 ` [PATCH] debug, x86: move BUILD_BUG_ON() ARRAY_SIZE and __FUNCTION__ Boaz Harrosh
2008-09-01 13:11 ` [PATCH 2/5] net/niu: Fix none-const BUILD_BUG_ON usage Boaz Harrosh
2008-09-01 13:13 ` [PATCH 3/5] virtio: " Boaz Harrosh
2008-09-02 15:53 ` Boaz Harrosh [this message]
2008-09-01 13:21 ` [PATCH 4/5] rt2x00: Compiler warning unmasked by fix of BUILD_BUG_ON Boaz Harrosh
2008-09-01 13:27 ` Ivo Van Doorn
2008-09-01 13:27 ` Benny Halevy
2008-09-01 13:44 ` [PATCH 4/5 ver2] " Boaz Harrosh
2008-09-01 14:01 ` Ivo Van Doorn
2008-09-01 15:17 ` Boaz Harrosh
2008-09-01 16:34 ` Ivo van Doorn
2008-09-02 14:20 ` Boaz Harrosh
2008-09-02 14:27 ` Ivo van Doorn
2008-09-02 15:55 ` Boaz Harrosh
2008-09-01 13:28 ` [PATCH 5/5] debug: BUILD_BUG_ON: error on non-const expressions Boaz Harrosh
2008-09-01 13:55 ` Jan Beulich
2008-09-01 14:21 ` Boaz Harrosh
2008-09-01 14:36 ` Jan Beulich
2008-09-01 15:00 ` Boaz Harrosh
2008-09-01 15:29 ` Jan Beulich
2008-09-01 16:41 ` Boaz Harrosh
2008-09-02 7:47 ` Jan Beulich
2008-09-02 15:19 ` Boaz Harrosh
2008-09-02 15:57 ` [PATCH 5/5 ver2] " Boaz Harrosh
2008-09-02 16:06 ` Boaz Harrosh
2008-09-02 16:11 ` Jan Beulich
2008-09-03 8:57 ` Boaz Harrosh
2008-09-03 10:19 ` Jan Beulich
2008-09-03 10:52 ` Boaz Harrosh
2008-10-02 5:35 ` Rusty Russell
2008-10-05 9:34 ` Boaz Harrosh
2008-09-02 16:07 ` [PATCH 5/5 ver3] " Boaz Harrosh
2008-09-06 16:01 ` [PATCHSET 0/5] BUILD_BUG_ON: error on none-const expressions Ingo Molnar
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=48BD6190.7070006@panasas.com \
--to=bharrosh@panasas.com \
--cc=IvDoorn@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.