* [PATCH net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py
@ 2025-09-01 10:00 Breno Leitao
2025-09-02 7:26 ` Simon Horman
2025-09-02 23:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2025-09-01 10:00 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Shuah Khan
Cc: netdev, linux-kselftest, linux-kernel, Breno Leitao
This patch improves the utils.py module by removing unused imports
(errno, random), simplifying the fd_read_timeout() function by
eliminating unnecessary else clause, and cleaning up code style in the
defer class constructor.
Additionally, it renames the parameter in rand_port() from 'type' to
'stype' to avoid shadowing the built-in Python name 'type', improving
code clarity and preventing potential issues.
These changes enhance code readability and maintainability without
affecting functionality.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
tools/testing/selftests/net/lib/py/utils.py | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index b188cac49738f..1cdc8e6d6b603 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -1,9 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
-import errno
import json as _json
import os
-import random
import re
import select
import socket
@@ -21,8 +19,7 @@ def fd_read_timeout(fd, timeout):
rlist, _, _ = select.select([fd], [], [], timeout)
if rlist:
return os.read(fd, 1024)
- else:
- raise TimeoutError("Timeout waiting for fd read")
+ raise TimeoutError("Timeout waiting for fd read")
class cmd:
@@ -138,8 +135,6 @@ global_defer_queue = []
class defer:
def __init__(self, func, *args, **kwargs):
- global global_defer_queue
-
if not callable(func):
raise Exception("defer created with un-callable object, did you call the function instead of passing its name?")
@@ -227,11 +222,11 @@ def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
return cmd_obj
-def rand_port(type=socket.SOCK_STREAM):
+def rand_port(stype=socket.SOCK_STREAM):
"""
Get a random unprivileged port.
"""
- with socket.socket(socket.AF_INET6, type) as s:
+ with socket.socket(socket.AF_INET6, stype) as s:
s.bind(("", 0))
return s.getsockname()[1]
---
base-commit: 864ecc4a6dade82d3f70eab43dad0e277aa6fc78
change-id: 20250901-fix-02eb26114040
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py
2025-09-01 10:00 [PATCH net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py Breno Leitao
@ 2025-09-02 7:26 ` Simon Horman
2025-09-02 23:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-09-02 7:26 UTC (permalink / raw)
To: Breno Leitao
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, netdev, linux-kselftest, linux-kernel
On Mon, Sep 01, 2025 at 03:00:07AM -0700, Breno Leitao wrote:
> This patch improves the utils.py module by removing unused imports
> (errno, random), simplifying the fd_read_timeout() function by
> eliminating unnecessary else clause, and cleaning up code style in the
> defer class constructor.
>
> Additionally, it renames the parameter in rand_port() from 'type' to
> 'stype' to avoid shadowing the built-in Python name 'type', improving
> code clarity and preventing potential issues.
>
> These changes enhance code readability and maintainability without
> affecting functionality.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py
2025-09-01 10:00 [PATCH net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py Breno Leitao
2025-09-02 7:26 ` Simon Horman
@ 2025-09-02 23:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-02 23:00 UTC (permalink / raw)
To: Breno Leitao
Cc: davem, edumazet, kuba, pabeni, horms, shuah, netdev,
linux-kselftest, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 01 Sep 2025 03:00:07 -0700 you wrote:
> This patch improves the utils.py module by removing unused imports
> (errno, random), simplifying the fd_read_timeout() function by
> eliminating unnecessary else clause, and cleaning up code style in the
> defer class constructor.
>
> Additionally, it renames the parameter in rand_port() from 'type' to
> 'stype' to avoid shadowing the built-in Python name 'type', improving
> code clarity and preventing potential issues.
>
> [...]
Here is the summary with links:
- [net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py
https://git.kernel.org/netdev/net-next/c/23313771c7b9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-02 23:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 10:00 [PATCH net-next] net: selftests: clean up tools/testing/selftests/net/lib/py/utils.py Breno Leitao
2025-09-02 7:26 ` Simon Horman
2025-09-02 23:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).