imd: make it work on big-endian machines
The commit
commit 5e335773e0
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
b2b000699b
commit
fc71878c1f
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue