public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 1/3] lib: Add swap() macro
Date: Fri, 05 Dec 2014 19:39:25 +0200	[thread overview]
Message-ID: <87sigunghe.fsf@intel.com> (raw)
In-Reply-To: <20141205170650.GP10649@intel.com>

On Fri, 05 Dec 2014, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Fri, Dec 05, 2014 at 06:44:19PM +0200, Jani Nikula wrote:
>> On Fri, 05 Dec 2014, ville.syrjala@linux.intel.com wrote:
>> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> >
>> > swap() will swap its two arguments while keeping the required
>> > tmp variable hidden. Makes for neater code.
>> >
>> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> > ---
>> >  lib/igt_aux.h | 6 ++++++
>> >  1 file changed, 6 insertions(+)
>> >
>> > diff --git a/lib/igt_aux.h b/lib/igt_aux.h
>> > index 6c83c53..63e1b06 100644
>> > --- a/lib/igt_aux.h
>> > +++ b/lib/igt_aux.h
>> > @@ -90,4 +90,10 @@ void intel_require_memory(uint32_t count, uint32_t size, unsigned mode);
>> >  #define min(a, b) ((a) < (b) ? (a) : (b))
>> >  #define max(a, b) ((a) > (b) ? (a) : (b))
>> >  
>> > +#define swap(a, b) do {		\
>> > +	typeof(a) _tmp = (a);	\
>> > +	(a) = (b);		\
>> > +	(b) = _tmp;		\
>> > +} while (0)
>> 
>> Nitpick, make the macro take pointers instead, and amend the cocci patch
>> accordingly? To a grumpy old C coder, swap(&a, &b) is so much more
>> obvious than swap(a, b)...
>
> But then it's different than the kernel swap() we all love.

Fair enough. I'll cry a little. I'll feel better soon.


>
>> 
>> Jani.
>> 
>> 
>> > +
>> >  #endif /* IGT_AUX_H */
>> > -- 
>> > 2.0.4
>> >
>> > _______________________________________________
>> > Intel-gfx mailing list
>> > Intel-gfx@lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>> 
>> -- 
>> Jani Nikula, Intel Open Source Technology Center
>
> -- 
> Ville Syrjälä
> Intel OTC

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2014-12-05 17:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05 15:04 [PATCH i-g-t 1/3] lib: Add swap() macro ville.syrjala
2014-12-05 15:04 ` [PATCH i-g-t 2/3] lib/igt.cocci: Deal with min/max/swap ville.syrjala
2014-12-05 15:04 ` [PATCH i-g-t 3/3] tests: Run lib/igt.cocci ville.syrjala
2014-12-05 16:44 ` [PATCH i-g-t 1/3] lib: Add swap() macro Jani Nikula
2014-12-05 17:06   ` Ville Syrjälä
2014-12-05 17:39     ` Jani Nikula [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=87sigunghe.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /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