From b93796d624415fdc2ba608a1bd1089cbaaf93dc0 Mon Sep 17 00:00:00 2001 From: Richard Spiegel Date: Mon, 29 Oct 2018 08:01:53 -0700 Subject: payloads/coreinfo/cbfs_module.c: Get rid of void pointer math Pointer math with void pointers is illegal in many compilers, though it works with GCC because it assumes size of void to be 1. Change the pointers or add parenthesis to force a proper order that will not cause compile errors if compiled with a different compiler, and more importantly, don't have unsuspected side effects. BUG=b:118484178 TEST=Build coreinfo with original code, run objdump and saved output. Added modifications, build coreinfo again, run objdump again, compared objdump outputs. Change-Id: I1bbdc9499d257c5051fd7a86ca8b5c68bbf2e81d Signed-off-by: Richard Spiegel Reviewed-on: https://review.coreboot.org/29344 Reviewed-by: Marshall Dawson Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- payloads/coreinfo/cbfs_module.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'payloads/coreinfo') diff --git a/payloads/coreinfo/cbfs_module.c b/payloads/coreinfo/cbfs_module.c index 275c84e986..6a04879440 100644 --- a/payloads/coreinfo/cbfs_module.c +++ b/payloads/coreinfo/cbfs_module.c @@ -69,7 +69,7 @@ static struct cbfile *getfile(struct cbfile *f) return NULL; if (f->magic == LARCHIVE_MAGIC) return f; - f = (void *)f + ntohl(header->align); + f = (struct cbfile *)((u8 *)f + ntohl(header->align)); } } @@ -81,8 +81,8 @@ static struct cbfile *firstfile(void) static struct cbfile *nextfile(struct cbfile *f) { - f = (void *)f + ALIGN(ntohl(f->len) + ntohl(f->offset), - ntohl(header->align)); + f = (struct cbfile *)((u8 *)f + ALIGN(ntohl(f->len) + ntohl(f->offset), + ntohl(header->align))); return getfile(f); } -- cgit v1.2.3