On Wed, Apr 30, 2025 at 11:10:28AM +0200, Michal Luczaj wrote:
Flatten the function. Remove the nested block by inverting the condition: return early on !timeout.
IIUC we are removing this function in the next commit, so we can skip this patch IMO. I suggested this change, if we didn't move the code in the core.
Thanks, Stefano
No functional change intended. Suggested-by: Stefano Garzarella <sgarz...@redhat.com> Signed-off-by: Michal Luczaj <m...@rbox.co> --- net/vmw_vsock/virtio_transport_common.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 49c6617b467195ba385cc3db86caa4321b422d7a..4425802c5d718f65aaea425ea35886ad64e2fe6e 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1194,23 +1194,23 @@ static void virtio_transport_remove_sock(struct vsock_sock *vsk) static void virtio_transport_wait_close(struct sock *sk, long timeout) { - if (timeout) { - DEFINE_WAIT_FUNC(wait, woken_wake_function); - ssize_t (*unsent)(struct vsock_sock *vsk); - struct vsock_sock *vsk = vsock_sk(sk); + DEFINE_WAIT_FUNC(wait, woken_wake_function); + ssize_t (*unsent)(struct vsock_sock *vsk); + struct vsock_sock *vsk = vsock_sk(sk); - unsent = vsk->transport->unsent_bytes; + if (!timeout) + return; - add_wait_queue(sk_sleep(sk), &wait); + unsent = vsk->transport->unsent_bytes; - do { - if (sk_wait_event(sk, &timeout, unsent(vsk) == 0, - &wait)) - break; - } while (!signal_pending(current) && timeout); + add_wait_queue(sk_sleep(sk), &wait); - remove_wait_queue(sk_sleep(sk), &wait); - } + do { + if (sk_wait_event(sk, &timeout, unsent(vsk) == 0, &wait)) + break; + } while (!signal_pending(current) && timeout); + + remove_wait_queue(sk_sleep(sk), &wait); } static void virtio_transport_cancel_close_work(struct vsock_sock *vsk, -- 2.49.0