|SUCCESS| dts: ConfigurationError not thrown due to lack of next default value
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Apr 15 05:58:44 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/163037
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-15
Commit: 20260414152116.277497-1-rileyf at linux.ibm.com
Author: Riley Fletcher <rileyf at linux.ibm.com>
Subject: [PATCH] dts: ConfigurationError not thrown due to lack of next default value
This patch fixes a bug where a StopIteration exception is raised instead
of a ConfigurationError when an invalid PCI address is provided to the
get_port_info() method.
> diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
> index ee943462c2..3de92b549e 100644
> --- a/dts/framework/testbed_model/linux_session.py
> +++ b/dts/framework/testbed_model/linux_session.py
> @@ -168,7 +168,7 @@ def get_port_info(self, pci_address: str) -> PortInfo:
> ConfigurationError: If the port could not be found.
> """
> bus_info = f"pci@{pci_address}"
> - port = next(port for port in self._lshw_net_info if port.get("businfo") == bus_info)
> + port = next((port for port in self._lshw_net_info if port.get("businfo") == bus_info), None)
Good catch on the StopIteration issue. The fix correctly adds a default
value of None to next(), which allows the subsequent None check to work
as intended.
However, can this logic be simplified? The current approach creates a
generator expression just to get the first matching element. Would using
a simple for loop with early return be more readable and efficient?
Something like:
for port in self._lshw_net_info:
if port.get("businfo") == bus_info:
break
else:
raise ConfigurationError(...)
This avoids creating the generator expression wrapper and makes the
intent clearer.
> if port is None:
> raise ConfigurationError(f"Port {pci_address} could not be found on the node.")
More information about the test-report
mailing list