From: Amerigo Wang <xiyou.wangcong@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel.h: Verify that arguments to swap() are the same type
Date: Thu, 16 Jul 2009 11:19:20 +0800 [thread overview]
Message-ID: <20090716031920.GB5713@cr0.nay.redhat.com> (raw)
In-Reply-To: <1247708061.15087.13.camel@Joe-Laptop.home>
On Wed, Jul 15, 2009 at 06:34:21PM -0700, Joe Perches wrote:
>Signed-off-by: Joe Perches <joe@perches.com>
>
Hmm, sounds reasonable.
Does this catch any actual wrong usages of swap()?
Acked-by: WANG Cong <xiyou.wangcong@gmail.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@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2009-07-16 3:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-16 1:34 Joe Perches
2009-07-16 3:19 ` Amerigo Wang [this message]
2009-07-16 5:09 ` Joe Perches
2009-07-23 21:47 ` Andrew Morton
2009-07-23 22:25 ` Joe Perches
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=20090716031920.GB5713@cr0.nay.redhat.com \
--to=xiyou.wangcong@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®