Page MenuHomeFreeBSD

Implement ptsname_r.
ClosedPublic

Authored by delphij on Oct 3 2020, 2:55 AM.

Details

Summary

PR: 250062

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

delphij created this revision.
lib/libc/stdlib/ptsname.c
82 ↗(On Diff #77803)

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 ↗(On Diff #77803)

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

118 ↗(On Diff #77803)

== 0?

delphij added inline comments.
lib/libc/stdlib/ptsname.c
82 ↗(On Diff #77803)

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 ↗(On Diff #77803)

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
140 ↗(On Diff #77804)

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 ↗(On Diff #77829)

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

142 ↗(On Diff #77829)

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
140 ↗(On Diff #77804)

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.