about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-02-02 20:25:04 +0100
committerAjax <commial@gmail.com>2016-02-04 23:20:21 +0100
commit38fb7d07fc90e17a95c96b80fe9e0825a09ea498 (patch)
tree8dd1c5b000fbfcfc86e9b7095519ee2c2baab9ff
parent147a217b64b3610cdd822b0f23ad2af8106960fd (diff)
downloadmiasm-38fb7d07fc90e17a95c96b80fe9e0825a09ea498.tar.gz
miasm-38fb7d07fc90e17a95c96b80fe9e0825a09ea498.zip
Remove unused variables
-rw-r--r--miasm2/analysis/binary.py5
-rw-r--r--miasm2/analysis/sandbox.py4
-rw-r--r--miasm2/core/asmbloc.py4
-rw-r--r--miasm2/core/cpu.py28
-rw-r--r--miasm2/core/graph.py3
-rw-r--r--miasm2/core/parse_asm.py1
-rw-r--r--miasm2/core/types.py2
-rw-r--r--miasm2/ir/ir.py1
-rw-r--r--miasm2/ir/ir2C.py4
-rw-r--r--miasm2/jitter/loader/pe.py1
-rw-r--r--miasm2/os_dep/win_api_x86_32.py6
11 files changed, 16 insertions, 43 deletions
diff --git a/miasm2/analysis/binary.py b/miasm2/analysis/binary.py
index ffdd7822..900d76ab 100644
--- a/miasm2/analysis/binary.py
+++ b/miasm2/analysis/binary.py
@@ -123,7 +123,7 @@ class ContainerPE(Container):
     "Container abstraction for PE"
 
     def parse(self, data, vm=None):
-        from miasm2.jitter.loader.pe import vm_load_pe, preload_pe, guess_arch
+        from miasm2.jitter.loader.pe import vm_load_pe, guess_arch
         from elfesteem import pe_init
 
         # Parse signature
@@ -160,8 +160,7 @@ class ContainerELF(Container):
     "Container abstraction for ELF"
 
     def parse(self, data, vm=None):
-        from miasm2.jitter.loader.elf import \
-            vm_load_elf, preload_elf, guess_arch
+        from miasm2.jitter.loader.elf import vm_load_elf, guess_arch
         from elfesteem import elf_init
 
         # Parse signature
diff --git a/miasm2/analysis/sandbox.py b/miasm2/analysis/sandbox.py
index 61de65a7..eef83e85 100644
--- a/miasm2/analysis/sandbox.py
+++ b/miasm2/analysis/sandbox.py
@@ -412,7 +412,7 @@ class Sandbox_Win_x86_64(Sandbox, Arch_x86_64, OS_Win):
         Sandbox.__init__(self, *args, **kwargs)
 
         # reserve stack for local reg
-        for i in xrange(0x4):
+        for _ in xrange(0x4):
             self.jitter.push_uint64_t(0)
 
         # Pre-stack return address
@@ -459,7 +459,7 @@ class Sandbox_Linux_x86_64(Sandbox, Arch_x86_64, OS_Linux):
         Sandbox.__init__(self, *args, **kwargs)
 
         # reserve stack for local reg
-        for i in xrange(0x4):
+        for _ in xrange(0x4):
             self.jitter.push_uint64_t(0)
 
         # Pre-stack return address
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py
index a6584602..6e568740 100644
--- a/miasm2/core/asmbloc.py
+++ b/miasm2/core/asmbloc.py
@@ -1319,8 +1319,8 @@ def assemble_block(mnemo, block, symbol_pool, conservative=False):
             instr.fixDstOffset()
 
         old_l = instr.l
-        cached_candidate, candidates = conservative_asm(
-            mnemo, instr, symbol_pool, conservative)
+        cached_candidate, _ = conservative_asm(mnemo, instr, symbol_pool,
+                                               conservative)
 
         # Restore original arguments
         instr.args = saved_args
diff --git a/miasm2/core/cpu.py b/miasm2/core/cpu.py
index 050648f5..5b9462b4 100644
--- a/miasm2/core/cpu.py
+++ b/miasm2/core/cpu.py
@@ -41,7 +41,6 @@ class bitobj:
     def getbits(self, n):
         if not n:
             return 0
