[coreboot-gerrit] Patch set updated for coreboot: cbfstool: move tests for fixed-location files earlier

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Thu Aug 13 10:27:59 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11221

-gerrit

commit c69f876b62269edd456f058a0e8e2e236aebe881
Author: Patrick Georgi <pgeorgi at google.com>
Date:   Wed Aug 12 12:05:21 2015 +0200

    cbfstool: move tests for fixed-location files earlier
    
    ... and the assert is gone.
    The actual action of adding a just-right file can be moved after the tests
    since it's exactly the condition those tests don't continue or break on.
    
    Change-Id: I6d0e829e0158198301136ada9a0de2f168ceee3f
    Signed-off-by: Patrick Georgi <pgeorgi at google.com>
---
 util/cbfstool/cbfs_image.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 1a20fba..19281ee 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -580,6 +580,26 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
 		if (addr + need_size > addr_next)
 			continue;
 
+		// Test for complicated cases
+		if (content_offset > 0) {
+			if (addr_next < content_offset) {
+				DEBUG("Not for specified offset yet");
+				continue;
+			} else if (addr > content_offset) {
+				DEBUG("Exceed specified content_offset.");
+				break;
+			} else if (addr + header_size > content_offset) {
+				ERROR("Not enough space for header.\n");
+				break;
+			} else if (content_offset + buffer->size > addr_next) {
+				ERROR("Not enough space for content.\n");
+				break;
+			}
+		}
+
+		// TODO there are more few tricky cases that we may
+		// want to fit by altering offset.
+
 		// Can we simply put object here?
 		if (!content_offset || content_offset == addr + header_size) {
 			DEBUG("Filling new entry data (%zd bytes).\n",
@@ -613,27 +633,6 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
 			return 0;
 		}
 
-		// We need to put content here, and the case is really
-		// complicated...
-		assert(content_offset);
-		if (content_offset > 0) {
-			if (addr_next < content_offset) {
-				DEBUG("Not for specified offset yet");
-				continue;
-			} else if (addr > content_offset) {
-				DEBUG("Exceed specified content_offset.");
-				break;
-			} else if (addr + header_size > content_offset) {
-				ERROR("Not enough space for header.\n");
-				break;
-			} else if (content_offset + buffer->size > addr_next) {
-				ERROR("Not enough space for content.\n");
-				break;
-			}
-		}
-
-		// TODO there are more few tricky cases that we may
-		// want to fit by altering offset.
 		DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n",
 		      addr, addr_next - addr, content_offset);
 



More information about the coreboot-gerrit mailing list