From nobody Fri Jun 19 14:22:26 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ghftq2ZPDz6jPMN for ; Fri, 19 Jun 2026 14:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ghftp3Fncz44My for ; Fri, 19 Jun 2026 14:22:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781878946; 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; bh=RAZ/FvlRXUb/E3avuXhZgv8LePbUOVFytEnobpt47pU=; b=COHJ30vWj9Nag3hAOQqRRo6XyvzSLr8WniNBAX9pYm/P89mt2ZXLFypcMRj0PUp/9mX/sV APbguMD5TA3JVyLieM4fTFB/s+FunUHnMvHYHXLnUOEGUwq3+CxQMx9HUHMGrT52bRWa73 I9X8Lbgqjzoe2TMnCHJuniyoWXu/DF7lp8AzvHs94AwbKSw+Qt52NKFuAYlui4IOvmQtQ7 1QRKmgnT1IB+2d/hsXbu7JyF1DJmPGEpaUU9BG90iqD575V/LAwHbBETk14+mQS3dqUamN yFvIp4W/YqMan9O9kg8/FP9aso6elJea3qToXpre7+SM36VLiL1d03IPHtEthg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781878946; a=rsa-sha256; cv=none; b=vYQUSAYrjcbmWtK4EOkYDZvv03DnWwpV0iKHNt6f5uQQp0CF+lUk2Ff2P9oBTWx5jfOBUX lroZ2rTjLL2jsYc8v0eZWT2NnVYQWkwFjm6rUkDlGZmMg2MJBuvxOJsXk/HTXe84pXuYjh BmgCNqIMOj6ngUaMTWK9jbDlkSaLNNkUo+cefWwmBRof5YIGEDQdX822145Z8bk/w4dcX5 v0n+E04ng4AqgN09+icsAmV1xsIFa5AuxCY4xFgb1A/bPtMB/11X70S9A2H8NEu/N0ZE/w AS/kHd86IgYrz1EvnZUSQd89TQzPEVxRxkt14ry+5wcaHZDWDe3V/o+thV/ATw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781878946; 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; bh=RAZ/FvlRXUb/E3avuXhZgv8LePbUOVFytEnobpt47pU=; b=hxCOHBxaS2OO/JBsLldauwD118a0CGfPIKhhKj1ypccpt3ylsPiiZ2VCGn+OCXmsKnEIwl OzPXVIyATRy7ntX0uF2EJbyFSsCvGk+V9ySvUUHk5aEMackk/32z9IoWO9kzKAhVE8FHZW CDThp4/f58DCV6Qysc4EnLWhTp0nR2W6xEjuqrZ1boIdqjBB7Ouda2Gg7exCi5OWkg8L8T CJEDVLrr475IjDs/IRwlXACSP0+bE+5k/EBZss17sNHZQsAOQdn7ofyxxwgfSbUTZG1+FH ihcpUHcwsOcbXldUy/VrSY4zVBE25NU6xo+AeizBo7LyMPnz9Vqu7Y3a77xPkg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4ghftp1p8RzpFn for ; Fri, 19 Jun 2026 14:22:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3cea3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 19 Jun 2026 14:22:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Aymeric Wibo Subject: git: dc24f31b67f5 - main - ctermid(3): Fix return values section List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: obiwac X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc24f31b67f5b0bac35cb93470f6f2d065d99f6f Auto-Submitted: auto-generated Date: Fri, 19 Jun 2026 14:22:26 +0000 Message-Id: <6a3550a2.3cea3.363b73d0@gitrepo.freebsd.org> The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=dc24f31b67f5b0bac35cb93470f6f2d065d99f6f commit dc24f31b67f5b0bac35cb93470f6f2d065d99f6f Author: Aymeric Wibo AuthorDate: 2026-06-19 14:21:12 +0000 Commit: Aymeric Wibo CommitDate: 2026-06-19 14:21:16 +0000 ctermid(3): Fix return values section ctermid() doesn't, and has never, set errno. While here, add ctermid_r to the name section and align the parameter name in the source file. Reviewed by: bnovkov Approved by: bnovkov MFC after: 3 days Obtained from: https://github.com/apple-oss-distributions/libc Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D57396 --- lib/libc/gen/ctermid.3 | 25 +++++++++++++++---------- lib/libc/gen/ctermid.c | 14 +++++++------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/libc/gen/ctermid.3 b/lib/libc/gen/ctermid.3 index 2a53412f1b29..daf59f32c157 100644 --- a/lib/libc/gen/ctermid.3 +++ b/lib/libc/gen/ctermid.3 @@ -25,11 +25,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 1, 2011 +.Dd June 2, 2026 .Dt CTERMID 3 .Os .Sh NAME -.Nm ctermid +.Nm ctermid , +.Nm ctermid_r .Nd generate terminal pathname .Sh LIBRARY .Lb libc @@ -78,14 +79,18 @@ If no suitable lookup of the controlling terminal name can be performed, this implementation returns .Ql /dev/tty . .Sh RETURN VALUES -Upon successful completion, a -.Pf non- Dv NULL -pointer is returned. -Otherwise, a -.Dv NULL -pointer is returned and the global variable -.Va errno -is set to indicate the error. +The +.Fn ctermid +function returns +.Fa buf +if it is +.Pf non- Dv NULL , +otherwise it returns the address of a static buffer. +The +.Fn ctermid_r +function always returns +.Fa buf , +even if it is the NULL pointer. .Sh ERRORS The current implementation detects no error conditions. .Sh SEE ALSO diff --git a/lib/libc/gen/ctermid.c b/lib/libc/gen/ctermid.c index fb117b3c8ded..1ca2401f0c1d 100644 --- a/lib/libc/gen/ctermid.c +++ b/lib/libc/gen/ctermid.c @@ -39,32 +39,32 @@ #define LEN_PATH_DEV (sizeof(_PATH_DEV) - 1) char * -__ssp_real(ctermid)(char *s) +__ssp_real(ctermid)(char *buf) { static char def[sizeof(_PATH_DEV) + SPECNAMELEN]; struct stat sb; size_t dlen; int sverrno; - if (s == NULL) { - s = def; + if (buf == NULL) { + buf = def; dlen = sizeof(def) - LEN_PATH_DEV; } else dlen = L_ctermid - LEN_PATH_DEV; - strcpy(s, _PATH_TTY); + strcpy(buf, _PATH_TTY); /* Attempt to perform a lookup of the actual TTY pathname. */ sverrno = errno; if (stat(_PATH_TTY, &sb) == 0 && S_ISCHR(sb.st_mode)) - (void)sysctlbyname("kern.devname", s + LEN_PATH_DEV, + (void)sysctlbyname("kern.devname", buf + LEN_PATH_DEV, &dlen, &sb.st_rdev, sizeof(sb.st_rdev)); errno = sverrno; return (s); } char * -__ssp_real(ctermid_r)(char *s) +__ssp_real(ctermid_r)(char *buf) { - return (s != NULL ? ctermid(s) : NULL); + return (buf != NULL ? ctermid(buf) : NULL); }