-        o = 0
         if n > len(self.bits) - self.offset:
             raise ValueError('not enought bits %r %r' % (n, len(self.bits)))
         b = self.bits[self.offset:self.offset + n]
@@ -174,7 +173,6 @@ def ast_parse_op(t):
         if t[0] in ['-', '+', '!']:
             return m2_expr.ExprOp(t[0], t[1])
     if len(t) == 3:
-        args = [t[0], t[2]]
         if t[1] == '-':
             # a - b => a + (-b)
             t[1] = '+'
@@ -669,9 +667,7 @@ class reg_noarg(object):
 
 
 class mn_prefix:
-
-    def __init__(self):
-        b = None
+    pass
 
 
 def swap16(v):
@@ -899,7 +895,6 @@ class metamn(type):
             bases[0].all_mn_inst[c].append(i)
             add_candidate(bases, c)
             # gen byte lookup
-            off = 0
             o = ""
             for f in i.fields_order:
                 if not isinstance(f, bsi):
@@ -996,14 +991,8 @@ class cls_mn(object):
         fname_values = pre_dis_info
         todo = [(dict(fname_values), branch, offset * 8)
                 for branch in cls.bintree.items()]
-        cpt = 0
-        if hasattr(bs, 'getlen'):
-            bs_l = bs.getlen()
-        else:
-            bs_l = len(bs)
         for fname_values, branch, offset_b in todo:
             (l, fmask, fbits, fname, flen), vals = branch
-            cpt += 1
 
             if flen is not None:
                 l = flen(attrib, fname_values)
@@ -1127,7 +1116,6 @@ class cls_mn(object):
             if not c.add_pre_dis_info(pre_dis_info):
                 continue
 
-            args = []
             todo = {}
             getok = True
             fname_values = dict(pre_dis_info)
@@ -1257,7 +1245,6 @@ class cls_mn(object):
                         raise NotImplementedError('not fully functional')
                     f.expr = expr_simp(f.expr)
                     args_expr.append(f.expr)
-                    a = args_str[start:stop]
                     args_str = args_str[stop:].strip(' ')
                     if args_str.startswith(','):
                         args_str = args_str[1:]
@@ -1341,7 +1328,7 @@ class cls_mn(object):
     @classmethod
     def filter_asm_candidates(cls, instr, candidates):
         o = []
-        for c, v in candidates:
+        for _, v in candidates:
             o += v
         o.sort(key=len)
         return o
@@ -1351,18 +1338,16 @@ class cls_mn(object):
 
         result = []
         done = []
-        cpt = 0
 
         while todo:
             index, cur_len, to_decode = todo.pop()
             # TEST XXX
-            for i, f in to_decode:
+            for _, f in to_decode:
                 setattr(self, f.fname, f)
             if (index, [x[1].value for x in to_decode]) in done:
                 continue
             done.append((index, [x[1].value for x in to_decode]))
 
-            cpt += 1
             can_encode = True
             for i, f in to_decode[index:]:
                 f.parent.l = cur_len
@@ -1377,9 +1362,7 @@ class cls_mn(object):
                 if ret is True:
                     continue
 
-                gcpt = 0
-                for i in ret:
-                    gcpt += 1
+                for _ in ret:
                     o = []
                     if ((index, cur_len, [xx[1].value for xx in to_decode]) in todo or
                         (index, cur_len, [xx[1].value for xx in to_decode]) in done):
@@ -1400,14 +1383,13 @@ class cls_mn(object):
 
     def encodefields(self, decoded):
         bits = bitobj()
-        for p, f in decoded:
+        for _, f in decoded:
             setattr(self, f.fname, f)
 
             if f.value is None:
                 continue
             bits.putbits(f.value, f.l)
 
-        xx = bits.tostring()
         return bits.tostring()
 
     def decoded2bytes(self, result):
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py
index f544757d..c98bf8a9 100644
--- a/miasm2/core/graph.py
+++ b/miasm2/core/graph.py
@@ -195,8 +195,6 @@ class DiGraph(object):
         """Render dot graph with HTML"""
 
         escape_chars = re.compile('[' + re.escape('{}') + '&|<>' + ']')
-        label_attr = 'colspan="2" align="center" bgcolor="grey"'
-        edge_attr = 'label = "%s" color="%s" style="bold"'
         td_attr = {'align': 'left'}
         nodes_attr = {'shape': 'Mrecord',
                       'fontname': 'Courier New'}
