From: Wu Fengguang <wfg@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
L-K <linux-kernel@vger.kernel.org>
Subject: Re: generic swap()
Date: Fri, 6 Feb 2009 09:26:57 +0800 [thread overview]
Message-ID: <20090206012657.GA6850@localhost> (raw)
In-Reply-To: <1232099136.14073.9.camel@laptop>
On Fri, Jan 16, 2009 at 10:45:36AM +0100, Peter Zijlstra wrote:
> On Fri, 2009-01-16 at 01:38 -0800, Andrew Morton wrote:
> > On Fri, 16 Jan 2009 10:26:34 +0100 Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > > Hi,
> > >
> > > Where did this patch come from? -- I can't seem to find it on lkml at all..
> >
> > That's a damn good question. I received:
>
> Hehe, one of the mysteries of life then :-)
>
> > > The reason I ask it that I wonder why swap() has a return value?
> >
> > Accident, I guess.
> >
> > > +#define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; })
> >
> > You think it should use the do{}while(0) thing?
>
> That was what I was thinking indeed. Non of the current users appear to
> make use of the (somewhat arbitrary) return value, so lets change it
> before someone gets creative ;-)
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Wu Fengguang <fengguang.wu@intel.com>
Good change, thank you Peter.
//Sorry I was not able to read this email because of VPN issues.
Fengguang
> ---
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 343df9e..7fa3718 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -480,7 +480,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
> /*
> * swap - swap value of @a and @b
> */
> -#define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; })
> +#define swap(a, b) \
> + do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
>
> /**
> * container_of - cast a member of a structure out to the containing structure
>
prev parent reply other threads:[~2009-02-06 1:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-16 9:26 generic swap() Peter Zijlstra
2009-01-16 9:38 ` Andrew Morton
2009-01-16 9:45 ` Peter Zijlstra
2009-02-06 1:26 ` Wu Fengguang [this message]
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=20090206012657.GA6850@localhost \
--to=wfg@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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