Manual update for get.*_r functions

Andreas Jaeger aj@arthur.rhein-neckar.de
Wed Jun 30 14:54:00 GMT 1999


>>>>> Ulrich Drepper writes:

Uli> Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:
>> I've checked POSIX and my understanding of POSIX is that the check for 
>> NULL is necessary.

Uli> POSIX says:

Uli> 	If successful, the getpwuid_r() and getpwnam_r() functions shall
Uli> 	return zero.  Otherwise, an error number shall be returned to
Uli> 	indicate the error.


Uli> I.e., the return value is != 0 in all error cases and no found entry
Uli> is an error case.

Let's read it in context.  Please note that I'm citing the draft from
the Austin Group:

  The getpwnam_r() function updates the passwd structure pointed to by 
  pwd and stores a pointer to that structure at the location pointed
  to by result.  The structure contonas an entry from the user
  database with a matching name.  Storage referenced by the structure
  is allocated from the memory provided with the buffer parameter,
  which is bufsize characters in size.  The maximum size needed for
  this buffer can be determined with the {_SC_GETPW_R_SIZE_MAX}
  sysconf() paramter.  A NULL pointer is returned at the location
  pointed to by result on error or if the requested entry is not
  found.

For me the last sentence differentiates between errors and no entry
found - which lead me to imply that no entry found is *not* an error
and therefore the function should return 0.

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de


More information about the Libc-hacker mailing list