public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 1/3] lib: Add swap() macro
Date: Fri, 05 Dec 2014 18:44:19 +0200	[thread overview]
Message-ID: <87y4qmnj18.fsf@intel.com> (raw)
In-Reply-To: <1417791854-9800-1-git-send-email-ville.syrjala@linux.intel.com>

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)...

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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2014-12-05 16:48 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 ` Jani Nikula [this message]
2014-12-05 17:06   ` [PATCH i-g-t 1/3] lib: Add swap() macro Ville Syrjälä
2014-12-05 17:39     ` Jani Nikula

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=87y4qmnj18.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