Page MenuHomeFreeBSD

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

Authored by 0mp on Dec 15 2020, 6:05 PM.
Tags
None
Referenced Files
F81613611: D27623.id80727.diff
Thu, Apr 18, 11:43 PM
Unknown Object (File)
Sun, Apr 7, 12:07 AM
Unknown Object (File)
Sat, Mar 30, 1:34 PM
Unknown Object (File)
Sat, Mar 30, 1:34 PM
Unknown Object (File)
Jan 19 2024, 5:05 AM
Unknown Object (File)
Dec 23 2023, 1:23 AM
Unknown Object (File)
Nov 29 2023, 7:51 AM
Unknown Object (File)
Nov 29 2023, 12:31 AM
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.