On Tue, Feb 11, 2020 at 11:25:49AM -0600, Eric Blake wrote:
On 2/11/20 11:15 AM, Richard W.M. Jones wrote:
>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 ())
Do we want any checking, such as whether this is non-NULL?
For example, patch 3 has:
-typedef void (*connection_close_function) (struct connection *)
__attribute__((__nonnull__ (1)));
+typedef void (*connection_close_function) (void);
which loses the compile-time checking that we have a non-NULL
connection parameter; so replacing a parameter passed through a
nonnull attribute with a macro that guarantees a nonnull result
might be in our favor, where we can leave explicit calls to
threadlocal_get_conn() rather than macro usage for the few callers
that expect to handle the corner cases where a threadlocal
connection might not yet be set.
Yes let's do this.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html