mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 01/11] net: net_read_uint32: assert that only 32 bit are read
Date: Mon, 10 Feb 2014 09:02:44 +0100	[thread overview]
Message-ID: <20140210080244.GD17250@pengutronix.de> (raw)
In-Reply-To: <1391808493-27328-1-git-send-email-u.kleine-koenig@pengutronix.de>

On Fri, Feb 07, 2014 at 10:28:03PM +0100, Uwe Kleine-König wrote:
> On some architectures (e.g. alpha, amd64, arm64, ia64, s390x, mips64)
> sizeof(ulong) is 8 which made net_read_uint32 actually read too much and
> even returned the wrong value on big endian machines.
> (Note the second issue isn't that critical though, because the only
> architecture from the list above that uses big endian byte order is s390x
> ...)
> 
> Also change the argument to void * because the pointer is not necessarily
> properly aligned.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Applied this series, thanks

Sascha

> ---
>  include/net.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net.h b/include/net.h
> index a4cfec712374..8388e2f12ebe 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -269,11 +269,11 @@ static inline IPaddr_t net_read_ip(void *from)
>  }
>  
>  /* return uint32 *in network byteorder* */
> -static inline uint32_t net_read_uint32(uint32_t *from)
> +static inline uint32_t net_read_uint32(void *from)
>  {
> -	ulong l;
> -	memcpy((void*)&l, (void*)from, sizeof(l));
> -	return l;
> +	uint32_t tmp;
> +	memcpy(&tmp, from, sizeof(tmp));
> +	return tmp;
>  }
>  
>  /* write IP *in network byteorder* */
> -- 
> 1.8.5.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2014-02-10  8:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 21:28 Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 02/11] nfs: fix mount prog version in portmap lookup Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 03/11] nfs: skip over stale rpc packets Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 04/11] nfs: shorten and simplify rpc_add_credentials a bit Uwe Kleine-König
2014-02-08  6:51   ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-08 15:11     ` Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 05/11] nfs: simplify rpc_lookup_req Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 06/11] nfs: drop an unneeded variable from nfs_do_open() Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 07/11] net: new function net_read_uint64 Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 08/11] net: provide alternatives to {ntoh, hton}[sl] funtions with cleaner semantics Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 09/11] nfs: switch to nfs3 Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 10/11] mount: support filesystem options passed via -o Uwe Kleine-König
2014-02-07 21:28 ` [PATCH v2 11/11] nfs: parse nfsport and mount port from file system options Uwe Kleine-König
2014-02-10  8:02 ` Sascha Hauer [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=20140210080244.GD17250@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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