simplify chained expression

This commit is contained in:
Sebastian Bachmann 2017-06-19 15:11:04 +02:00
parent a303291fbf
commit 1e11b29a6d
5 changed files with 18 additions and 18 deletions

View File

@ -62,7 +62,7 @@ class DVMBasicBlock(object):
tmp_ins = []
idx = 0
for i in self.method.get_instructions():
if idx >= self.start and idx < self.end:
if self.start <= idx < self.end:
tmp_ins.append(i)
idx += i.get_length()
@ -135,7 +135,7 @@ class DVMBasicBlock(object):
op_value = i.get_op_value()
if op_value == 0x26 or (op_value >= 0x2b and op_value <= 0x2c):
if op_value == 0x26 or (0x2b <= op_value <= 0x2c):
code = self.method.get_code().get_bc()
self.special_ins[idx] = code.get_ins_off(idx + i.get_ref_off() * 2)
@ -288,7 +288,7 @@ class BasicBlocks(object):
def get_basic_block(self, idx):
for i in self.bb:
if idx >= i.get_start() and idx < i.get_end():
if i.get_start() <= idx < i.get_end():
return i
return None
@ -824,8 +824,8 @@ class Analysis(object):
self.classes[current_class.get_name()],
current_method, off)
elif ((op_value >= 0x6e and op_value <= 0x72) or
(op_value >= 0x74 and op_value <= 0x78)):
elif ((0x6e <= op_value <= 0x72) or
(0x74 <= op_value <= 0x78)):
idx_meth = instruction.get_ref_kind()
method_info = last_vm.get_cm_method(idx_meth)
if method_info:
@ -867,7 +867,7 @@ class Analysis(object):
self.classes[current_class.get_name()],
current_method, off)
elif op_value >= 0x1a and op_value <= 0x1b:
elif 0x1a <= op_value <= 0x1b:
string_value = last_vm.get_cm_string(
instruction.get_ref_kind())
if string_value not in self.strings:
@ -877,15 +877,15 @@ class Analysis(object):
self.classes[current_class.get_name()],
current_method)
elif op_value >= 0x52 and op_value <= 0x6d:
elif 0x52 <= op_value <= 0x6d:
idx_field = instruction.get_ref_kind()
field_info = last_vm.get_cm_field(idx_field)
field_item = last_vm.get_field_descriptor(
field_info[0], field_info[2], field_info[1])
if field_item:
# read access to a field
if (op_value >= 0x52 and op_value <= 0x58) or (
op_value >= 0x60 and op_value <= 0x66):
if (0x52 <= op_value <= 0x58) or (
0x60 <= op_value <= 0x66):
self.classes[current_class.get_name(
)].AddFXrefRead(
current_method,

View File

@ -1558,10 +1558,10 @@ def format_value(_type, _data, lookup_string=lambda ix: "<string>"):
elif _type == TYPE_FRACTION:
return "%f%s" % (complexToFloat(_data) * 100, FRACTION_UNITS[_data & COMPLEX_UNIT_MASK])
elif _type >= TYPE_FIRST_COLOR_INT and _type <= TYPE_LAST_COLOR_INT:
elif TYPE_FIRST_COLOR_INT <= _type <= TYPE_LAST_COLOR_INT:
return "#%08X" % _data
elif _type >= TYPE_FIRST_INT and _type <= TYPE_LAST_INT:
elif TYPE_FIRST_INT <= _type <= TYPE_LAST_INT:
return "%d" % androconf.long2int(_data)
return "<0x%X, type 0x%02X>" % (_data, _type)

View File

@ -150,7 +150,7 @@ def clean_name_instruction(instruction):
op_value = instruction.get_op_value()
# goto range
if op_value >= 0x28 and op_value <= 0x2a:
if 0x28 <= op_value <= 0x2a:
return "goto"
return instruction.get_name()
@ -1479,7 +1479,7 @@ class EncodedValue(object):
self.value = ""
# TODO: parse floats/doubles correctly
if self.value_type >= VALUE_SHORT and self.value_type < VALUE_STRING:
if VALUE_SHORT <= self.value_type < VALUE_STRING:
self.value, self.raw_value = self._getintvalue(buff.read(
self.value_arg + 1))
elif self.value_type == VALUE_STRING:
@ -6396,7 +6396,7 @@ class Unresolved(Instruction):
def get_instruction(cm, op_value, buff, odex=False):
try:
if not odex and (op_value >= 0xe3 and op_value <= 0xfe):
if not odex and (0xe3 <= op_value <= 0xfe):
return InstructionInvalid(cm, buff)
try:
return DALVIK_OPCODES_FORMAT[op_value][0](cm, buff)

View File

@ -42,7 +42,7 @@ class DataModel(Observer):
return self._lastOffset
def inLimits(self, x):
if x >= 0 and x < len(self.data):
if 0 <= x < len(self.data):
return True
return False
@ -56,7 +56,7 @@ class DataModel(Observer):
self.dataOffset = off
def offsetInPage(self, off):
if off >= self.dataOffset and off <= self.dataOffset + self.rows * self.cols:
if self.dataOffset <= off <= self.dataOffset + self.rows * self.cols:
return True
return False

View File

@ -397,7 +397,7 @@ class DisasmViewMode(ViewMode):
return
screenVA = self._getVA(self.dataModel.getOffset())
if target > screenVA and target < self._getVA(self.dataModel.getOffset()) + tsize - self.OPCODES[-1].size:
if screenVA < target < self._getVA(self.dataModel.getOffset()) + tsize - self.OPCODES[-1].size:
# branch target is in screen
sz = 0
@ -685,7 +685,7 @@ class DisasmViewMode(ViewMode):
tsize = sum([opcode.get_length() for opcode in self.OPCODES])
if offset < self.dataModel.getOffset() + tsize and offset > self.dataModel.getOffset():
if self.dataModel.getOffset() + tsize > offset > self.dataModel.getOffset():
# if in current page, move cursor
row = self._getRowInPage(offset)
off_row = self._getOffsetOfRow(row)