This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: question on sparc SHMLBA helper function


From: Roland McGrath <roland@hack.frob.com>
Date: Fri, 16 Mar 2012 14:35:06 -0700 (PDT)

> Perhaps we can avoid the issue entirely.  I see exactly one use
> of SHMLBA, in shmat.c, and I really don't understand what that
> logic is intended to do.  It is sorely lacking a comment.

It just seems to be a very poor way to detect an error return value.

All the INTERNAL_SYSCALL_ERROR_P bits should take care of things these
days, and then the only return value we have to check for from
INTERNAL_SYSCALL is "-1".

Probably something as simple as this:

diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 2eec6a6..e4076fc 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -51,7 +51,7 @@ shmat (shmid, shmaddr, shmflg)
 					       shmid, shmflg,
 					       (long int) __ptrvalue (&raddr),
 					       __ptrvalue ((void *) shmaddr));
-  if ((unsigned long) result <= -(unsigned long) SHMLBA)
+  if ((unsigned long) result != (unsigned long) -1)
     result = raddr;
 
   return BOUNDED_N (result, length);


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