diff options
| author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-01-10 13:01:46 +1100 |
|---|---|---|
| committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-02-23 13:14:24 +1100 |
| commit | 5bcb6c4ac405ab7dd5227069b5c2e686d5d087eb (patch) | |
| tree | 77c7d0bc2dd3c3a75bd5da2fe77ebd0a5c7dfac4 /core/test | |
| parent | 0d8fb9b489f5a7f6840ed7edcc1c8c7d65b79dd2 (diff) | |
| download | blackbird-skiboot-5bcb6c4ac405ab7dd5227069b5c2e686d5d087eb.tar.gz blackbird-skiboot-5bcb6c4ac405ab7dd5227069b5c2e686d5d087eb.zip | |
nvram-format: Fix endian issues
NVRAM formats are always BE, so let's use the sparse annotation to catch
any issues (and correct said issues).
On LE platforms, the test was erroneously passing as with building the
nvram-format code on LE we were produces an incorrect NVRAM image.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/test')
| -rw-r--r-- | core/test/run-nvram-format.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/test/run-nvram-format.c b/core/test/run-nvram-format.c index 4ca2cded..5bd8ea2a 100644 --- a/core/test/run-nvram-format.c +++ b/core/test/run-nvram-format.c @@ -69,8 +69,8 @@ int main(void) nvram_image = malloc(sz); assert(nvram_format(nvram_image, sz)==0); assert(nvram_check(nvram_image, sz)==0); - assert(nvram_image[sz-13]==0); - assert(nvram_image[sz-14]==1); + assert(nvram_image[sz-14]==0); + assert(nvram_image[sz-13]==1); h = (struct chrp_nvram_hdr*)(&nvram_image[NVRAM_SIZE_COMMON + NVRAM_SIZE_FW_PRIV]); assert(memcmp(h->name, "wwwwwwwwwwww", 12)==0); free(nvram_image); @@ -87,7 +87,7 @@ int main(void) /* Does our NUL checking work? */ assert(nvram_format(nvram_image, 128 * 1024) == 0); h = (struct chrp_nvram_hdr *) nvram_image; - memset((char *) h + sizeof(*h), 0xFF, h->len * 16 - sizeof(*h)); + memset((char *) h + sizeof(*h), 0xFF, be16_to_cpu(h->len) * 16 - sizeof(*h)); assert(nvram_check(nvram_image, 128 * 1024) != 0); assert(nvram_format(nvram_image, 128*1024)==0); |

