Derek Price wrote: > +int > +getlogin_r (char *name, size_t size) > +{ > + char *n = getlogin (); > + if (n) > + { > + size_t nlen = strlen (n); > + if (nlen < size) > + { > + memcpy (name, n, nlen + 1); > + return 0; > + } > + errno = ERANGE; > + } > + return -1; > +}
The return value is incorrect, and the getlogin () return conventions are ignored. http://www.opengroup.org/onlinepubs/009695399/functions/getlogin.html says: "Upon successful completion, getlogin() shall return a pointer to the login name or a null pointer if the user's login name cannot be found. Otherwise, it shall return a null pointer and set errno to indicate the error." Which means, you need to set errno = 0 before calling getlogin(), to distinguish two of the three cases. And "If successful, the getlogin_r() function shall return zero; otherwise, an error number shall be returned to indicate the error." So, instead of "errno = ERANGE; return -1; " you need to do "return ERANGE;". Bruno _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib