]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
wireshark: fix compilation errors
authorPavel Hrdina <phrdina@redhat.com>
Wed, 20 May 2020 20:52:05 +0000 (22:52 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 10 Jul 2020 14:07:02 +0000 (16:07 +0200)
With meson introduction which is using the same CFLAGS for the whole
project some compilation errors were discovered. The wireshark plugin
library is the only one in tools directory that is not using AM_CFLAGS.

With the AM_CFLAGS we get these errors:

../../tools/wireshark/src/packet-libvirt.c: In function 'dissect_libvirt_fds':
../../tools/wireshark/src/packet-libvirt.c:348:31: error: unused parameter 'tvb' [-Werror=unused-parameter]
  348 | dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
      |                     ~~~~~~~~~~^~~
../../tools/wireshark/src/packet-libvirt.c:348:41: error: unused parameter 'start' [-Werror=unused-parameter]
  348 | dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
      |                                    ~~~~~^~~~~
../../tools/wireshark/src/packet-libvirt.c:348:55: error: unused parameter 'nfds' [-Werror=unused-parameter]
  348 | dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
      |                                                ~~~~~~~^~~~
At top level:
../../tools/wireshark/src/packet-libvirt.c:64:5: error: 'dissect_xdr_bool' defined but not used [-Werror=unused-function]
   64 |     dissect_xdr_##xtype(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf) \
      |     ^~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:88:1: note: in expansion of macro 'XDR_PRIMITIVE_DISSECTOR'
   88 | XDR_PRIMITIVE_DISSECTOR(bool,    bool_t,  boolean)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:64:5: error: 'dissect_xdr_float' defined but not used [-Werror=unused-function]
   64 |     dissect_xdr_##xtype(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf) \
      |     ^~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:86:1: note: in expansion of macro 'XDR_PRIMITIVE_DISSECTOR'
   86 | XDR_PRIMITIVE_DISSECTOR(float,   gfloat,  float)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:64:5: error: 'dissect_xdr_short' defined but not used [-Werror=unused-function]
   64 |     dissect_xdr_##xtype(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf) \
      |     ^~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:80:1: note: in expansion of macro 'XDR_PRIMITIVE_DISSECTOR'
   80 | XDR_PRIMITIVE_DISSECTOR(short,   gint16,  int)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c: In function 'dissect_libvirt_message':
../../tools/wireshark/src/packet-libvirt.c:423:34: error: null pointer dereference [-Werror=null-dereference]
  423 |         vir_xdr_dissector_t xd = find_payload_dissector(proc, type, get_program_data(prog, VIR_PROGRAM_DISSECTORS),
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  424 |                                                         *(gsize *)get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN));
      |                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/internal.h
tools/Makefile.am
tools/wireshark/src/packet-libvirt.c

index c054e3ce96f06989072fe0c65fd3e4999efde7f9..3bab6b4bfe072e3a75a84b4f351c145f9a790c65 100644 (file)
     _Pragma ("GCC diagnostic push")
 #endif
 
+#define VIR_WARNINGS_NO_UNUSED_FUNCTION \
+    _Pragma ("GCC diagnostic push") \
+    _Pragma ("GCC diagnostic ignored \"-Wunused-function\"")
+
 /* Workaround bogus GCC 6.0 for logical 'or' equal expression warnings.
  * (GCC bz 69602) */
 #if BROKEN_GCC_WLOGICALOP_EQUAL_EXPR
index 53df930e0ac3ec8d0e2372982873ccb98c743ff8..eb8f269b4864e6239ec13f529d55ae8c1d448193 100644 (file)
@@ -378,7 +378,7 @@ if WITH_WIRESHARK_DISSECTOR
 
 ws_plugin_LTLIBRARIES = wireshark/src/libvirt.la
 wireshark_src_libvirt_la_CFLAGS = \
-       -I wireshark/src $(WIRESHARK_DISSECTOR_CFLAGS) $(XDR_CFLAGS)
+       -I wireshark/src $(WIRESHARK_DISSECTOR_CFLAGS) $(XDR_CFLAGS) $(AM_CFLAGS)
 wireshark_src_libvirt_la_LDFLAGS = -avoid-version -module
 wireshark_src_libvirt_la_SOURCES = \
        wireshark/src/packet-libvirt.h \
index 20b7a3ec81221c605fa50c857ddbcb5bb190a6d1..2b499d2cf29307de09a9c13d2163aff518cf71ad 100644 (file)
@@ -75,6 +75,8 @@ static gint ett_libvirt_stream_hole = -1;
         } \
     }
 
+VIR_WARNINGS_NO_UNUSED_FUNCTION
+
 XDR_PRIMITIVE_DISSECTOR(int,     gint32,  int)
 XDR_PRIMITIVE_DISSECTOR(u_int,   guint32, uint)
 XDR_PRIMITIVE_DISSECTOR(short,   gint16,  int)
@@ -87,6 +89,8 @@ XDR_PRIMITIVE_DISSECTOR(float,   gfloat,  float)
 XDR_PRIMITIVE_DISSECTOR(double,  gdouble, double)
 XDR_PRIMITIVE_DISSECTOR(bool,    bool_t,  boolean)
 
+VIR_WARNINGS_RESET
+
 typedef gboolean (*vir_xdr_dissector_t)(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
 
 typedef struct vir_dissector_index vir_dissector_index_t;
@@ -345,7 +349,9 @@ dissect_libvirt_num_of_fds(tvbuff_t *tvb, proto_tree *tree)
 }
 
 static void
-dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
+dissect_libvirt_fds(tvbuff_t *tvb G_GNUC_UNUSED,
+                    gint start G_GNUC_UNUSED,
+                    gint32 nfds G_GNUC_UNUSED)
 {
     /* TODO: NOP for now */
 }
@@ -420,8 +426,13 @@ dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
         return; /* No payload */
 
     if (status == VIR_NET_OK) {
-        vir_xdr_dissector_t xd = find_payload_dissector(proc, type, get_program_data(prog, VIR_PROGRAM_DISSECTORS),
-                                                        *(gsize *)get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN));
+        const vir_dissector_index_t *pds = get_program_data(prog, VIR_PROGRAM_DISSECTORS);
+        const gsize *len = get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN);
+
+        if (!len)
+            goto unknown;
+
+        vir_xdr_dissector_t xd = find_payload_dissector(proc, type, pds, *len);
         if (xd == NULL)
             goto unknown;
         dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, xd);