From f1d0c5aba023725f70a391917437a2ad94c8eea1 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 20 Nov 2019 13:27:01 -0700 Subject: [PATCH] sock: Simply spdk_sock_close When this was originally implemented, it only accessed *sock once or twice. As more stuff is added, it becomes worthwhile to dereference the first level of **sock. Change-Id: Ie31bb0210008f6341b071ba472aaedf897fa459a Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475310 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/sock/sock.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/sock/sock.c b/lib/sock/sock.c index dfb7229bb2..1324a0ebf0 100644 --- a/lib/sock/sock.c +++ b/lib/sock/sock.c @@ -216,24 +216,25 @@ spdk_sock_accept(struct spdk_sock *sock) } int -spdk_sock_close(struct spdk_sock **sock) +spdk_sock_close(struct spdk_sock **_sock) { + struct spdk_sock *sock = *_sock; int rc; - if (*sock == NULL) { + if (sock == NULL) { errno = EBADF; return -1; } - if ((*sock)->cb_fn != NULL) { + if (sock->cb_fn != NULL) { /* This sock is still part of a sock_group. */ errno = EBUSY; return -1; } - rc = (*sock)->net_impl->close(*sock); + rc = sock->net_impl->close(sock); if (rc == 0) { - *sock = NULL; + *_sock = NULL; } return rc;