From patchwork Fri Feb 14 18:11:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1238280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109770-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=qYdzxFZ+; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bZta+AL5; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48K1fX1tYpzB47Z for ; Sat, 15 Feb 2020 05:11:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=nbv2DtYhbTQIZh5d 6SLjmSfb43E6U+WBTAKUl00pP7GVOaq6AuMAkU/dgFgbPI3S2+h4IHlJfuCfxLaB v8cEeZw8Z1+pBVC7beZfdzQy6H6wexhXHexnQTUwlz014ByJJGDt807WdJm3aJjv 2vsAtoIUP8OSYTmFzIhSW14/TO8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=86Yi4OvqctkSdHiRnnb0XI AvSao=; b=qYdzxFZ+6gIX+yqEvA2Xnc+QdbnqJyZbp+m9BbZ1T07RTjnIrQ4mZP GK8DAXZTfvodQqmC059DtbX5mJthr+ZsLLxgbv6MZR7V+NWB7Lo/pdzMZrkVQiQ/ Xofid0a+0sCQxEsiJat3x+VkefGRvBwuF38MjHrKXpcn/NHnA9qV4= Received: (qmail 95357 invoked by alias); 14 Feb 2020 18:11:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 95345 invoked by uid 89); 14 Feb 2020 18:11:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*i:sk:cover.1, st1 X-HELO: us-smtp-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581703881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pK1gutaoxKuA9FgDGVuPOXLwu+EWoTV+ADH+NqdqOEs=; b=bZta+AL5CMpd0OcmcazORO+T6GUTrRv2eGRXjnYR0Yt3o3/8S/jLRnqyHri2ULQRVOucsP rOKImK9VN1Jc9rVwbkEVlr3es+5c8+FPC/LJsZtV7M6AsVoz+HGDaN8Mt9MSahvexeyMk4 +GZbsAILWHlhxh3i1B5/nyO/U3Ms/Q0= From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 2/3] Linux: Port ttyname, ttyname_r to In-Reply-To: References: X-From-Line: dfe5df934af6d37ca92c8d324bb39413b0b8174e Mon Sep 17 00:00:00 2001 Message-Id: Date: Fri, 14 Feb 2020 19:11:15 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com --- misc/tst-fd_to_filename.c | 1 + sysdeps/unix/sysv/linux/ttyname.c | 7 +++---- sysdeps/unix/sysv/linux/ttyname_r.c | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/misc/tst-fd_to_filename.c b/misc/tst-fd_to_filename.c index 480f613dcf..eb08dd7e25 100644 --- a/misc/tst-fd_to_filename.c +++ b/misc/tst-fd_to_filename.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index c05ca687f5..6034e132b0 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -25,8 +25,7 @@ #include #include #include - -#include <_itoa.h> +#include #include "ttyname.h" @@ -112,7 +111,6 @@ char * ttyname (int fd) { static size_t buflen; - char procname[30]; struct stat64 st, st1; int dostat = 0; int doispty = 0; @@ -129,7 +127,8 @@ ttyname (int fd) return NULL; /* We try using the /proc filesystem. */ - *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; + struct fd_to_filename procname_storage; + char *procname = __fd_to_filename (fd, &procname_storage); if (buflen == 0) { diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c index 4a1ae40bb2..e16761b43d 100644 --- a/sysdeps/unix/sysv/linux/ttyname_r.c +++ b/sysdeps/unix/sysv/linux/ttyname_r.c @@ -25,8 +25,7 @@ #include #include #include - -#include <_itoa.h> +#include #include "ttyname.h" @@ -92,7 +91,6 @@ getttyname_r (char *buf, size_t buflen, const struct stat64 *mytty, int __ttyname_r (int fd, char *buf, size_t buflen) { - char procname[30]; struct stat64 st, st1; int dostat = 0; int doispty = 0; @@ -122,7 +120,8 @@ __ttyname_r (int fd, char *buf, size_t buflen) return errno; /* We try using the /proc filesystem. */ - *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; + struct fd_to_filename procname_storage; + char *procname = __fd_to_filename (fd, &procname_storage); ssize_t ret = __readlink (procname, buf, buflen - 1); if (__glibc_unlikely (ret == -1 && errno == ENAMETOOLONG))