Page MenuHomeFreeBSD

D57396.diff
No OneTemporary

D57396.diff

diff --git a/lib/libc/gen/ctermid.3 b/lib/libc/gen/ctermid.3
--- 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 @@
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
--- 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);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Jun 15, 2:52 AM (19 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33962893
Default Alt Text
D57396.diff (1 KB)

Event Timeline