public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Code cleanup: int *status -> int *statusp
@ 2010-08-26  9:55 Jan Kratochvil
  2010-08-28  8:38 ` Jan Kratochvil
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kratochvil @ 2010-08-26  9:55 UTC (permalink / raw)
  To: gdb-patches

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);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Code cleanup: int *status -> int *statusp
  2010-08-26  9:55 [patch] Code cleanup: int *status -> int *statusp Jan Kratochvil
@ 2010-08-28  8:38 ` Jan Kratochvil
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kratochvil @ 2010-08-28  8:38 UTC (permalink / raw)
  To: gdb-patches

Hi,

checked-in.


Jan


http://sourceware.org/ml/gdb-cvs/2010-08/msg00182.html

--- src/gdb/ChangeLog	2010/08/27 23:09:58	1.12123
+++ src/gdb/ChangeLog	2010/08/28 08:38:24	1.12124
@@ -1,3 +1,9 @@
+2010-08-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Code cleanup.
+	* linux-nat.c (pull_pid_from_list): Rename status to statusp.
+	(my_waitpid): Likewise.
+
 2010-08-27  Doug Evans  <dje@google.com>
 
 	* dwarf2read.c (dw2_require_line_header): Read from .debug_types
--- src/gdb/linux-nat.c	2010/07/27 21:22:09	1.180
+++ src/gdb/linux-nat.c	2010/08/28 08:38:25	1.181
@@ -376,7 +376,7 @@
 }
 
 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 @@
       {
 	struct simple_pid_list *next = (*p)->next;
 
-	*status = (*p)->status;
+	*statusp = (*p)->status;
 	xfree (*p);
 	*p = next;
 	return 1;
@@ -414,13 +414,13 @@
 /* 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);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-28  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-26  9:55 [patch] Code cleanup: int *status -> int *statusp Jan Kratochvil
2010-08-28  8:38 ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).