[glib] Silence a bunch of -Wunused-but-set-variable warnings



commit 0729260141bb585943ad1c6efa8ab7ee9058b0aa
Author: David Zeuthen <davidz redhat com>
Date:   Fri Apr 8 15:44:25 2011 -0400

    Silence a bunch of -Wunused-but-set-variable warnings
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 gio/gdbusaddress.c           |   29 +++++++++++++++++++++++++++++
 gio/gdbusauth.c              |    1 +
 gio/gdbusauthmechanismsha1.c |    4 ++++
 gio/gdbusconnection.c        |   17 -----------------
 gio/gdbusmessage.c           |    5 ++---
 gio/gdbusprivate.c           |    1 +
 gio/gdbusproxy.c             |    5 +----
 gio/gdbusserver.c            |    5 +----
 gio/gdbusutils.c             |    4 ----
 gio/gicon.c                  |    4 +---
 gio/ginetaddress.c           |    1 +
 gio/glib-compile-schemas.c   |    3 ---
 gio/gresolver.c              |    2 ++
 gio/gsocket.c                |    6 +-----
 gio/gsocketconnection.c      |    1 +
 gio/gsocketcontrolmessage.c  |    1 +
 gio/gunixconnection.c        |    1 +
 gio/gvdb/gvdb-reader.c       |    2 --
 gio/tests/converter-stream.c |    6 ------
 gio/tests/file.c             |    9 +++------
 gio/tests/httpd.c            |    1 +
 gio/tests/live-g-file.c      |    3 +--
 gio/tests/sleepy-stream.c    |    3 ---
 23 files changed, 52 insertions(+), 62 deletions(-)
---
diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c
index 83e7699..1f2645e 100644
--- a/gio/gdbusaddress.c
+++ b/gio/gdbusaddress.c
@@ -258,6 +258,25 @@ is_valid_nonce_tcp (const gchar  *address_entry,
       goto out;
     }
 
+  if (nonce_file == NULL)
+    {
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_INVALID_ARGUMENT,
+                   _("Error in address `%s' - missing noncefile attribute"),
+                   address_entry);
+      goto out;
+    }
+  if (host == NULL)
+    {
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_INVALID_ARGUMENT,
+                   _("Error in address `%s' - missing host attribute"),
+                   address_entry);
+      goto out;
+    }
+
   ret= TRUE;
 
  out:
@@ -332,6 +351,16 @@ is_valid_tcp (const gchar  *address_entry,
       goto out;
     }
 
+  if (host == NULL)
+    {
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_INVALID_ARGUMENT,
+                   _("Error in address `%s' - missing host attribute"),
+                   address_entry);
+      goto out;
+    }
+
   ret= TRUE;
 
  out:
diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
index eb8ebfd..f190469 100644
--- a/gio/gdbusauth.c
+++ b/gio/gdbusauth.c
@@ -997,6 +997,7 @@ _g_dbus_auth_run_server (GDBusAuth              *auth,
     {
       local_error = NULL;
       byte = g_data_input_stream_read_byte (dis, cancellable, &local_error);
+      byte = byte; /* To avoid -Wunused-but-set-variable */
       if (local_error != NULL)
         {
           g_propagate_error (error, local_error);
diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c
index cadcc99..a38a3fe 100644
--- a/gio/gdbusauthmechanismsha1.c
+++ b/gio/gdbusauthmechanismsha1.c
@@ -426,6 +426,7 @@ keyring_lookup_entry (const gchar  *cookie_context,
         }
 
       line_when = g_ascii_strtoll (tokens[1], &endp, 10);
+      line_when = line_when; /* To avoid -Wunused-but-set-variable */
       if (*endp != '\0')
         {
           g_set_error (error,
@@ -560,6 +561,7 @@ keyring_acquire_lock (const gchar  *path,
             goto again;
         }
 #endif
+      num_create_tries = num_create_tries; /* To avoid -Wunused-but-set-variable */
       g_set_error (error,
                    G_IO_ERROR,
                    g_io_error_from_errno (errno),
@@ -747,6 +749,8 @@ keyring_generate_entry (const gchar  *cookie_context,
               g_strfreev (tokens);
               goto out;
             }
+          line_when = line_when; /* To avoid -Wunused-but-set-variable */
+
 
           /* D-Bus spec says:
            *
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index a10bf4d..3bacf81 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -2049,8 +2049,6 @@ on_worker_message_received (GDBusWorker  *worker,
 {
   GDBusConnection *connection;
   FilterCallback *filters;
-  gboolean consumed_by_filter;
-  gboolean altered_by_filter;
   guint num_filters;
   guint n;
   gboolean alive;
@@ -2086,8 +2084,6 @@ on_worker_message_received (GDBusWorker  *worker,
   CONNECTION_UNLOCK (connection);
 
   /* then call the filters in order (without holding the lock) */
-  consumed_by_filter = FALSE;
-  altered_by_filter = FALSE;
   for (n = 0; n < num_filters; n++)
     {
       message = filters[n].func (connection,
@@ -4065,7 +4061,6 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
 {
   PropertyGetAllData *data = _data;
   GVariantBuilder builder;
-  GError *error;
   GDBusMessage *reply;
   guint n;
 
@@ -4082,8 +4077,6 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
       goto out;
     }
 
-  error = NULL;
-
   /* TODO: Right now we never fail this call - we just omit values if
    *       a get_property() call is failing.
    *
@@ -6061,7 +6054,6 @@ distribute_method_call (GDBusConnection *connection,
   const gchar *object_path;
   const gchar *interface_name;
   const gchar *member;
-  const gchar *signature;
   const gchar *path;
   gchar *subtree_path;
   gchar *needle;
@@ -6070,7 +6062,6 @@ distribute_method_call (GDBusConnection *connection,
 
   interface_name = g_dbus_message_get_interface (message);
   member = g_dbus_message_get_member (message);
-  signature = g_dbus_message_get_signature (message);
   path = g_dbus_message_get_path (message);
   subtree_path = g_strdup (path);
   needle = strrchr (subtree_path, '/');
@@ -6101,14 +6092,6 @@ distribute_method_call (GDBusConnection *connection,
       _g_dbus_debug_print_unlock ();
     }
 
-#if 0
-  g_debug ("interface    = `%s'", interface_name);
-  g_debug ("member       = `%s'", member);
-  g_debug ("signature    = `%s'", signature);
-  g_debug ("path         = `%s'", path);
-  g_debug ("subtree_path = `%s'", subtree_path != NULL ? subtree_path : "N/A");
-#endif
-
   object_path = g_dbus_message_get_path (message);
   g_assert (object_path != NULL);
 
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index a7878b0..94a1de3 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -1525,6 +1525,8 @@ parse_value_from_blob (GMemoryInputStream    *mis,
           g_free (s);
         }
     }
+#else
+  is_leaf = is_leaf; /* To avoid -Wunused-but-set-variable */
 #endif /* DEBUG_SERIALIZER */
 
   /* sink the reference */
@@ -2151,12 +2153,9 @@ append_body_to_blob (GVariant             *value,
                      GDataOutputStream    *dos,
                      GError              **error)
 {
-  gboolean ret;
   GVariant *item;
   GVariantIter iter;
 
-  ret = FALSE;
-
   if (!g_variant_is_of_type (value, G_VARIANT_TYPE_TUPLE))
     {
       g_set_error (error,
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 5f8f1f4..9c2c58c 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -1632,6 +1632,7 @@ _g_dbus_initialize (void)
       const gchar *debug;
 
       g_dbus_error_domain = G_DBUS_ERROR;
+      (g_dbus_error_domain); /* To avoid -Wunused-but-set-variable */
 
       debug = g_getenv ("G_DBUS_DEBUG");
       if (debug != NULL)
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 76397b4..67af1fb 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -643,8 +643,7 @@ g_dbus_proxy_get_cached_property (GDBusProxy   *proxy,
   value = g_hash_table_lookup (proxy->priv->properties, property_name);
   if (value == NULL)
     {
-      const GDBusPropertyInfo *info;
-      info = lookup_property_info_or_warn (proxy, property_name);
+      lookup_property_info_or_warn (proxy, property_name);
       /* no difference */
       goto out;
     }
@@ -823,7 +822,6 @@ on_properties_changed (GDBusConnection *connection,
                        gpointer         user_data)
 {
   GDBusProxy *proxy = G_DBUS_PROXY (user_data);
-  GError *error;
   const gchar *interface_name_for_signal;
   GVariant *changed_properties;
   gchar **invalidated_properties;
@@ -832,7 +830,6 @@ on_properties_changed (GDBusConnection *connection,
   GVariant *value;
   guint n;
 
-  error = NULL;
   changed_properties = NULL;
   invalidated_properties = NULL;
 
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index 5bbeaae..9b5b8c3 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -773,21 +773,18 @@ try_tcp (GDBusServer  *server,
   gboolean ret;
   const gchar *host;
   const gchar *port;
-  const gchar *family;
   gint port_num;
-  GSocketAddress *address;
   GResolver *resolver;
   GList *resolved_addresses;
   GList *l;
 
   ret = FALSE;
-  address = NULL;
   resolver = NULL;
   resolved_addresses = NULL;
 
   host = g_hash_table_lookup (key_value_pairs, "host");
   port = g_hash_table_lookup (key_value_pairs, "port");
-  family = g_hash_table_lookup (key_value_pairs, "family");
+  /* family = g_hash_table_lookup (key_value_pairs, "family"); */
   if (g_hash_table_lookup (key_value_pairs, "noncefile") != NULL)
     {
       g_set_error_literal (error,
diff --git a/gio/gdbusutils.c b/gio/gdbusutils.c
index 6ac9dfc..d757f03 100644
--- a/gio/gdbusutils.c
+++ b/gio/gdbusutils.c
@@ -125,7 +125,6 @@ g_dbus_is_name (const gchar *string)
   guint len;
   gboolean ret;
   const gchar *s;
-  const gchar *end;
 
   g_return_val_if_fail (string != NULL, FALSE);
 
@@ -136,7 +135,6 @@ g_dbus_is_name (const gchar *string)
     goto out;
 
   s = string;
-  end = s + len;
   if (*s == ':')
     {
       /* handle unique name */
@@ -248,7 +246,6 @@ g_dbus_is_interface_name (const gchar *string)
   guint len;
   gboolean ret;
   const gchar *s;
-  const gchar *end;
 
   g_return_val_if_fail (string != NULL, FALSE);
 
@@ -259,7 +256,6 @@ g_dbus_is_interface_name (const gchar *string)
     goto out;
 
   s = string;
-  end = s + len;
   if (G_UNLIKELY (*s == '.'))
     {
       /* can't start with a . */
diff --git a/gio/gicon.c b/gio/gicon.c
index c78acd3..e0c1593 100644
--- a/gio/gicon.c
+++ b/gio/gicon.c
@@ -124,7 +124,6 @@ g_icon_equal (GIcon *icon1,
 static gboolean
 g_icon_to_string_tokenized (GIcon *icon, GString *s)
 {
-  char *ret;
   GPtrArray *tokens;
   gint version;
   GIconIface *icon_iface;
@@ -133,8 +132,6 @@ g_icon_to_string_tokenized (GIcon *icon, GString *s)
   g_return_val_if_fail (icon != NULL, FALSE);
   g_return_val_if_fail (G_IS_ICON (icon), FALSE);
 
-  ret = NULL;
-
   icon_iface = G_ICON_GET_IFACE (icon);
   if (icon_iface->to_tokens == NULL)
     return FALSE;
@@ -383,6 +380,7 @@ ensure_builtin_icon_types (void)
   t = g_file_icon_get_type ();
   t = g_emblemed_icon_get_type ();
   t = g_emblem_get_type ();
+  (t); /* To avoid -Wunused-but-set-variable */
 }
 
 /**
diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c
index 0f67e4f..260c775 100644
--- a/gio/ginetaddress.c
+++ b/gio/ginetaddress.c
@@ -414,6 +414,7 @@ g_inet_address_new_from_string (const gchar *string)
 
   /* Make sure _g_networking_init() has been called */
   type = g_inet_address_get_type ();
+  (type); /* To avoid -Wunused-but-set-variable */
 
 #ifdef G_OS_WIN32
   memset (&sa, 0, sizeof (sa));
diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c
index 7a684ad..d2c3f77 100644
--- a/gio/glib-compile-schemas.c
+++ b/gio/glib-compile-schemas.c
@@ -1442,9 +1442,6 @@ static void
 schema_state_end (SchemaState **state_ptr,
                   GError      **error)
 {
-  SchemaState *state;
-
-  state = *state_ptr;
   *state_ptr = NULL;
 }
 
diff --git a/gio/gresolver.c b/gio/gresolver.c
index 657505b..9309846 100644
--- a/gio/gresolver.c
+++ b/gio/gresolver.c
@@ -90,6 +90,7 @@ g_resolver_class_init (GResolverClass *resolver_class)
 
   /* Make sure _g_networking_init() has been called */
   type = g_inet_address_get_type ();
+  (type); /* To avoid -Wunused-but-set-variable */
 
   /* Initialize _g_resolver_addrinfo_hints */
 #ifdef AI_ADDRCONFIG
@@ -858,6 +859,7 @@ _g_resolver_targets_from_res_query (const gchar      *rrname,
       GETSHORT (type, p);
       GETSHORT (qclass, p);
       GETLONG  (ttl, p);
+      ttl = ttl; /* To avoid -Wunused-but-set-variable */
       GETSHORT (rdlength, p);
 
       if (type != T_SRV || qclass != C_IN)
diff --git a/gio/gsocket.c b/gio/gsocket.c
index 01792a7..aa0a39c 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -678,6 +678,7 @@ g_socket_class_init (GSocketClass *klass)
 
   /* Make sure winsock has been initialized */
   type = g_inet_address_get_type ();
+  (type); /* To avoid -Wunused-but-set-variable */
 
 #ifdef SIGPIPE
   /* There is no portable, thread-safe way to avoid having the process
@@ -3328,12 +3329,7 @@ g_socket_receive_message (GSocket                 *socket,
     /* decode control messages */
     {
       GPtrArray *my_messages = NULL;
-      const gchar *scm_pointer;
       struct cmsghdr *cmsg;
-      gsize scm_size;
-
-      scm_pointer = (const gchar *) msg.msg_control;
-      scm_size = msg.msg_controllen;
 
       for (cmsg = CMSG_FIRSTHDR (&msg); cmsg; cmsg = CMSG_NXTHDR (&msg, cmsg))
 	{
diff --git a/gio/gsocketconnection.c b/gio/gsocketconnection.c
index 852805a..ac9ce74 100644
--- a/gio/gsocketconnection.c
+++ b/gio/gsocketconnection.c
@@ -448,6 +448,7 @@ init_builtin_types (void)
   a_type = g_unix_connection_get_type ();
 #endif
   a_type = g_tcp_connection_get_type ();
+  (a_type); /* To avoid -Wunused-but-set-variable */
 }
 
 /**
diff --git a/gio/gsocketcontrolmessage.c b/gio/gsocketcontrolmessage.c
index 322a049..1192669 100644
--- a/gio/gsocketcontrolmessage.c
+++ b/gio/gsocketcontrolmessage.c
@@ -185,6 +185,7 @@ g_socket_control_message_deserialize (int      level,
 #ifndef G_OS_WIN32
   a_type = g_unix_credentials_message_get_type ();
   a_type = g_unix_fd_message_get_type ();
+  (a_type); /* To avoid -Wunused-but-set-variable */
 #endif
 
   message_types = g_type_children (G_TYPE_SOCKET_CONTROL_MESSAGE, &n_message_types);
diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c
index f04a621..4d1cf40 100644
--- a/gio/gunixconnection.c
+++ b/gio/gunixconnection.c
@@ -473,6 +473,7 @@ g_unix_connection_receive_credentials (GUnixConnection      *connection,
 
   /* ensure the type of GUnixCredentialsMessage has been registered with the type system */
   credentials_message_gtype = G_TYPE_UNIX_CREDENTIALS_MESSAGE;
+  (credentials_message_gtype); /* To avoid -Wunused-but-set-variable */
   num_bytes_read = g_socket_receive_message (socket,
                                              NULL, /* GSocketAddress **address */
                                              NULL,
diff --git a/gio/gvdb/gvdb-reader.c b/gio/gvdb/gvdb-reader.c
index f132df7..0d9df37 100644
--- a/gio/gvdb/gvdb-reader.c
+++ b/gio/gvdb/gvdb-reader.c
@@ -87,7 +87,6 @@ gvdb_table_setup_root (GvdbTable                 *file,
 {
   const struct gvdb_hash_header *header;
   guint32 n_bloom_words;
-  guint32 bloom_shift;
   guint32 n_buckets;
   gsize size;
 
@@ -100,7 +99,6 @@ gvdb_table_setup_root (GvdbTable                 *file,
 
   n_bloom_words = guint32_from_le (header->n_bloom_words);
   n_buckets = guint32_from_le (header->n_buckets);
-  bloom_shift = n_bloom_words >> 27;
   n_bloom_words &= (1u << 27) - 1;
 
   if G_UNLIKELY (n_bloom_words * sizeof (guint32_le) > size)
diff --git a/gio/tests/converter-stream.c b/gio/tests/converter-stream.c
index ceafed7..8017015 100644
--- a/gio/tests/converter-stream.c
+++ b/gio/tests/converter-stream.c
@@ -92,14 +92,11 @@ g_expander_converter_convert (GConverter *converter,
 			      gsize      *bytes_written,
 			      GError    **error)
 {
-  GExpanderConverter  *conv;
   const guint8 *in, *in_end;
   guint8 v, *out;
   int i;
   gsize block_size;
 
-  conv = G_EXPANDER_CONVERTER (converter);
-
   in = inbuf;
   out = outbuf;
   in_end = in + inbuf_size;
@@ -211,14 +208,11 @@ g_compressor_converter_convert (GConverter *converter,
 				gsize      *bytes_written,
 				GError    **error)
 {
-  GCompressorConverter  *conv;
   const guint8 *in, *in_end;
   guint8 v, *out;
   int i;
   gsize block_size;
 
-  conv = G_COMPRESSOR_CONVERTER (converter);
-
   in = inbuf;
   out = outbuf;
   in_end = in + inbuf_size;
diff --git a/gio/tests/file.c b/gio/tests/file.c
index a8903ab..c7734a9 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -206,10 +206,9 @@ ipending_cb (GObject      *source,
 {
   CreateDeleteData *data = user_data;
   GError *error;
-  gssize size;
 
   error = NULL;
-  size = g_input_stream_read_finish (data->istream, res, &error);
+  g_input_stream_read_finish (data->istream, res, &error);
   g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PENDING);
   g_error_free (error);
 }
@@ -334,10 +333,9 @@ opending_cb (GObject      *source,
 {
   CreateDeleteData *data = user_data;
   GError *error;
-  gssize size;
 
   error = NULL;
-  size = g_output_stream_write_finish (data->ostream, res, &error);
+  g_output_stream_write_finish (data->ostream, res, &error);
   g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PENDING);
   g_error_free (error);
 }
@@ -512,11 +510,10 @@ replaced_cb (GObject      *source,
              gpointer      user_data)
 {
   ReplaceLoadData *data = user_data;
-  gboolean ret;
   GError *error;
 
   error = NULL;
-  ret = g_file_replace_contents_finish (data->file, res, NULL, &error);
+  g_file_replace_contents_finish (data->file, res, NULL, &error);
   g_assert_no_error (error);
 
   g_file_load_contents_async (data->file, NULL, loaded_cb, data);
diff --git a/gio/tests/httpd.c b/gio/tests/httpd.c
index c3aaf33..d8f53e1 100644
--- a/gio/tests/httpd.c
+++ b/gio/tests/httpd.c
@@ -72,6 +72,7 @@ handler (GThreadedSocketService *service,
       *tmp = 0;
       version = tmp + 1;
     }
+  version = version; /* To avoid -Wunused-but-set-variable */
 
   query = strchr (escaped, '?');
   if (query != NULL)
diff --git a/gio/tests/live-g-file.c b/gio/tests/live-g-file.c
index 32203b6..84e46a1 100644
--- a/gio/tests/live-g-file.c
+++ b/gio/tests/live-g-file.c
@@ -126,7 +126,6 @@ create_empty_file (GFile * parent, const char *filename,
 		   GFileCreateFlags create_flags)
 {
   GFile *child;
-  gboolean res;
   GError *error;
   GFileOutputStream *outs;
 
@@ -138,7 +137,7 @@ create_empty_file (GFile * parent, const char *filename,
   g_assert_no_error (error);
   g_assert (outs != NULL);
   error = NULL;
-  res = g_output_stream_close (G_OUTPUT_STREAM (outs), NULL, &error);
+  g_output_stream_close (G_OUTPUT_STREAM (outs), NULL, &error);
   g_object_unref (outs);
   return child;
 }
diff --git a/gio/tests/sleepy-stream.c b/gio/tests/sleepy-stream.c
index 1c6613e..fc235e1 100644
--- a/gio/tests/sleepy-stream.c
+++ b/gio/tests/sleepy-stream.c
@@ -164,11 +164,8 @@ read_line (GDataInputStream  *stream,
            GError           **error)
 {
   gsize length;
-  int eol_len;
   char *str;
 
-  eol_len = 1 + (eol[1] != '\0');
-
   str = g_data_input_stream_read_line (stream, &length, NULL, error);
 
   if (str == NULL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]