summary refs log tree commit diff stats
path: root/scripts/tracetool/format/d.py
diff options
context:
space:
mode:
authorJuraj Marcin <jmarcin@redhat.com>2025-05-21 15:52:32 +0200
committerDaniel P. Berrangé <berrange@redhat.com>2025-05-22 11:24:41 +0100
commit911e0f2c6e2d00c985affa75ec188c8edcf480f2 (patch)
tree00da4e67a23a4c2143a531dabd26d0b255287702 /scripts/tracetool/format/d.py
parentb8b5278aca78be4a1c2e7cbb11c6be176f63706d (diff)
downloadfocaccia-qemu-911e0f2c6e2d00c985affa75ec188c8edcf480f2.tar.gz
focaccia-qemu-911e0f2c6e2d00c985affa75ec188c8edcf480f2.zip
util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr()
To get a listening socket, we need to first create a socket, try binding
it to a certain port, and lastly starting listening to it. Each of these
operations can fail due to various reasons, one of them being that the
requested address/port is already in use. In such case, the function
tries the same process with a new port number.

This patch refactors the port number loop, so the success path is no
longer buried inside the 'if' statements in the middle of the loop. Now,
the success path is not nested and ends at the end of the iteration
after successful socket creation, binding, and listening. In case any of
the operations fails, it either continues to the next iteration (and the
next port) or jumps out of the loop to handle the error and exits the
function.

Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'scripts/tracetool/format/d.py')
0 files changed, 0 insertions, 0 deletions