[virt-tools-list] [PATCH 2/2] Fix compiler warnings ifndef HAVE_OVIRT (remote-viewer.c)

Uri Lublin uril at redhat.com
Tue Mar 7 10:18:50 UTC 2017


Currently the compilers complains when HAVE_OVIRT is not defined:
src/remote-viewer.c: In function 'remote_viewer_get_property':
src/remote-viewer.c:227:26: warning: unused variable 'priv' [-Wunused-variable]
     RemoteViewerPrivate *priv = self->priv;
                          ^~~~
src/remote-viewer.c:224:36: warning: unused parameter 'value' [-Wunused-parameter]
                            GValue *value, GParamSpec *pspec)
                                    ^~~~~

This patch does two things in remote_viewer_get_property() to make
the compiler happy:
1. 'self' and 'priv' are moved inside the case block.
2. 'value' is "touched"

Signed-off-by: Uri Lublin <uril at redhat.com>
---

If desired:
 - I can split this patch to two patches (separating 1, 2 above)
 - Instead of touching value I can add G_GNUC_UNUSED
   after GValue *value (within an ifndef HAVE_OVIRT)

---
 src/remote-viewer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8c31532..bdac735 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -223,17 +223,18 @@ static void
 remote_viewer_get_property(GObject *object, guint property_id,
                            GValue *value, GParamSpec *pspec)
 {
-    RemoteViewer *self = REMOTE_VIEWER(object);
-    RemoteViewerPrivate *priv = self->priv;
-
     switch (property_id) {
 #ifdef HAVE_OVIRT
-    case PROP_OVIRT_FOREIGN_MENU:
+    case PROP_OVIRT_FOREIGN_MENU: {
+        RemoteViewer *self = REMOTE_VIEWER(object);
+        RemoteViewerPrivate *priv = self->priv;
         g_value_set_object(value, priv->ovirt_foreign_menu);
         break;
+    }
 #endif
 
     default:
+        (void)value; /* build with no warnings ifndef HAVE_OVIRT */
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
 }
-- 
2.9.3




More information about the virt-tools-list mailing list