lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090716031920.GB5713@cr0.nay.redhat.com>
Date:	Thu, 16 Jul 2009 11:19:20 +0800
From:	Amerigo Wang <xiyou.wangcong@...il.com>
To:	Joe Perches <joe@...ches.com>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel.h: Verify that arguments to swap() are the same
	type

On Wed, Jul 15, 2009 at 06:34:21PM -0700, Joe Perches wrote:
>Signed-off-by: Joe Perches <joe@...ches.com>
>

Hmm, sounds reasonable.

Does this catch any actual wrong usages of swap()?

Acked-by: WANG Cong <xiyou.wangcong@...il.com>


>diff --git a/include/linux/kernel.h b/include/linux/kernel.h
>index d6320a3..72878a5 100644
>--- a/include/linux/kernel.h
>+++ b/include/linux/kernel.h
>@@ -637,8 +637,13 @@ static inline void ftrace_dump(void) { }
> /*
>  * swap - swap value of @a and @b
>  */
>-#define swap(a, b) \
>-	do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
>+#define swap(a, b)				\
>+do {						\
>+	typeof(a) __tmp = (a);			\
>+	BUILD_BUG_ON(!__same_type(__tmp, (b)));	\
>+	(a) = (b);				\
>+	(b) = __tmp;				\
>+} while (0)
> 
> /**
>  * container_of - cast a member of a structure out to the containing structure
>
>
>--
>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/
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