[glib] Avoid setting unused variables (-Wself-assign)



commit b8f9c08a09c660761e4e8ff27339fc00c410f770
Author: Daniel Macks <dmacks netspace org>
Date:   Thu Apr 23 01:01:38 2015 -0400

    Avoid setting unused variables (-Wself-assign)
    
    Setting a variable and then assigning it to itself avoids
    -Wunused-but-set-variable but this specific trick is now caught by
    -Wself-assign. Instead, actually use the value or don't bother
    assigning it at all:
    
    gdbusauthmechanismsha1.c: #ifdef a var decl to match its actual use use
    gdbusauthmechanismsha1.c: call g_ascii_strtoll() in void context
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745723

 gio/gdbusauthmechanismsha1.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c
index 88b8f9b..47cef78 100644
--- a/gio/gdbusauthmechanismsha1.c
+++ b/gio/gdbusauthmechanismsha1.c
@@ -389,7 +389,6 @@ keyring_lookup_entry (const gchar  *cookie_context,
       gchar **tokens;
       gchar *endp;
       gint line_id;
-      guint64 line_when;
 
       if (line[0] == '\0')
         continue;
@@ -422,8 +421,7 @@ keyring_lookup_entry (const gchar  *cookie_context,
           goto out;
         }
 
-      line_when = g_ascii_strtoll (tokens[1], &endp, 10);
-      line_when = line_when; /* To avoid -Wunused-but-set-variable */
+      (void)g_ascii_strtoll (tokens[1], &endp, 10); /* do not care what the timestamp is */
       if (*endp != '\0')
         {
           g_set_error (error,
@@ -490,7 +488,9 @@ keyring_acquire_lock (const gchar  *path,
   gchar *lock;
   gint ret;
   guint num_tries;
+#ifdef EEXISTS
   guint num_create_tries;
+#endif
   int errsv;
 
   g_return_val_if_fail (path != NULL, FALSE);
@@ -512,8 +512,8 @@ keyring_acquire_lock (const gchar  *path,
    *         real locking implementations are still flaky on network filesystems
    */
 
-  num_create_tries = 0;
 #ifdef EEXISTS
+  num_create_tries = 0;
  again:
 #endif
   num_tries = 0;
@@ -562,7 +562,6 @@ 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 (errsv),


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