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

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