Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f440d909 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman
Browse files

staging: lustre: remove CLASSERT macro



lustre uses a fake switch() statement as a compile-time assert, but unfortunately
each use of that causes a warning when building with clang:

drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42'
drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT'
 #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)

As Greg suggested, let's just kill off this macro completely instead of
fixing it. This replaces it with BUILD_BUG_ON(), which means we have
to negate all the conditions in the process.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 757b9bd0
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -277,22 +277,6 @@ do { \
#define CFS_ALLOC_PTR(ptr)      LIBCFS_ALLOC(ptr, sizeof(*(ptr)))
#define CFS_FREE_PTR(ptr)       LIBCFS_FREE(ptr, sizeof(*(ptr)))

/** Compile-time assertion.
 *
 * Check an invariant described by a constant expression at compile time by
 * forcing a compiler error if it does not hold.  \a cond must be a constant
 * expression as defined by the ISO C Standard:
 *
 *       6.8.4.2  The switch statement
 *       ....
 *       [#3] The expression of each case label shall be  an  integer
 *       constant   expression  and  no  two  of  the  case  constant
 *       expressions in the same switch statement shall have the same
 *       value  after  conversion...
 *
 */
#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)

/* max value for numeric network address */
#define MAX_NUMERIC_VALUE 0xffffffff

+8 −8
Original line number Diff line number Diff line
@@ -258,8 +258,8 @@ int kiblnd_unpack_msg(struct kib_msg *msg, int nob)
	if (flip) {
		/* leave magic unflipped as a clue to peer endianness */
		msg->ibm_version = version;
		CLASSERT(sizeof(msg->ibm_type) == 1);
		CLASSERT(sizeof(msg->ibm_credits) == 1);
		BUILD_BUG_ON(sizeof(msg->ibm_type) != 1);
		BUILD_BUG_ON(sizeof(msg->ibm_credits) != 1);
		msg->ibm_nob     = msg_nob;
		__swab64s(&msg->ibm_srcnid);
		__swab64s(&msg->ibm_srcstamp);
@@ -1247,10 +1247,10 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo)
	dev = net->ibn_dev;

	/* pre-mapped messages are not bigger than 1 page */
	CLASSERT(IBLND_MSG_SIZE <= PAGE_SIZE);
	BUILD_BUG_ON(IBLND_MSG_SIZE > PAGE_SIZE);

	/* No fancy arithmetic when we do the buffer calculations */
	CLASSERT(!(PAGE_SIZE % IBLND_MSG_SIZE));
	BUILD_BUG_ON(PAGE_SIZE % IBLND_MSG_SIZE);

	tpo->tpo_hdev = kiblnd_current_hdev(dev);

@@ -2943,7 +2943,7 @@ static int kiblnd_startup(lnet_ni_t *ni)
	if (ni->ni_interfaces[0]) {
		/* Use the IPoIB interface specified in 'networks=' */

		CLASSERT(LNET_MAX_INTERFACES > 1);
		BUILD_BUG_ON(LNET_MAX_INTERFACES <= 1);
		if (ni->ni_interfaces[1]) {
			CERROR("Multiple interfaces not supported\n");
			goto failed;
@@ -3020,11 +3020,11 @@ static void __exit ko2iblnd_exit(void)

static int __init ko2iblnd_init(void)
{
	CLASSERT(sizeof(struct kib_msg) <= IBLND_MSG_SIZE);
	CLASSERT(offsetof(struct kib_msg,
	BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE);
	BUILD_BUG_ON(!offsetof(struct kib_msg,
			  ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
			  <= IBLND_MSG_SIZE);
	CLASSERT(offsetof(struct kib_msg,
	BUILD_BUG_ON(!offsetof(struct kib_msg,
			  ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
			  <= IBLND_MSG_SIZE);

+2 −2
Original line number Diff line number Diff line
@@ -2904,8 +2904,8 @@ static int __init ksocklnd_init(void)
	int rc;

	/* check ksnr_connected/connecting field large enough */
	CLASSERT(SOCKLND_CONN_NTYPES <= 4);
	CLASSERT(SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN);
	BUILD_BUG_ON(SOCKLND_CONN_NTYPES > 4);
	BUILD_BUG_ON(SOCKLND_CONN_ACK != SOCKLND_CONN_BULK_IN);

	/* initialize the_ksocklnd */
	the_ksocklnd.lnd_type     = SOCKLND;
+1 −1
Original line number Diff line number Diff line
@@ -1658,7 +1658,7 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello)
	if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) {
		struct lnet_magicversion *hmv = (struct lnet_magicversion *)hello;

		CLASSERT(sizeof(struct lnet_magicversion) ==
		BUILD_BUG_ON(sizeof(struct lnet_magicversion) !=
			 offsetof(ksock_hello_msg_t, kshm_src_nid));

		if (hmv->version_major == cpu_to_le16(KSOCK_PROTO_V1_MAJOR) &&
+1 −1
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello)
	int rc;
	int i;

	CLASSERT(sizeof(struct lnet_magicversion) == offsetof(struct lnet_hdr, src_nid));
	BUILD_BUG_ON(sizeof(struct lnet_magicversion) != offsetof(struct lnet_hdr, src_nid));

	LIBCFS_ALLOC(hdr, sizeof(*hdr));
	if (!hdr) {
Loading