This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH,HURD] hurd: compliance fixes for getlogin_r
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Pino Toscano <toscano dot pino at tiscali dot it>
- Cc: libc-alpha at sourceware dot org, bug-hurd at gnu dot org
- Date: Fri, 27 Apr 2012 15:15:42 -0700 (PDT)
- Subject: Re: [PATCH,HURD] hurd: compliance fixes for getlogin_r
- References: <201204271244.03657.toscano.pino@tiscali.it>
You can just use string_t and no need for the XXX comment.
libc code can use C99 freely these days, so use an inline initializing
declaration rather than pre-declaring a new variable.
I don't think there's any need to iniitalize the result buffer. We trust
the RPC stubs to return a properly-terminated string on success, and if
they didn't then that wouldn't necessarily catch it anyway. If you want
that sort of paranoia, use __strnlen (login, sizeof login - 1).
If you've already called strlen/strnlen then don't use strncpy,
just use memcpy with the known length.
Thanks,
Roland