flatten and simplify some code

This commit is contained in:
Jan Petykiewicz 2024-08-01 00:22:59 -07:00
parent 5f2b1a432e
commit 5a82f04f9e
2 changed files with 5 additions and 8 deletions

View File

@ -96,7 +96,7 @@ def ctypes_equal(
if isinstance(a, (ctypes.Array, ctypes.Structure, ctypes.Union, ctypes._SimpleCData)):
if not ctypes_equal(a_attr, b_attr):
return False
elif not a_attr == b_attr:
elif a_attr != b_attr:
return False
return True

View File

@ -192,10 +192,9 @@ class Process(AbstractProcess):
max_path_len,
)
if rval > 0:
return name_buffer.value.decode()
else:
if rval <= 0:
return None
return name_buffer.value.decode()
@staticmethod
def list_available_pids() -> list[int]:
@ -218,11 +217,9 @@ class Process(AbstractProcess):
num_returned = floor(returned_size.value / ctypes.sizeof(ctypes.wintypes.DWORD))
if nn == num_returned:
nn *= 2
continue
else:
if nn != num_returned:
break
nn *= 2
return pids[:num_returned]