Skip to content

Commit 575d78c

Browse files
mmhalNipaLocal
authored and
NipaLocal
committed
vsock: Reduce indentation in virtio_transport_wait_close()
Flatten the function. Remove the nested block by inverting the condition: return early on !timeout. No functional change intended. Suggested-by: Stefano Garzarella <[email protected]> Signed-off-by: Michal Luczaj <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 4d69873 commit 575d78c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

net/vmw_vsock/virtio_transport_common.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,28 +1194,28 @@ static void virtio_transport_remove_sock(struct vsock_sock *vsk)
11941194

11951195
static void virtio_transport_wait_close(struct sock *sk, long timeout)
11961196
{
1197-
if (timeout) {
1198-
DEFINE_WAIT_FUNC(wait, woken_wake_function);
1199-
ssize_t (*unsent)(struct vsock_sock *vsk);
1200-
struct vsock_sock *vsk = vsock_sk(sk);
1197+
DEFINE_WAIT_FUNC(wait, woken_wake_function);
1198+
ssize_t (*unsent)(struct vsock_sock *vsk);
1199+
struct vsock_sock *vsk = vsock_sk(sk);
12011200

1202-
/* Some transports (Hyper-V, VMCI) do not implement
1203-
* unsent_bytes. For those, no lingering on close().
1204-
*/
1205-
unsent = vsk->transport->unsent_bytes;
1206-
if (!unsent)
1207-
return;
1201+
if (!timeout)
1202+
return;
1203+
1204+
/* Some transports (Hyper-V, VMCI) do not implement unsent_bytes.
1205+
* For those, no lingering on close().
1206+
*/
1207+
unsent = vsk->transport->unsent_bytes;
1208+
if (!unsent)
1209+
return;
12081210

1209-
add_wait_queue(sk_sleep(sk), &wait);
1211+
add_wait_queue(sk_sleep(sk), &wait);
12101212

1211-
do {
1212-
if (sk_wait_event(sk, &timeout, unsent(vsk) == 0,
1213-
&wait))
1214-
break;
1215-
} while (!signal_pending(current) && timeout);
1213+
do {
1214+
if (sk_wait_event(sk, &timeout, unsent(vsk) == 0, &wait))
1215+
break;
1216+
} while (!signal_pending(current) && timeout);
12161217

1217-
remove_wait_queue(sk_sleep(sk), &wait);
1218-
}
1218+
remove_wait_queue(sk_sleep(sk), &wait);
12191219
}
12201220

12211221
static void virtio_transport_cancel_close_work(struct vsock_sock *vsk,

0 commit comments

Comments
 (0)