This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v6 6/6] linux ttyname and ttyname_r: Add tests
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Luke Shumaker <lukeshu at lukeshu dot com>
- Cc: libc-alpha at sourceware dot org, christian dot brauner at mailbox dot org
- Date: Sun, 12 Nov 2017 10:21:29 +0100
- Subject: Re: [PATCH v6 6/6] linux ttyname and ttyname_r: Add tests
- Authentication-results: sourceware.org; auth=none
- References: <20171110200827.32265-1-lukeshu@lukeshu.com> <20171110200827.32265-7-lukeshu@lukeshu.com>
* Luke Shumaker:
> +/* returns a pointer to static storage */
> +static char *
> +xreadlink (const char *linkname)
> +{
> + static char target[PATH_MAX+1];
> + ssize_t target_len = readlink (linkname, target, PATH_MAX);
> + VERIFY (target_len > 0);
> + target_len = trim_prefix (target, target_len, "(unreachable)");
> + target[target_len] = '\0';
> + return target;
> +}
Please don't use x* names in this way in tests, they should go into
support/ as glibc function wrappers. (I just added a different
implementation of xreadlink to support/.)