Page MenuHomeFreeBSD

strerror.3: Add an example for perror()
ClosedPublic

Authored by 0mp on Dec 15 2020, 6:05 PM.
Tags
None
Referenced Files
F159391441: D27623.id80746.diff
Sat, Jun 13, 3:09 PM
F159380772: D27623.id80826.diff
Sat, Jun 13, 12:12 PM
Unknown Object (File)
Fri, Jun 12, 9:54 PM
Unknown Object (File)
Sat, May 30, 4:54 PM
Unknown Object (File)
Wed, May 20, 5:16 AM
Unknown Object (File)
Fri, May 15, 8:44 AM
Unknown Object (File)
May 6 2026, 12:46 AM
Unknown Object (File)
Apr 30 2026, 6:20 PM
Subscribers

Details

Summary
strerror.3: Add an example for perror()

This is a nice and quick reference.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

0mp requested review of this revision.Dec 15 2020, 6:05 PM
yuripv added inline comments.
lib/libc/string/strerror.3
158 ↗(On Diff #80725)

@yuripv, let me know if that's a nice addition to the manual page or not. :) I understand it's basic stuff, but I feel like it's nice to show common patterns in a manual for reference.

Hmm, maybe it's better to keep the example shorter as in the err(3) manual page?

In D27623#617254, @0mp wrote:

@yuripv, let me know if that's a nice addition to the manual page or not. :) I understand it's basic stuff, but I feel like it's nice to show common patterns in a manual for reference.

it is nice addition indeed, every little bit helps

In D27623#617271, @0mp wrote:

Hmm, maybe it's better to keep the example shorter as in the err(3) manual page?

not sure, both works for me.

p.s. as you mentioned err(3), i think there an error in "Warn of an error" example -- second one uses err().

jilles added inline comments.
lib/libc/string/strerror.3
161 ↗(On Diff #80727)

This is not a great example since it is undefined behaviour. In fact, before FreeBSD 11.0, this caused a segmentation fault instead of an error return.

Perhaps a better example is fd = open("/dev/null/wrong", O_RDONLY); which will fail with Not a directory.

lib/libc/string/strerror.3
161 ↗(On Diff #80727)

Ha, fascinating! Thanks a lot, I'll update the revision shortly.

Use open() instead of pipe().

This revision is now accepted and ready to land.Dec 16 2020, 3:10 PM
This revision was automatically updated to reflect the committed changes.