binman: Update entry.SetOffsetSize to be optional

At present this function always sets both the offset and the size of
entries. But in some cases we want to set only one or the other, for
example with the forthcoming ifwi entry, where we only set the offset.
Update the function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2019-07-08 13:18:39 -06:00
parent fa1c937832
commit cf54904a99
2 changed files with 16 additions and 7 deletions

View file

@ -236,14 +236,15 @@ class Section(object):
Args: Args:
name: Entry name to update name: Entry name to update
offset: New offset offset: New offset, or None to leave alone
size: New size size: New size, or None to leave alone
""" """
entry = self._entries.get(name) entry = self._entries.get(name)
if not entry: if not entry:
self._Raise("Unable to set offset/size for unknown entry '%s'" % self._Raise("Unable to set offset/size for unknown entry '%s'" %
name) name)
entry.SetOffsetSize(self._skip_at_start + offset, size) entry.SetOffsetSize(self._skip_at_start + offset if offset else None,
size)
def GetEntryOffsets(self): def GetEntryOffsets(self):
"""Handle entries that want to set the offset/size of other entries """Handle entries that want to set the offset/size of other entries

View file

@ -368,13 +368,21 @@ class Entry(object):
Dict: Dict:
key: Entry type key: Entry type
value: List containing position and size of the given entry value: List containing position and size of the given entry
type. type. Either can be None if not known
""" """
return {} return {}
def SetOffsetSize(self, pos, size): def SetOffsetSize(self, offset, size):
self.offset = pos """Set the offset and/or size of an entry
self.size = size
Args:
offset: New offset, or None to leave alone
size: New size, or None to leave alone
"""
if offset is not None:
self.offset = offset
if size is not None:
self.size = size
def SetImagePos(self, image_pos): def SetImagePos(self, image_pos):
"""Set the position in the image """Set the position in the image