Skip to content

Commit a52bd23

Browse files
committed
set getRawParam and setRawParam default argbits to 0
1 parent 3d0b0ae commit a52bd23

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

qiling/cc/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def getNumSlots(argbits: int) -> int:
2626

2727
raise NotImplementedError
2828

29-
def getRawParam(self, slot: int, argbits: int = None) -> int:
29+
def getRawParam(self, slot: int, argbits: int = 0) -> int:
3030
"""Read a value of native size from the specified argument slot.
3131
3232
Note that argument slots and argument indexes are not the same. Though they often correlate
@@ -41,7 +41,7 @@ def getRawParam(self, slot: int, argbits: int = None) -> int:
4141

4242
raise NotImplementedError
4343

44-
def setRawParam(self, slot: int, value: int, argbits: int = None) -> None:
44+
def setRawParam(self, slot: int, value: int, argbits: int = 0) -> None:
4545
"""Replace the value in the specified argument slot.
4646
4747
Note that argument slots and argument indexes are not the same. Though they often correlate
@@ -148,17 +148,17 @@ def __access_param(self, index: int, stack_access: Callable, reg_access: Callabl
148148
else:
149149
return reg_access, reg
150150

151-
def getRawParam(self, index: int, argbits: int = None) -> int:
151+
def getRawParam(self, index: int, argbits: int = 0) -> int:
152152
read, loc = self.__access_param(index, self.arch.stack_read, self.arch.regs.read)
153153

154-
mask = (0 if argbits is None else (1 << argbits)) - 1
154+
mask = (argbits and (1 << argbits)) - 1
155155

156156
return read(loc) & mask
157157

158-
def setRawParam(self, index: int, value: int, argbits: int = None) -> None:
158+
def setRawParam(self, index: int, value: int, argbits: int = 0) -> None:
159159
write, loc = self.__access_param(index, self.arch.stack_write, self.arch.regs.write)
160160

161-
mask = (0 if argbits is None else (1 << argbits)) - 1
161+
mask = (argbits and (1 << argbits)) - 1
162162

163163
write(loc, value & mask)
164164

qiling/cc/intel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class QlIntel32(QlIntelBaseCC):
4242
def getNumSlots(argbits: int) -> int:
4343
return max(argbits, 32) // 32
4444

45-
def getRawParam(self, slot: int, nbits: int = None) -> int:
45+
def getRawParam(self, slot: int, nbits: int = 0) -> int:
4646
__super_getparam = super().getRawParam
4747

4848
if nbits == 64:

qiling/os/fcall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def __init__(self, ql: Qiling, cc: QlCC, accessors: Mapping[int, Accessor] = {})
3232
self.cc = cc
3333

3434
def __make_accessor(nbits: int) -> Accessor:
35-
reader = lambda si: cc.getRawParam(si, nbits or None)
36-
writer = lambda si, val: cc.setRawParam(si, val, nbits or None)
35+
reader = lambda si: cc.getRawParam(si, nbits)
36+
writer = lambda si, val: cc.setRawParam(si, val, nbits)
3737
nslots = cc.getNumSlots(nbits)
3838

3939
return (reader, writer, nslots)

0 commit comments

Comments
 (0)