Skip to content

Commit 280dd8d

Browse files
committed
refactor: unpack * from map_info to avoid errors
more flexible than fixed _ some unpacking code are unchanged now
1 parent 7c903b8 commit 280dd8d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

qiling/os/memory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def __perms_mapping(ps: int) -> str:
166166

167167
return ''.join(val if idx & ps else '-' for idx, val in perms_d.items())
168168

169-
def __process(lbound: int, ubound: int, perms: int, label: str, is_mmio: bool) -> Tuple[int, int, str, str, str]:
169+
def __process(lbound: int, ubound: int, perms: int, label: str, is_mmio: bool, _data: bytearray = None) -> Tuple[int, int, str, str, str]:
170170
perms_str = __perms_mapping(perms)
171171

172172
if hasattr(self.ql, 'loader'):
@@ -439,10 +439,10 @@ def __mapped_regions(self) -> Iterator[Tuple[int, int]]:
439439

440440
iter_memmap = iter(self.map_info)
441441

442-
p_lbound, p_ubound, _, _, _ = next(iter_memmap)
442+
p_lbound, p_ubound, *_3 = next(iter_memmap)
443443

444444
# map_info is assumed to contain non-overlapping regions sorted by lbound
445-
for lbound, ubound, _, _, _ in iter_memmap:
445+
for lbound, ubound, *_3 in iter_memmap:
446446
if lbound == p_ubound:
447447
p_ubound = ubound
448448
else:
@@ -514,8 +514,8 @@ def find_free_space(self, size: int, minaddr: Optional[int] = None, maxaddr: Opt
514514
assert minaddr < maxaddr
515515

516516
# get gap ranges between mapped ones and memory bounds
517-
gaps_ubounds = tuple(lbound for lbound, _, _, _, _ in self.map_info) + (mem_ubound,)
518-
gaps_lbounds = (mem_lbound,) + tuple(ubound for _, ubound, _, _, _ in self.map_info)
517+
gaps_ubounds = tuple(lbound for lbound, *_4 in self.map_info) + (mem_ubound,)
518+
gaps_lbounds = (mem_lbound,) + tuple(ubound for _, ubound, *_3 in self.map_info)
519519
gaps = zip(gaps_lbounds, gaps_ubounds)
520520

521521
for lbound, ubound in gaps:

0 commit comments

Comments
 (0)