Peter Marheine has uploaded this change for review.

View Change

Add clarification to struct flash_region on chipoff_t

Although chipoff_t is fairly clearly documented on its own, it seems
fairly frequent that developers will treat the end address of a flash
region as an exclusive upper bound rather than the inclusive one it
should be; for example CB:82496 fixes an incorrect use that affected
multiple sites, and CB:73571 stemmed from a similar cause. Add a
clarifying comment to call attention to this, to help programmers avoid
making similar mistakes in the future.

Change-Id: I80b61a87ca31bd5a116224aadb4e211ee6841e1f
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
---
M include/layout.h
1 file changed, 5 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/77/82677/1
diff --git a/include/layout.h b/include/layout.h
index 5614bea..d03a15b 100644
--- a/include/layout.h
+++ b/include/layout.h
@@ -37,6 +37,11 @@

struct flash_region {
char *name;
+ /*
+ * Note that because start and end are chipoff_t, end is an inclusive upper
+ * bound: the length of a region is (end - start + 1) bytes and it is
+ * impossible to represent a region with zero length.
+ */
chipoff_t start;
chipoff_t end;
bool read_prot;

To view, visit change 82677. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I80b61a87ca31bd5a116224aadb4e211ee6841e1f
Gerrit-Change-Number: 82677
Gerrit-PatchSet: 1
Gerrit-Owner: Peter Marheine <pmarheine@chromium.org>