From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by sourceware.org (Postfix) with ESMTPS id BD76B3988893 for ; Tue, 4 May 2021 13:18:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BD76B3988893 Received: by mail-qv1-xf2a.google.com with SMTP id q6so3208630qvb.2 for ; Tue, 04 May 2021 06:18:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UhV6fcNnw+9B2WQBrzVwqPQAlGZx+QcuL/YWF6YwxPg=; b=iLc1TAw6uML5hPUIGiwsLfYqIC7zw4lHTtQy0mOr8fZAPKyHObWUbichZRct1I39+S f35RS/b/ZbNfxul0JY88F9GdcBSnCIoWHainWMKByeYEpEG4a0anVW091Kwlb/yPwCxT WPrLoohsoBlyAxSlj97lBUDaP+beo51fVuOCqK1b0ddoKMRtEKQFqiloG//kzkJE80xC 9vI9MOMCsseMhI5kyDkbFXqRs3Ge2yHuJcoaJqLXk0iNYYqeuaPSxUAIkLbzQVVWZJrm utXAgDEifYpLRA9SLtnTu5erXw283YuUc9Add5UTDFlCBFmDGPc1mxtC89YOsk07R/F6 blHA== X-Gm-Message-State: AOAM532q3a3A8WORX6245VFfOLzujmr0J5GjmebTOEuY1M8bdelDclt2 gS5nmf9e7/IJ02fWqU0unmv0hud/MbB2Iw== X-Google-Smtp-Source: ABdhPJz7X03GYomycz/75vixMoYj8KGVsd5m2OBC3dXuzKNEjk+7UvfOgXEVa9GP2aYlnIKhBAXSjQ== X-Received: by 2002:ad4:4724:: with SMTP id l4mr25901652qvz.0.1620134338260; Tue, 04 May 2021 06:18:58 -0700 (PDT) Received: from [192.168.1.4] ([177.194.37.86]) by smtp.gmail.com with ESMTPSA id g13sm2331817qtp.31.2021.05.04.06.18.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 May 2021 06:18:57 -0700 (PDT) Subject: Re: [PATCH 2/3] linux: use fd_to_filename instead of _fitoa_word in ttyname_r. To: libc-alpha@sourceware.org References: <20210504015152.31064-1-ericonr@disroot.org> <20210504015152.31064-2-ericonr@disroot.org> From: Adhemerval Zanella Message-ID: Date: Tue, 4 May 2021 10:18:55 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210504015152.31064-2-ericonr@disroot.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2021 13:18:59 -0000 On 03/05/2021 22:51, Érico Nogueira via Libc-alpha wrote: > Simplifies the logic and makes intent clearer, while at the same time > decreasing binary size. > > On x86_64, dropped from 1883270 to 1883206, a 64 byte decrease. LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > sysdeps/unix/sysv/linux/ttyname_r.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c > index c1092d1695..fa1578fb64 100644 > --- a/sysdeps/unix/sysv/linux/ttyname_r.c > +++ b/sysdeps/unix/sysv/linux/ttyname_r.c > @@ -26,7 +26,7 @@ > #include > #include > > -#include <_itoa.h> > +#include > > #include "ttyname.h" > > @@ -92,7 +92,7 @@ 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 fd_to_filename filename; > struct stat64 st, st1; > int dostat = 0; > int doispty = 0; > @@ -122,9 +122,7 @@ __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'; > - > - ssize_t ret = __readlink (procname, buf, buflen - 1); > + ssize_t ret = __readlink (__fd_to_filename (fd, &filename), buf, buflen - 1); > if (__glibc_unlikely (ret == -1 && errno == ENAMETOOLONG)) > { > __set_errno (ERANGE); >