[glib] Fix variable-scoping to avoid declaring on platforms where not used



commit b8ccbd9a3cfa8b6130999e3666593037eaf697f1
Author: Daniel Macks <dmacks netspace org>
Date:   Mon Feb 11 11:12:42 2013 -0500

    Fix variable-scoping to avoid declaring on platforms where not used
    
    "len" is only used by some platforms' implementations (as controlled
    by various autoconf/#ifdef tokens) and only in a small codeblock in
    those cases, but was declared based on a looser #ifdef heuristic and
    in a larger scope. The result is an unused-variable warning when built
    on some platforms. Move declaration to the local codeblocks that use
    the variable, which also restricts it to the narrower set of platforms
    where those codeblocks are used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689323

 gio/gunixmounts.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index c4f4d3d..c03d112 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -1280,7 +1280,6 @@ _g_get_unix_mount_points (void)
   GList *return_list;
 #ifdef HAVE_SYS_SYSCTL_H
   int usermnt = 0;
-  size_t len = sizeof(usermnt);
   struct stat sb;
 #endif
   
@@ -1291,10 +1290,15 @@ _g_get_unix_mount_points (void)
   
 #ifdef HAVE_SYS_SYSCTL_H
 #if defined(HAVE_SYSCTLBYNAME)
-  sysctlbyname ("vfs.usermount", &usermnt, &len, NULL, 0);
+  {
+    size_t len = sizeof(usermnt);
+
+    sysctlbyname ("vfs.usermount", &usermnt, &len, NULL, 0);
+  }
 #elif defined(CTL_VFS) && defined(VFS_USERMOUNT)
   {
     int mib[2];
+    size_t len = sizeof(usermnt);
     
     mib[0] = CTL_VFS;
     mib[1] = VFS_USERMOUNT;
@@ -1303,6 +1307,7 @@ _g_get_unix_mount_points (void)
 #elif defined(CTL_KERN) && defined(KERN_USERMOUNT)
   {
     int mib[2];
+    size_t len = sizeof(usermnt);
     
     mib[0] = CTL_KERN;
     mib[1] = KERN_USERMOUNT;


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