Page MenuHomeFreeBSD

Implement ptsname_r.
ClosedPublic

Authored by delphij on Oct 3 2020, 2:55 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 9, 7:02 AM
Unknown Object (File)
Sat, Mar 9, 7:02 AM
Unknown Object (File)
Sat, Mar 9, 7:02 AM
Unknown Object (File)
Sat, Mar 9, 7:02 AM
Unknown Object (File)
Sat, Mar 9, 7:02 AM
Unknown Object (File)
Sat, Mar 9, 7:02 AM
Unknown Object (File)
Fri, Mar 8, 8:09 PM
Unknown Object (File)
Thu, Mar 7, 9:55 PM
Subscribers

Details

Summary

PR: 250062

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33983
Build 31176: arc lint + arc unit

Event Timeline

delphij created this revision.
lib/libc/stdlib/ptsname.c
82

In musl and glibc, if buffer 0, ERANGE is returned.

ioctl TIOCGPTN returns ERANGE so there is no need to do a user-space check.

Does FreeBSD need the user-space check?

87

If buflen is smaller than sizeof(_PATH_DEV) but longer than the actual return value, I think ptsname_r should still return 0.

113–116

== 0?

delphij added inline comments.
lib/libc/stdlib/ptsname.c
82

Hmm, I've looked at the manual page and found that it's only returned for glibc < 2.25, so I'll drop this. The reference was:

https://man7.org/linux/man-pages/man3/ptsname_r.3.html

delphij marked an inline comment as done.

Address 2 of reviewer comments.

lib/libc/stdlib/ptsname.c
87

We always prepend _PATH_DEV to the result, how does ptsname_r behave on e.g. Linux?

This revision is now accepted and ready to land.Oct 3 2020, 6:09 AM

Otherwise, seems alright!

lib/libc/stdlib/ptsname.3
141

Macros like Er do not expand here. It's much better to just put ERANGE here as the argument to width.

delphij marked an inline comment as done.

Address 0mp's comment.

This revision now requires review to proceed.Oct 3 2020, 9:13 PM
This revision is now accepted and ready to land.Oct 4 2020, 5:24 AM
jilles added inline comments.
lib/libc/stdlib/ptsname.3
120–121

I think .Fn ptsname_r should be added here as well.

143

This complies to https://www.austingroupbugs.net/bug_view_page.php?bug_id=508 which is planned for POSIX issue8 (in a few years).

delphij marked 2 inline comments as done.

Address reviewer comments;

Move width back to Er per suggestion from https://mandoc.bsd.lv/mdoc/details/width.html#Macro_default_widths .

This revision now requires review to proceed.Oct 4 2020, 5:55 PM
lib/libc/stdlib/ptsname.3
141

It looks like it's the recommended practice at https://mandoc.bsd.lv/mdoc/details/width.html#Macro_default_widths (and observing the output, using "ERANGE" would make the description wrap into its own line) so I have changed it back.

This revision is now accepted and ready to land.Oct 6 2020, 11:47 PM
This revision was automatically updated to reflect the committed changes.