From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 578013942014 for ; Tue, 4 May 2021 16:43:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 578013942014 Received: by mail-qk1-x729.google.com with SMTP id q127so9195209qkb.1 for ; Tue, 04 May 2021 09:43:28 -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:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=AUmmLKPnc9aAMBE6l8KmffEjtdw4SPV/m6+J0k7oWtk=; b=QZBsrKA+y4AD4NhEuVhtrTBpBtigBwyKjpUOTcikaSm04+R0lDnypkCzo20PyJyEcK so3Ulx5AH5JbyutLYiN8fLXGYprVemO9dPz4mI/7GjiAwGhA29zXC7kUk6BOtq4V6INo 626I/bXsYZupT6WEniyEB/JZoS0HYeIq+2f8eJLpUAnhvGVBtVYZQuDrf/nZGNhpOkPa uQtMOqP5TlE8LJUuFVkuwavmQIOtDmCs83x+qBDNye4C4VKNaKG97WY+E6yX33g2+KzG UMdcgrpWVMOxnMrkGHx/qFKf25hZQkGdf+rZqUJl8cjqHIrMNAArIBhXW9XVeAnCDc/f ohtg== X-Gm-Message-State: AOAM533jdf1fzseNwc5YgJ3Au0EUNdtPcShaoil+FrPh1MHKJw3eErGw WN2vwDJRHFn9iqXbecMuECxB1Q8jNSJlFA== X-Google-Smtp-Source: ABdhPJy9lO4ATildhHxR6eN69e4XdiIL9FeZ27ICY7S+SqSzdQ/+U+mJVu/0J1BWILzlECcQahqWNw== X-Received: by 2002:a37:a34b:: with SMTP id m72mr24188212qke.92.1620146607910; Tue, 04 May 2021 09:43:27 -0700 (PDT) Received: from [192.168.1.4] ([177.194.37.86]) by smtp.gmail.com with ESMTPSA id v20sm11155574qkf.28.2021.05.04.09.43.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 May 2021 09:43:27 -0700 (PDT) Subject: Re: [PATCH 3/3] linux: implement ttyname as a wrapper around ttyname_r. From: Adhemerval Zanella To: libc-alpha@sourceware.org, =?UTF-8?Q?=c3=89rico_Nogueira?= References: <20210504015152.31064-1-ericonr@disroot.org> <20210504015152.31064-3-ericonr@disroot.org> Message-ID: <0b9e65b7-832d-ab6f-f73b-1d7ea5fccfe9@linaro.org> Date: Tue, 4 May 2021 13:43:25 -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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 16:43:29 -0000 On 04/05/2021 13:37, Adhemerval Zanella wrote: >> - >> - if (!name && dostat != -1) >> + int result = ttyname_r (fd, ttyname_buf, TTYNAME_BUFLEN); >> + if (result != 0) > > Why do you need to pass the allocated buffer size minus 1? The ttyname_r > should handle it, it already pass buflen - 1 on readlink for instance. You also need a libc_hidden_{proto,def} ttyname_r to avoid the intra PLT (the elf/check-localplt should have warned you about it).