Since we're going to be calling this function a lot, add a short alias for it. --- server/internal.h | 1 + server/public.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/internal.h b/server/internal.h index a1fa7309..1e7b4cf0 100644 --- a/server/internal.h +++ b/server/internal.h @@ -493,6 +493,7 @@ extern int threadlocal_get_error (void); extern void *threadlocal_buffer (size_t size); extern void threadlocal_set_conn (struct connection *conn); extern struct connection *threadlocal_get_conn (void); +#define GET_CONN (threadlocal_get_conn ()) /* Declare program_name. */ #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1 diff --git a/server/public.c b/server/public.c index 418945fe..8fa7e21b 100644 --- a/server/public.c +++ b/server/public.c @@ -533,7 +533,7 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec) * NBD_CMD_DISC or a problem with the connection * - the input socket detects POLLRDHUP/POLLHUP/POLLERR */ - struct connection *conn = threadlocal_get_conn (); + struct connection *conn = GET_CONN; struct pollfd fds[] = { [0].fd = quit_fd, [0].events = POLLIN, @@ -595,7 +595,7 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec) const char * nbdkit_export_name (void) { - struct connection *conn = threadlocal_get_conn (); + struct connection *conn = GET_CONN; if (!conn) { nbdkit_error ("no connection in this thread"); @@ -608,7 +608,7 @@ nbdkit_export_name (void) int nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen) { - struct connection *conn = threadlocal_get_conn (); + struct connection *conn = GET_CONN; int s; if (!conn) { -- 2.25.0