From c8c0844f7fbcb955848ca84432e5ffcf71f1cef1 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 2 Aug 2013 12:59:45 -0400 Subject: debloat code that depends on /proc/self/fd/%d with shared function I intend to add more Linux workarounds that depend on using these pathnames, and some of them will be in "syscall" functions that, from an anti-bloat standpoint, should not depend on the whole snprintf framework. --- src/unistd/ttyname_r.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/unistd') diff --git a/src/unistd/ttyname_r.c b/src/unistd/ttyname_r.c index 2255e2df..a2ce3511 100644 --- a/src/unistd/ttyname_r.c +++ b/src/unistd/ttyname_r.c @@ -3,6 +3,8 @@ #include #include +void __procfdname(char *, unsigned); + int ttyname_r(int fd, char *name, size_t size) { char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2]; @@ -10,7 +12,7 @@ int ttyname_r(int fd, char *name, size_t size) if (!isatty(fd)) return ENOTTY; - snprintf(procname, sizeof procname, "/proc/self/fd/%d", fd); + __procfdname(procname, fd); l = readlink(procname, name, size); if (l < 0) return errno; -- cgit v1.2.1