[Spice-devel] [PATCH] Add SPICE_ATTR_NORETURN on prototype of error functions

Christophe de Dinechin christophe at dinechin.org
Tue Jun 26 09:04:41 UTC 2018


From: Christophe de Dinechin <dinechin at redhat.com>

The error functions are supposed to not return.  Using the attribute
documents that in the interface, and is better for the compiler
because most noreturn-related optimizations and spurious warning
eliminations happen at the call site.

Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
---
 common/lz.h   | 1 +
 common/quic.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/common/lz.h b/common/lz.h
index 21ba1fa..23910b8 100644
--- a/common/lz.h
+++ b/common/lz.h
@@ -19,6 +19,7 @@ typedef void *LzContext;
 
 typedef struct LzUsrContext LzUsrContext;
 struct LzUsrContext {
+    SPICE_ATTR_NORETURN
     SPICE_ATTR_PRINTF(2, 3) void (*error)(LzUsrContext *usr, const char *fmt, ...);
     SPICE_ATTR_PRINTF(2, 3) void (*warn)(LzUsrContext *usr, const char *fmt, ...);
     SPICE_ATTR_PRINTF(2, 3) void (*info)(LzUsrContext *usr, const char *fmt, ...);
diff --git a/common/quic.h b/common/quic.h
index 7c1da85..398fb09 100644
--- a/common/quic.h
+++ b/common/quic.h
@@ -41,6 +41,7 @@ typedef void *QuicContext;
 
 typedef struct QuicUsrContext QuicUsrContext;
 struct QuicUsrContext {
+    SPICE_ATTR_NORETURN
     SPICE_ATTR_PRINTF(2, 3) void (*error)(QuicUsrContext *usr, const char *fmt, ...);
     SPICE_ATTR_PRINTF(2, 3) void (*warn)(QuicUsrContext *usr, const char *fmt, ...);
     SPICE_ATTR_PRINTF(2, 3) void (*info)(QuicUsrContext *usr, const char *fmt, ...);
-- 
2.13.5 (Apple Git-94)



More information about the Spice-devel mailing list