This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Code cleanup: int *status -> int *statusp


Hi,

it cost me some time to debug some threads racing due to the problem that:

#include <sys/wait.h>
int
main (int argc, char **argv)
{
  return WIFSTOPPED (&argc);
}

does not produce any warning due to:

/usr/include/stdlib.h
/* Lots of hair to allow traditional BSD use of `union wait'
   as well as POSIX.1 use of `int' for the status word.  */
#   define __WAIT_INT(status) \
  (__extension__ (((union { __typeof(status) __in; int __i; }) \
                   { .__in = (status) }).__i))

and GDB uses the "status" name sometimes for `int' and sometimes for `int *'.

GLIBC man uses:
  pid_t wait(int *status);
  pid_t waitpid(pid_t pid, int *status, int options);
although POSIX uses:
  http://www.opengroup.org/onlinepubs/009695399/functions/wait.html
  pid_t wait(int *stat_loc);
  pid_t waitpid(pid_t pid, int *stat_loc, int options);

I will check it in in several days as obvious if no complains get replied.


Thanks,
Jan


gdb/
2010-08-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linux-nat.c (pull_pid_from_list): Rename status to statusp.
	(my_waitpid): Likewise.

--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -376,7 +376,7 @@ add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
 }
 
 static int
-pull_pid_from_list (struct simple_pid_list **listp, int pid, int *status)
+pull_pid_from_list (struct simple_pid_list **listp, int pid, int *statusp)
 {
   struct simple_pid_list **p;
 
@@ -385,7 +385,7 @@ pull_pid_from_list (struct simple_pid_list **listp, int pid, int *status)
       {
 	struct simple_pid_list *next = (*p)->next;
 
-	*status = (*p)->status;
+	*statusp = (*p)->status;
 	xfree (*p);
 	*p = next;
 	return 1;
@@ -414,13 +414,13 @@ linux_tracefork_child (void)
 /* Wrapper function for waitpid which handles EINTR.  */
 
 static int
-my_waitpid (int pid, int *status, int flags)
+my_waitpid (int pid, int *statusp, int flags)
 {
   int ret;
 
   do
     {
-      ret = waitpid (pid, status, flags);
+      ret = waitpid (pid, statusp, flags);
     }
   while (ret == -1 && errno == EINTR);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]