imd: make it work on big-endian machine
PATCH 1/1 imd: make it work on big-endian machine
The commit
commit 5e335773e0814173b40873a891964a7858d64688
Author: Sascha Hauer <[email protected]>
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 imd->type field needs addition convertion 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 convertion via imd_read_type().
--- common/imd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
common/imd.c +2 -2
@@ -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);
Signature · 7 lines
2.7.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · On Fri, 20 May 2016 00:05:59 +0300 Antony Pavlov <[email protected]>…
The commit
commit
5e335773e0814173b40873a891964a7858d64688
Author: Sascha Hauer <[email protected]>
Date: Tue Mar 29 10:06:46 2016 +0200imd: use struct
imd_header* as argument
Quoted 7 lines
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
imd->typefield needs addition convertion
^^^^^^^^^^
Hmm, It looks like I have to fix a typo: "convertion" -> "conversion". I'll resend v2 version of the patch in a few minutes.
Quoted 41 lines
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 convertion via
imd_read_type().Signed-off-by Antony Pavlov <[email protected]>--- common/imd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)common/imd.c +2
-2@@ -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);Signature · 1 line
2.7.0
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox