sparse_img.py: Don't write empty map groups.

In certain cases, we may have no mapping of ZERO or NONZERO blocks in
the image (such as squashfs at the moment). Don't write those groups if
they are empty.

Change-Id: I82aa05fbbd79130b08868585edd5298e531c4f5a
This commit is contained in:
Tao Bao 2015-06-26 17:49:39 -07:00 committed by Simon Wilson
parent ef5dc90bba
commit 7f9470cda3
1 changed files with 6 additions and 2 deletions

View File

@ -204,8 +204,12 @@ class SparseImage(object):
nonzero_blocks.append(b) nonzero_blocks.append(b)
nonzero_blocks.append(b+1) nonzero_blocks.append(b+1)
out["__ZERO"] = RangeSet(data=zero_blocks) assert zero_blocks or nonzero_blocks
out["__NONZERO"] = RangeSet(data=nonzero_blocks)
if zero_blocks:
out["__ZERO"] = rangelib.RangeSet(data=zero_blocks)
if nonzero_blocks:
out["__NONZERO"] = rangelib.RangeSet(data=nonzero_blocks)
def ResetFileMap(self): def ResetFileMap(self):
"""Throw away the file map and treat the entire image as """Throw away the file map and treat the entire image as