linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gertjan van Wingerde <gwingerde@gmail.com>
To: Julia Lawall <julia@diku.dk>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
	Ivo van Doorn <IvDoorn@gmail.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org, users@rt2x00.serialmonkey.com
Subject: Re: [PATCH 5/9] drivers/net/wireless: Correct code taking the size of a pointer
Date: Mon, 14 Dec 2009 23:07:25 +0100	[thread overview]
Message-ID: <4B26B71D.1080903@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0912131706390.27767@ask.diku.dk>

On 12/13/09 17:07, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> sizeof(iv16) and sizeof(iv32) are the sizes of pointers.  Change them to
> the size of the copied data.
> 
> Furthermore, iveiv_entry is a local structure that has just been
> initialized and is not visible outside this function.  Thus, there would
> seem to be no point to copy data into it.  The order of the arguments is
> thus changed to copy the data into the parameters, which are provided as
> pointers, suggesting in this case that they should be used to return values.
> 
> A simplified version of the semantic patch that finds the first problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression *x;
> expression f;
> type T;
> @@
> 
> *f(...,(T)x,...)
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

This is certainly better than the original code.

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> 
> ---
>  drivers/net/wireless/rt2x00/rt2800lib.c        |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index eb1e1d0..f52b82e 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -2140,8 +2140,8 @@ static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
>  	rt2800_register_multiread(rt2x00dev, offset,
>  				      &iveiv_entry, sizeof(iveiv_entry));
>  
> -	memcpy(&iveiv_entry.iv[0], iv16, sizeof(iv16));
> -	memcpy(&iveiv_entry.iv[4], iv32, sizeof(iv32));
> +	memcpy(iv16, &iveiv_entry.iv[0], sizeof(*iv16));
> +	memcpy(iv32, &iveiv_entry.iv[4], sizeof(*iv32));
>  }
>  
>  static int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
> 


  reply	other threads:[~2009-12-14 22:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-13 11:42 [PATCH 5/9] drivers/net/wireless: Correct code taking the size of a pointer Julia Lawall
2009-12-13 12:55 ` Andreas Schwab
2009-12-13 13:10   ` Julia Lawall
2009-12-13 16:07   ` Julia Lawall
2009-12-14 22:07     ` Gertjan van Wingerde [this message]
2009-12-15 17:09       ` Ivo van Doorn
2009-12-13 16:08   ` Julia Lawall

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=4B26B71D.1080903@gmail.com \
    --to=gwingerde@gmail.com \
    --cc=IvDoorn@gmail.com \
    --cc=julia@diku.dk \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=schwab@linux-m68k.org \
    --cc=users@rt2x00.serialmonkey.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;
as well as URLs for NNTP newsgroup(s).