@@ -287,7 +285,6 @@ class DiGraph(object):
             dominators[node] = set(nodes)
 
         dominators[head] = set([head])
-        modified = True
         todo = set(nodes)
 
         while todo:
diff --git a/miasm2/core/parse_asm.py b/miasm2/core/parse_asm.py
index aefa6df9..b324d2cc 100644
--- a/miasm2/core/parse_asm.py
+++ b/miasm2/core/parse_asm.py
@@ -234,7 +234,6 @@ def parse_txt(mnemo, attrib, txt, symbol_pool=None):
     i = 0
     blocks = asmbloc.AsmCFG()
     block_to_nlink = None
-    block_may_link = False
     delayslot = 0
     while i < len(lines):
         if delayslot:
diff --git a/miasm2/core/types.py b/miasm2/core/types.py
index 7a4dcae1..2108d446 100644
--- a/miasm2/core/types.py
+++ b/miasm2/core/types.py
@@ -1444,7 +1444,7 @@ class MemStruct(MemType):
     @classmethod
     def _gen_attributes(cls):
         # Generate self.<name> getter and setters
-        for name, field, _ in cls._type.all_fields:
+        for name, _, _ in cls._type.all_fields:
             setattr(cls, name, property(
                 lambda self, name=name: self.get_field(name),
                 lambda self, val, name=name: self.set_field(name, val)
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py
index 14acb907..fa34cd01 100644
--- a/miasm2/ir/ir.py
+++ b/miasm2/ir/ir.py
@@ -52,7 +52,6 @@ class irbloc(object):
                     if dst is not None:
                         raise ValueError('Multiple destinations!')
                     dst = i.src
-                    dst_linenb = linenb
         self._dst = dst
         self._dst_linenb = linenb
         return dst
diff --git a/miasm2/ir/ir2C.py b/miasm2/ir/ir2C.py
index 0161c391..31af2980 100644
--- a/miasm2/ir/ir2C.py
+++ b/miasm2/ir/ir2C.py
@@ -414,13 +414,12 @@ def irblocs2C(ir_arch, resolvers, label, irblocs,
         if l.name.startswith('lbl_gen_'):
             l.index = int(l.name[8:], 16)
             lbls_local.append(l)
-    lbl_index_min, lbl_index_max = 0, 0
+    lbl_index_min = 0
     lbls_index = [l.index for l in lbls if hasattr(l, 'index')]
     lbls_local.sort(key=lambda x:x.index)
 
     if lbls_index:
         lbl_index_min = min(lbls_index)
-        lbl_index_max = max(lbls_index)
         for l in lbls_local:
             l.index -= lbl_index_min
 
@@ -442,7 +441,6 @@ def irblocs2C(ir_arch, resolvers, label, irblocs,
         for exprs in b_out:
             for l in exprs:
                 out.append(l)
-        dst = irbloc.dst
         out.append("")
 
     return out
diff --git a/miasm2/jitter/loader/pe.py b/miasm2/jitter/loader/pe.py
index 89876a92..1d33f9b8 100644
--- a/miasm2/jitter/loader/pe.py
+++ b/miasm2/jitter/loader/pe.py
@@ -468,7 +468,6 @@ def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib,
     """
 
     todo = [(fname, fname, 0)]
-    dependencies = []
     weight2name = {}
     done = set()
 
diff --git a/miasm2/os_dep/win_api_x86_32.py b/miasm2/os_dep/win_api_x86_32.py
index 9333c238..ef2cfc38 100644
--- a/miasm2/os_dep/win_api_x86_32.py
+++ b/miasm2/os_dep/win_api_x86_32.py
@@ -512,9 +512,9 @@ def advapi32_CryptDestroyHash(jitter):
 
 
 def advapi32_CryptDecrypt(jitter):
-    ret_ad, _ = jitter.func_args_stdcall(["hkey", "hhash", "final",
-                                          "dwflags", "pbdata",
-                                          "pdwdatalen"])
+    # ret_ad, _ = jitter.func_args_stdcall(["hkey", "hhash", "final",
+    #                                       "dwflags", "pbdata",
+    #                                       "pdwdatalen"])
     raise ValueError("Not implemented")
     # jitter.func_ret_stdcall(ret_ad, 1)