[coreboot-gerrit] Change in coreboot[master]: cbfs: Get rid of void pointer math

Richard Spiegel (Code Review) gerrit at coreboot.org
Mon Oct 29 22:33:10 CET 2018


Richard Spiegel has uploaded this change for review. ( https://review.coreboot.org/29344


Change subject: cbfs: Get rid of void pointer math
......................................................................

cbfs: 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=none.

Change-Id: I1bbdc9499d257c5051fd7a86ca8b5c68bbf2e81d
Signed-off-by: Richard Spiegel <richard.spiegel at silverbackltd.com>
---
M payloads/coreinfo/cbfs_module.c
M util/cbfstool/cbfs_image.c
2 files changed, 3 insertions(+), 3 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/29344/1

diff --git a/payloads/coreinfo/cbfs_module.c b/payloads/coreinfo/cbfs_module.c
index 275c84e..6f40081 100644
--- a/payloads/coreinfo/cbfs_module.c
+++ b/payloads/coreinfo/cbfs_module.c
@@ -69,7 +69,7 @@
 			return NULL;
 		if (f->magic == LARCHIVE_MAGIC)
 			return f;
-		f = (void *)f + ntohl(header->align);
+		f = (void *)(f + ntohl(header->align));
 	}
 }
 
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 74572a9..7abedea 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -723,8 +723,8 @@
 
 	len = addr_next - addr - min_entry_size;
 	/* keep space for master header pointer */
-	if ((void *)entry + min_entry_size + len > buffer_get(&image->buffer) +
-		buffer_size(&image->buffer) - sizeof(int32_t)) {
+	if ((void *)(entry + min_entry_size + len) > buffer_get(&image->buffer)
+		+ buffer_size(&image->buffer) - sizeof(int32_t)) {
 		len -= sizeof(int32_t);
 	}
 	cbfs_create_empty_entry(entry, CBFS_COMPONENT_NULL, len, "");

-- 
To view, visit https://review.coreboot.org/29344
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1bbdc9499d257c5051fd7a86ca8b5c68bbf2e81d
Gerrit-Change-Number: 29344
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Spiegel <richard.spiegel at silverbackltd.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181029/b812535d/attachment.html>


More information about the coreboot-gerrit mailing list