arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1505492-unused-10.patch

147e83
commit 8915eacef88eb25ac94e6bb37b473adb326e9d1b
147e83
Author: Joseph Myers <joseph@codesourcery.com>
147e83
Date:   Wed Nov 26 20:54:16 2014 +0000
147e83
147e83
    Avoid warnings for unused results in nscd/connections.c.
147e83
    
147e83
    This patch avoids warnings for unused results of setuid and setgid in
147e83
    nscd/connections.c using an ignore_value macro along the lines
147e83
    suggested by Paul in
147e83
    <https://sourceware.org/ml/libc-alpha/2014-11/msg00733.html>.
147e83
    
147e83
    Tested for x86_64.
147e83
    
147e83
            * include/libc-internal.h (ignore_value): New macro.
147e83
            * nscd/connections.c (restart): Wrap calls to setuid and setgid
147e83
            with ignore_value.
147e83
147e83
diff --git a/include/libc-internal.h b/include/libc-internal.h
147e83
index 78f82da58a2c334b..2ced1c17d3dff93d 100644
147e83
--- a/include/libc-internal.h
147e83
+++ b/include/libc-internal.h
147e83
@@ -70,4 +70,10 @@ extern void __init_misc (int, char **, char **);
147e83
 #define PTR_ALIGN_UP(base, size) \
147e83
   ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
147e83
 
147e83
+/* Ignore the value of an expression when a cast to void does not
147e83
+   suffice (in particular, for a call to a function declared with
147e83
+   attribute warn_unused_result).  */
147e83
+#define ignore_value(x) \
147e83
+  ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
147e83
+
147e83
 #endif /* _LIBC_INTERNAL  */
147e83
diff --git a/nscd/connections.c b/nscd/connections.c
147e83
index 53813cf58876eae7..54b70e88d894523a 100644
147e83
--- a/nscd/connections.c
147e83
+++ b/nscd/connections.c
147e83
@@ -1486,7 +1486,7 @@ cannot change to old UID: %s; disabling paranoia mode"),
147e83
 cannot change to old GID: %s; disabling paranoia mode"),
147e83
 		   strerror (errno));
147e83
 
147e83
-	  setuid (server_uid);
147e83
+	  ignore_value (setuid (server_uid));
147e83
 	  paranoia = 0;
147e83
 	  return;
147e83
 	}
147e83
@@ -1501,8 +1501,8 @@ cannot change to old working directory: %s; disabling paranoia mode"),
147e83
 
147e83
       if (server_user != NULL)
147e83
 	{
147e83
-	  setuid (server_uid);
147e83
-	  setgid (server_gid);
147e83
+	  ignore_value (setuid (server_uid));
147e83
+	  ignore_value (setgid (server_gid));
147e83
 	}
147e83
       paranoia = 0;
147e83
       return;
147e83
@@ -1546,8 +1546,8 @@ cannot change to old working directory: %s; disabling paranoia mode"),
147e83
 
147e83
   if (server_user != NULL)
147e83
     {
147e83
-      setuid (server_uid);
147e83
-      setgid (server_gid);
147e83
+      ignore_value (setuid (server_uid));
147e83
+      ignore_value (setgid (server_gid));
147e83
     }
147e83
   if (chdir ("/") != 0)
147e83
     dbg_log (_("cannot change current working directory to \"/\": %s"),