[ob,7.10] Fix build issue with nat/linux-namespaces.c

Message ID 1442225356-5734-1-git-send-email-gbenson@redhat.com
State New, archived
Headers

Commit Message

Gary Benson Sept. 14, 2015, 10:09 a.m. UTC
  Hi all,

This commit was pushed to gdb/master on July 14 but not pushed to
7.10.  It fixes a build issue on systems with a prototype for setns
in their header files but no working setns is detected by configure.
Pushed to 7.10 as obvious.

Thanks,
Gary

---
gdb/ChangeLog:

	PR gdb/18957
	* nat/linux-namespaces.c (setns): Rename from this ...
	(do_setns): ... to this.  Support calling setns if it exists.
	(mnsh_handle_setns): Call do_setns.
---
 gdb/ChangeLog              |    7 +++++++
 gdb/nat/linux-namespaces.c |   12 ++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c
index 6fb0a2b..4341429 100644
--- a/gdb/nat/linux-namespaces.c
+++ b/gdb/nat/linux-namespaces.c
@@ -34,18 +34,18 @@  int debug_linux_namespaces;
 
 /* Handle systems without setns.  */
 
-#ifndef HAVE_SETNS
-static int
-setns (int fd, int nstype)
+static inline int
+do_setns (int fd, int nstype)
 {
-#ifdef __NR_setns
+#ifdef HAVE_SETNS
+  return setns (fd, nstype);
+#elif defined __NR_setns
   return syscall (__NR_setns, fd, nstype);
 #else
   errno = ENOSYS;
   return -1;
 #endif
 }
-#endif
 
 /* Handle systems without MSG_CMSG_CLOEXEC.  */
 
@@ -495,7 +495,7 @@  mnsh_recv_message (int sock, enum mnsh_msg_type *type,
 static ssize_t
 mnsh_handle_setns (int sock, int fd, int nstype)
 {
-  int result = setns (fd, nstype);
+  int result = do_setns (fd, nstype);
 
   return mnsh_return_int (sock, result, errno);
 }