All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: outreachy-kernel@googlegroups.com
Cc: Vaishali Thakkar <vthakkar1994@gmail.com>
Subject: Re: [Outreachy kernel] [RESEND PATCH v2 2/2] Staging: rtl8723au: Use put_unaligned_le16
Date: Fri, 20 Feb 2015 10:36:55 +0100	[thread overview]
Message-ID: <6043845.WWkL2rCT3V@wuerfel> (raw)
In-Reply-To: <9defe79e0f212c883f260e27a67bff9f9ba013ba.1424421580.git.vthakkar1994@gmail.com>

On Friday 20 February 2015 14:18:45 Vaishali Thakkar wrote:
> Using byte ordering functions and then memcpy() is risky and
> prone to hide errors which are hard to track down. So, this
> patch introduces the use of function put_unaligned_le16 which
> makes the code clear. Here, use of variable tim_bitmap_le
> and variable itself is removed. Also, to be compatible with the
> changes header file is added too.
> 
> Coccinelle is used to do this change and semantic patch used for
> this is as follows:
> 
> @a@
> typedef __le16;
> __le16 e16;
> identifier tmp;
> expression ptr;
> expression y,e;
> type T;
> @@
> 
> - tmp = cpu_to_le16(y);
> 
> <+... when != tmp
> (
> - memcpy(ptr, (T)&tmp, \(2\|sizeof(__le16)\|sizeof(e16)\));
> + put_unaligned_le16(y,ptr);
> |
> - memcpy(ptr, (T)&tmp, ...);
> + put_unaligned_le16(y,ptr);
> )
> ...+>
> ? tmp = e
> 
> @@ type T; identifier a.tmp; @@
> 
> - T tmp;
> ...when != tmp
> 
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> 

Reviewed-by: Arnd Bergmann <arnd@arndb.de>


      reply	other threads:[~2015-02-20  9:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20  8:48 [RESEND PATCH 0/2] Staging: Use put_unaligned_le16 Vaishali Thakkar
2015-02-20  8:48 ` [RESEND PATCH v3 1/2] Staging: rtl8188eu: " Vaishali Thakkar
2015-02-20  9:37   ` [Outreachy kernel] " Arnd Bergmann
2015-02-20  8:48 ` [RESEND PATCH v2 2/2] Staging: rtl8723au: " Vaishali Thakkar
2015-02-20  9:36   ` Arnd Bergmann [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=6043845.WWkL2rCT3V@wuerfel \
    --to=arnd@arndb.de \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=vthakkar1994@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.