[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48BD6190.7070006@panasas.com>
Date: Tue, 02 Sep 2008 18:53:52 +0300
From: Boaz Harrosh <bharrosh@...asas.com>
To: Ingo Molnar <mingo@...e.hu>, Rusty Russell <rusty@...tcorp.com.au>,
"David S. Miller" <davem@...emloft.net>,
Ivo van Doorn <IvDoorn@...il.com>,
"John W. Linville" <linville@...driver.com>
CC: Alexey Dobriyan <adobriyan@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Theodore Tso <tytso@....edu>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Jan Beulich <jbeulich@...ell.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH 3/5 ver2] virtio: Fix non-const BUILD_BUG_ON usage
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@...asas.com>
CC: Ingo Molnar <mingo@...e.hu>
CC: Rusty Russell <rusty@...tcorp.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists