[Spice-devel] [PATCH spice-server 07/10] red-common: Avoid some not used warning using clang

Frediano Ziglio fziglio at redhat.com
Mon Jan 22 17:54:59 UTC 2018


clang reports lot of warnings like:

spicevmc.c:47:1: error: unused function 'RED_CHAR_DEVICE_SPICEVMC_CLASS' [-Werror,-Wunused-function]
SPICE_DECLARE_TYPE(RedCharDeviceSpiceVmc, red_char_device_spicevmc, CHAR_DEVICE_SPICEVMC);
^
./red-common.h:110:43: note: expanded from macro 'SPICE_DECLARE_TYPE'
    static inline ModuleObjName ## Class *G_PASTE(G_PASTE(RED_,OBJ_NAME),_CLASS)(void *klass) \
                                          ^

They are all static inline function and usually should not generate
warnings but for some reasons they do.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-common.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/server/red-common.h b/server/red-common.h
index 171a1877..617e42d6 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -104,17 +104,20 @@ typedef struct GListIter {
     typedef struct ModuleObjName ## Class ModuleObjName ## Class; \
     typedef struct ModuleObjName ## Private ModuleObjName ## Private; \
     GType module_obj_name ## _get_type(void) G_GNUC_CONST; \
-    static inline ModuleObjName *G_PASTE(RED_,OBJ_NAME)(void *obj) \
+    static inline SPICE_GNUC_UNUSED ModuleObjName *G_PASTE(RED_,OBJ_NAME)(void *obj) \
     { return G_TYPE_CHECK_INSTANCE_CAST(obj, \
              module_obj_name ## _get_type(), ModuleObjName); } \
-    static inline ModuleObjName ## Class *G_PASTE(G_PASTE(RED_,OBJ_NAME),_CLASS)(void *klass) \
+    static inline SPICE_GNUC_UNUSED \
+    ModuleObjName ## Class *G_PASTE(G_PASTE(RED_,OBJ_NAME),_CLASS)(void *klass) \
     { return G_TYPE_CHECK_CLASS_CAST(klass, \
              module_obj_name ## _get_type(), ModuleObjName ## Class); } \
-    static inline gboolean G_PASTE(RED_IS_,OBJ_NAME)(void *obj) \
+    static inline SPICE_GNUC_UNUSED gboolean G_PASTE(RED_IS_,OBJ_NAME)(void *obj) \
     { return G_TYPE_CHECK_INSTANCE_TYPE(obj, module_obj_name ## _get_type()); } \
-    static inline gboolean G_PASTE(G_PASTE(RED_IS_,OBJ_NAME),_CLASS)(void *klass) \
+    static inline SPICE_GNUC_UNUSED \
+    gboolean G_PASTE(G_PASTE(RED_IS_,OBJ_NAME),_CLASS)(void *klass) \
     { return G_TYPE_CHECK_CLASS_TYPE((klass), module_obj_name ## _get_type()); } \
-    static inline ModuleObjName ## Class *G_PASTE(G_PASTE(RED_,OBJ_NAME),_GET_CLASS)(void *obj) \
+    static inline SPICE_GNUC_UNUSED \
+    ModuleObjName ## Class *G_PASTE(G_PASTE(RED_,OBJ_NAME),_GET_CLASS)(void *obj) \
     { return G_TYPE_INSTANCE_GET_CLASS(obj, \
              module_obj_name ## _get_type(), ModuleObjName ## Class); }
 
-- 
2.14.3



More information about the Spice-devel mailing list