This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: 3.3.4b


> 
> XFree86 3.3.4b is available
> 
> please check the following
> 
> - PAM support (this is for people using Red Hat or SuSE 6.2)
> - glibc-2.1.2 changes

I was told that all getxxx_r functions, which return int, in the latest and
final POSIX.1b would return 0 on success and errno on error. glibc 2.1.2 will
follow the latest and final POSIX.1b. I believe this patch is safe for POSIX
and none-POSIX implemenations.

Thanks.

H.J.
----
--- ../../../import/xfree86/beta/xc/include/Xos_r.h	Thu Jul 22 09:24:50 1999
+++ xc/include/Xos_r.h	Tue Jul 20 11:08:04 1999
@@ -282,14 +282,14 @@ typedef struct {
 # if defined(_POSIX_REENTRANT_FUNCTIONS) || !defined(SVR4) || defined(Lynx)
 #  ifndef Lynx
 #   define _XGetpwuid(u,p) \
-((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws)
+((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == 0) ? &(p).pws : NULL)
 #   define _XGetpwnam(u,p) \
-((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws)
+((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == 0) ? &(p).pws : NULL)
 #  else /* Lynx */
 #   define _XGetpwuid(u,p) \
-((getpwuid_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws)
+((getpwuid_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf)) == 0) ? &(p).pws : NULL)
 #   define _XGetpwnam(u,p) \
-((getpwnam_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws)
+((getpwnam_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf)) == 0) ? &(p).pws : NULL)
 #  endif
 # else /* SVR4 */
 #  define _XGetpwuid(u,p) \
@@ -312,11 +312,11 @@ typedef struct {
 } _Xgetpwparams;
 typedef int _Xgetpwret;
 # define _XGetpwuid(u,p) \
-((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == -1) ? \
- NULL : (p).pwp)
+((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == 0) ? \
+ (p).pwp : NULL)
 # define _XGetpwnam(u,p) \
-((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == -1) ? \
- NULL : (p).pwp)
+((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == 0) ? \
+ (p).pwp : NULL)
 #endif /* X_INCLUDE_PWD_H */
 
 #if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H)
@@ -452,33 +452,15 @@ typedef struct {
   struct servent      sent;
   struct servent_data sdata;
 } _Xgetservbynameparams;
-/* 
- * glibc-2.1.2 changes the getXXbyY_r functions to return errno instead of -1
- * in case of an error (this supposedly conforms to the latest POSIX)
- * this change is conditionalized for Linux only, to be on the save side, but
- * it should be correct for all implementations
- */
-#if defined(linux)
 #  define _XGethostbyname(h,hp) \
   (bzero((char*)&(hp).hdata,sizeof((hp).hdata)),	\
-   ((gethostbyname_r((h),&(hp).hent,&(hp).hdata) == 0) ? &(hp).hent : NULL))
+   ((gethostbyname_r((h),&(hp).hent,&(hp).hdata) == 0) ? &(hp).hent) : NULL)
 #  define _XGethostbyaddr(a,al,t,hp) \
   (bzero((char*)&(hp).hdata,sizeof((hp).hdata)),	\
-   ((gethostbyaddr_r((a),(al),(t),&(hp).hent,&(hp).hdata) == 0) ? &(hp).hent : NULL))
+   ((gethostbyaddr_r((a),(al),(t),&(hp).hent,&(hp).hdata) == 0) ? &(hp).hent) : NULL)
 #  define _XGetservbyname(s,p,sp) \
   (bzero((char*)&(sp).sdata,sizeof((sp).sdata)),	\
    ((getservbyname_r((s),(p),&(sp).sent,&(sp).sdata) == 0) ? &(sp).sent : NULL) )
-# else
-#  define _XGethostbyname(h,hp) \
-  (bzero((char*)&(hp).hdata,sizeof((hp).hdata)),	\
-   ((gethostbyname_r((h),&(hp).hent,&(hp).hdata) == -1) ? NULL : &(hp).hent))
-#  define _XGethostbyaddr(a,al,t,hp) \
-  (bzero((char*)&(hp).hdata,sizeof((hp).hdata)),	\
-   ((gethostbyaddr_r((a),(al),(t),&(hp).hent,&(hp).hdata) == -1) ? NULL : &(hp).hent))
-#  define _XGetservbyname(s,p,sp) \
-  (bzero((char*)&(sp).sdata,sizeof((sp).sdata)),	\
-   ((getservbyname_r((s),(p),&(sp).sent,&(sp).sdata) == -1) ? NULL : &(sp).sent) )
-# endif
 # endif
 # ifdef X_POSIX_THREAD_SAFE_FUNCTIONS
 #  undef X_POSIX_THREAD_SAFE_FUNCTIONS
@@ -723,9 +705,9 @@ typedef struct {
 # endif
 } _Xttynameparams;
 
-# define _XGetlogin(p)	(getlogin_r((p).buf, sizeof((p).buf)) ? NULL : (p).buf)
+# define _XGetlogin(p)	(getlogin_r((p).buf, sizeof((p).buf)) == 0 ? (p).buf : NULL)
 # define _XTtyname(f,p)	\
-	(ttyname_r((f), (p).buf, sizeof((p).buf)) ? NULL : (p).buf)
+	(ttyname_r((f), (p).buf, sizeof((p).buf)) == 0 ? (p).buf : NULL)
 
 #else
 /* Pre-POSIX API.
@@ -1106,11 +1088,11 @@ typedef struct {
 } _Xgetgrparams;
 
 #define _XGetgrgid(g,p)	\
- ((getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) ? \
-   NULL : (p).result))
+ ((getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) == 0 ? \
+   (p).result) : NULL)
 #define _XGetgrnam(n,p)	\
- ((getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) ? \
-   NULL : (p).result))
+ ((getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) == 0 ? \
+   (p).result) : NULL)
 #endif
 
 #if defined(X_INCLUDE_GRP_H) && !defined(_XOS_INCLUDED_GRP_H)

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