From patchwork Mon May 29 15:46:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 768263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wc1MB6wwVz9s5L for ; Tue, 30 May 2017 01:47:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Ykj39aYb"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=MBvkhGJYuge1/bag voJamMNPNTzjMkL6ibcAcc8hEB19As3MTBBav0TYLk5B/J2In5RMmGJaQtNgM/NT ZiHjjhHoUEPNTLqaZ/l10B9cTyixcmeP4F90Ri0x4CqUv2KM54aj9MYelTSIP85N nVYwsJvcw73NyfUSX+iq78px7vo= 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:date:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=Iz0QWMtqZBqiFKBE/+Xgam iwEKU=; b=Ykj39aYbmWfHV6qvFAcj2pSgPOUxfAZfXbpxp6EvbiYY83Dc91rA9N BL9QqKxw4rmmulzUkra2mHh6ULVlpIbP+vJghqtmjodPtY5QGtQfTbu5/Ass2JJL oT4VcJoOrTNGQJqWQnMicwW+MmmuNS5Igr+so7SCVzvXDM8J0xcBw= Received: (qmail 45971 invoked by alias); 29 May 2017 15:46:52 -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 45915 invoked by uid 89); 29 May 2017 15:46:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*F:D*se X-HELO: aloka.lostca.se Date: Mon, 29 May 2017 15:46:48 +0000 From: Arjun Shankar To: libc-alpha@sourceware.org Cc: Joseph Myers , Florian Weimer Subject: [PATCH v2] Remove check for NULL buffer passed to `ptsname_r' Message-ID: <20170529154648.GA21435@aloka.lostca.se> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) `ptsname_r' is declared in stdlib.h to only accept a `nonnull' second argument and therefore GCC may choose to make optimizations based on the assumption that this argument is NULL. This means that potentially, GCC can optimize away the NULL check at some point in the future. Since this is a programming interface, we might as well remove the NULL check ourselves. This also warrants a change to the `ptsname_r' manual page that must be submitted to the corresponding mailing list. In addition, remove the NULL buffer test in login/tst-ptsname.c. ChangeLog: 2017-05-29 Arjun Shankar * sysdeps/unix/sysv/linux/ptsname.c (__ptsname_internal): Remove check for NULL 'buf'. * login/tst-ptsname.c (do_test): Remove test with NULL 'buf'. --- Discussion on PATCH v1: https://sourceware.org/ml/libc-alpha/2017-05/msg00726.html login/tst-ptsname.c | 1 - sysdeps/unix/sysv/linux/ptsname.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/login/tst-ptsname.c b/login/tst-ptsname.c index be8744d..96f0449 100644 --- a/login/tst-ptsname.c +++ b/login/tst-ptsname.c @@ -70,7 +70,6 @@ do_test (void) if (fd != -1) { result |= do_single_test (fd, buf, sizeof (buf), 0); - result |= do_single_test (fd, NULL, sizeof (buf), EINVAL); result |= do_single_test (fd, buf, 1, ERANGE); close (fd); } diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c index e3f2ae8..41bb0bb 100644 --- a/sysdeps/unix/sysv/linux/ptsname.c +++ b/sysdeps/unix/sysv/linux/ptsname.c @@ -72,12 +72,6 @@ __ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp) int save_errno = errno; unsigned int ptyno; - if (buf == NULL) - { - __set_errno (EINVAL); - return EINVAL; - } - if (!__isatty (fd)) { __set_errno (ENOTTY);