mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] imd: make it work on big-endian machines
Date: Mon, 23 May 2016 09:33:37 +0200	[thread overview]
Message-ID: <20160523073337.GN11148@pengutronix.de> (raw)
In-Reply-To: <1463721951-5621-1-git-send-email-antonynpavlov@gmail.com>

On Fri, May 20, 2016 at 08:25:51AM +0300, Antony Pavlov wrote:
> The commit
> 
>     commit 5e335773e0814173b40873a891964a7858d64688
>     Author: Sascha Hauer <s.hauer@pengutronix.de>
>     Date:   Tue Mar 29 10:06:46 2016 +0200
> 
>         imd: use struct imd_header * as argument
> 
> introduces additional imd type checks like this
> 
>     if (!imd_is_string(imd->type))
>            return NULL;
> 
> These checks work incorrectly on any big-endian machine
> because the imd->type field needs addition conversion
> to little-endian byteorder before use.
> 
> Here is the imd command output on big-endian qemu-malta:
> 
>     barebox:/ imd /dev/nor0.barebox
>     release: <NULL>
>     build: <NULL>
> 
> This patch fixes the problem by adding necessary conversion
> via imd_read_type().
> 
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>

Applied, thanks

Sascha

> ---
> 
> Changes since v1:
> 
>   * fix typos in the commit message.
> 
>  common/imd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/imd.c b/common/imd.c
> index 159b73a..a8a10fc 100644
> --- a/common/imd.c
> +++ b/common/imd.c
> @@ -212,7 +212,7 @@ const char *imd_string_data(struct imd_header *imd, int index)
>  	int len = imd_read_length(imd);
>  	char *p = (char *)(imd + 1);
>  
> -	if (!imd_is_string(imd->type))
> +	if (!imd_is_string(imd_read_type(imd)))
>  		return NULL;
>  
>  	for (i = 0; total < len; total += l, p += l) {
> @@ -239,7 +239,7 @@ char *imd_concat_strings(struct imd_header *imd)
>  	char *str;
>  	char *data = (char *)(imd + 1);
>  
> -	if (!imd_is_string(imd->type))
> +	if (!imd_is_string(imd_read_type(imd)))
>  		return NULL;
>  
>  	str = malloc(len);
> -- 
> 2.7.0
> 
> 

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

      reply	other threads:[~2016-05-23  7:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20  5:25 Antony Pavlov
2016-05-23  7:33 ` 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=20160523073337.GN11148@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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