From 5d711b60bff9d9d7db424658864386d5257dcb11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= <remy.leone@gmail.com>
Date: Thu, 12 May 2016 14:44:50 +0200
Subject: [PATCH] Chained comparisons can be simplified

---
 scapy/arch/windows/__init__.py | 2 +-
 scapy/contrib/eigrp.py         | 2 +-
 scapy/layers/dns.py            | 4 ++--
 scapy/layers/dot11.py          | 2 +-
 scapy/sendrecv.py              | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/scapy/arch/windows/__init__.py b/scapy/arch/windows/__init__.py
index 44f3569b..0d1f34ba 100755
--- a/scapy/arch/windows/__init__.py
+++ b/scapy/arch/windows/__init__.py
@@ -650,7 +650,7 @@ L2socket: use the provided L2socket
                 r = prn(p)
                 if r is not None:
                     print r
-            if count > 0 and c >= count:
+            if 0 < count <= c:
                 break
         except KeyboardInterrupt:
             break
diff --git a/scapy/contrib/eigrp.py b/scapy/contrib/eigrp.py
index 94be6571..fed3e213 100644
--- a/scapy/contrib/eigrp.py
+++ b/scapy/contrib/eigrp.py
@@ -267,7 +267,7 @@ class ShortVersionField(ShortField):
 
             return (major << 8) | minor
 
-        elif type(x) is int and x >= 0 and x <= 65535:
+        elif type(x) is int and 0 <= x <= 65535:
             return x
         else:
             if self.default != None:
diff --git a/scapy/layers/dns.py b/scapy/layers/dns.py
index 3396a664..5315e07b 100644
--- a/scapy/layers/dns.py
+++ b/scapy/layers/dns.py
@@ -415,7 +415,7 @@ def RRlist2bitmap(lst):
     for wb in xrange(min_window_blocks, max_window_blocks+1):
         # First, filter out RR not encoded in the current window block
         # i.e. keep everything between 256*wb <= 256*(wb+1)
-        rrlist = filter(lambda x: 256*wb <= x and x < 256*(wb+1), lst)
+        rrlist = filter(lambda x: 256 * wb <= x < 256 * (wb + 1), lst)
         rrlist.sort()
         if rrlist == []:
             continue
@@ -436,7 +436,7 @@ def RRlist2bitmap(lst):
         for tmp in xrange(bytes):
             v = 0
             # Remove out of range Ressource Records
-            tmp_rrlist = filter(lambda x: 256*wb+8*tmp <= x and x < 256*wb+8*tmp+8, rrlist)
+            tmp_rrlist = filter(lambda x: 256 * wb + 8 * tmp <= x < 256 * wb + 8 * tmp + 8, rrlist)
             if not tmp_rrlist == []:
                 # 1. rescale to fit into 8 bits
                 tmp_rrlist = map(lambda x: (x-256*wb)-(tmp*8), tmp_rrlist)
diff --git a/scapy/layers/dot11.py b/scapy/layers/dot11.py
index b340dd85..df91e104 100644
--- a/scapy/layers/dot11.py
+++ b/scapy/layers/dot11.py
@@ -167,7 +167,7 @@ class Dot11(Packet):
     def mysummary(self):
         return self.sprintf("802.11 %Dot11.type% %Dot11.subtype% %Dot11.addr2% > %Dot11.addr1%")
     def guess_payload_class(self, payload):
-        if self.type == 0x02 and (self.subtype >= 0x08 and self.subtype <=0xF and self.subtype != 0xD):
+        if self.type == 0x02 and (0x08 <= self.subtype <= 0xF and self.subtype != 0xD):
             return Dot11QoS
 	elif self.FCfield & 0x40:
             return Dot11WEP
diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py
index 1d1d2afb..37a42940 100644
--- a/scapy/sendrecv.py
+++ b/scapy/sendrecv.py
@@ -619,7 +619,7 @@ interfaces)
                     if stop_filter and stop_filter(p):
                         stop_event = True
                         break
-                    if count > 0 and c >= count:
+                    if 0 < count <= c:
                         stop_event = True
                         break
     except KeyboardInterrupt:
@@ -689,7 +689,7 @@ stop_filter: python function applied to each packet to determine
                     if stop_filter and stop_filter(p):
                         stop_event = True
                         break
-                    if count > 0 and c >= count:
+                    if 0 < count <= c:
                         stop_event = True
                         break
     except KeyboardInterrupt:
-- 
GitLab