From patchwork Thu Jun 26 05:25:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marcus_H=C3=A4hnel?= X-Patchwork-Id: 2103141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernkonzept.com header.i=@kernkonzept.com header.a=rsa-sha256 header.s=mx1 header.b=gH+9PjwU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4bSjHF3mbNz1ymW for ; Fri, 27 Jun 2025 01:27:37 +1000 (AEST) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernkonzept.com header.i=@kernkonzept.com header.a=rsa-sha256 header.s=mx1 header.b=gH+9PjwU; dkim-atps=neutral Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 67068353BD9D; Thu, 26 Jun 2025 17:27:32 +0200 (CEST) Received: from mx.kernkonzept.com (serv1.kernkonzept.com [159.69.200.6]) by helium.openadk.org (Postfix) with ESMTPS id C15293521883 for ; Thu, 26 Jun 2025 17:27:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description; bh=xtO28xXaCFQ+r5dE7XmQcIAgt1MTf1qMFL02FnfuTCU=; b=gH+9PjwUBZB8jfefufk2SlZnxs 8Z6cq+dHUjxgFlmS/kyriGkZNZfjuWaBFaEsOG3iojyJih6Dzbd7G1kj8O2jydCmPSz9EuQdMfVGx tESOBkYRcRVHt16k1CmuBFiKpC56Uju+b/j/XWLOsk2v7FtSaRGoNkyPd/2L0O3uHDWp14RKnA7KE fnLnbaQyYsj/We0owl2TCmAjxZ2glTyuw7sp9icm6YRVpXRGFg4didtOZ2oK6jLgrqN3GWKaBccN3 48e1km+in7dv00/QXJtidLW3DEAJsJlEuiTLT54mItjXTLT1jo9/3YV9gpomblCvsbH/GacVlVm4t kcieKF5A==; Received: from [10.22.3.160] (helo=amethyst.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1uUoVa-001JDF-0E; Thu, 26 Jun 2025 17:27:26 +0200 From: Marcus Haehnel To: devel@uclibc-ng.org Date: Thu, 26 Jun 2025 17:25:08 +0200 Message-ID: <20250626152603.7035-2-marcus.haehnel@kernkonzept.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Message-ID-Hash: LV3N55EIAEM744BF7MCBBJGFDDTYGUDO X-Message-ID-Hash: LV3N55EIAEM744BF7MCBBJGFDDTYGUDO X-MailFrom: marcus.haehnel@kernkonzept.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Marcus Haehnel X-Mailman-Version: 3.3.8 Precedence: list Subject: [uclibc-ng-devel] [PATCH v2] openpty: Remove code that has been disabled for more than 20 years List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The use of ptsname_r instead of the custom pts_name seems to have proven in the field. Signed-off-by: Marcus Haehnel --- libutil/openpty.c | 76 ----------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/libutil/openpty.c b/libutil/openpty.c index e14cbc57d..74d86506b 100644 --- a/libutil/openpty.c +++ b/libutil/openpty.c @@ -26,61 +26,6 @@ #include #include -/* BCS: the following function is, IMO, overkill */ -#if 0 -/* Return the result of ptsname_r in the buffer pointed to by PTS, - which should be of length BUF_LEN. If it is too long to fit in - this buffer, a sufficiently long buffer is allocated using malloc, - and returned in PTS. 0 is returned upon success, -1 otherwise. */ -static int -pts_name (int fd, char **pts, size_t buf_len) -{ - int rv; - char *buf = *pts; - - for (;;) - { - char *new_buf; - - if (buf_len) - { - rv = ptsname_r (fd, buf, buf_len); - - if (rv != 0 || memchr (buf, '\0', buf_len)) - /* We either got an error, or we succeeded and the - returned name fit in the buffer. */ - break; - - /* Try again with a longer buffer. */ - buf_len += buf_len; /* Double it */ - } - else - /* No initial buffer; start out by mallocing one. */ - buf_len = 128; /* First time guess. */ - - if (buf != *pts) - /* We've already malloced another buffer at least once. */ - new_buf = realloc (buf, buf_len); - else - new_buf = malloc (buf_len); - if (! new_buf) - { - rv = -1; - __set_errno (ENOMEM); - break; - } - buf = new_buf; - } - - if (rv == 0) - *pts = buf; /* Return buffer to the user. */ - else if (buf != *pts) - free (buf); /* Free what we malloced when returning an error. */ - - return rv; -} -#endif - /* Create pseudo tty master slave pair and set terminal attributes according to TERMP and WINP. Return handles for both ends in AMASTER and ASLAVE, and return the name of the slave end in NAME. */ @@ -88,19 +33,10 @@ int openpty (int *amaster, int *aslave, char *name, const struct termios *termp, const struct winsize *winp) { -#if 0 -#ifdef PATH_MAX - char _buf[PATH_MAX]; -#else - char _buf[512]; -#endif - char *buf = _buf; -#else #ifdef PATH_MAX char buf[PATH_MAX]; #else char buf[512]; -#endif #endif int master, slave; @@ -114,20 +50,12 @@ openpty (int *amaster, int *aslave, char *name, const struct termios *termp, if (unlockpt (master)) goto fail; -#if 0 - if (pts_name (master, &buf, sizeof (_buf))) -#else if (ptsname_r (master, buf, sizeof buf)) -#endif goto fail; slave = open (buf, O_RDWR | O_NOCTTY); if (slave == -1) { -#if 0 - if (buf != _buf) - free (buf); -#endif goto fail; } @@ -142,10 +70,6 @@ openpty (int *amaster, int *aslave, char *name, const struct termios *termp, if (name != NULL) strcpy (name, buf); -#if 0 - if (buf != _buf) - free (buf); -#endif return 0; fail: