summaryrefslogtreecommitdiff
path: root/util/cbfstool/common.h
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-01-26 09:01:14 -0600
committerAaron Durbin <adurbin@chromium.org>2016-01-26 17:28:21 +0100
commit2dd5f4cce61f95468cd84d7272b8c455d0b6408b (patch)
tree7df081b6c8b130471f497acd816c9db1397ef28f /util/cbfstool/common.h
parent0a97d7eeba244b3a18249d07995dcfa884c14920 (diff)
downloadcoreboot-2dd5f4cce61f95468cd84d7272b8c455d0b6408b.tar.xz
cbfstool: provide buffer_offset()
Instead of people open coding the offset field access within a struct buffer provide buffer_offset() so that the implementation can change if needed without high touch in the code base. Change-Id: I751c7145687a8529ab549d87e412b7f2d1fb90ed Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/13468 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Diffstat (limited to 'util/cbfstool/common.h')
-rw-r--r--util/cbfstool/common.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 561a17abe3..42ae1e2b3d 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -62,6 +62,11 @@ static inline size_t buffer_size(const struct buffer *b)
return b->size;
}
+static inline size_t buffer_offset(const struct buffer *b)
+{
+ return b->offset;
+}
+
/*
* Shrink a buffer toward the beginning of its previous space.
* Afterward, buffer_delete() remains the means of cleaning it up. */
@@ -125,7 +130,7 @@ static inline void *buffer_get_original_backing(const struct buffer *b)
{
if (!b)
return NULL;
- return b->data - b->offset;
+ return buffer_get(b) - buffer_offset(b);
}
/* Creates an empty memory buffer with given size.