Page MenuHomeFreeBSD

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

Authored by 0mp on Dec 15 2020, 6:05 PM.
Tags
None
Referenced Files
F106096456: D27623.diff
Wed, Dec 25, 8:29 AM
Unknown Object (File)
Fri, Dec 20, 7:45 AM
Unknown Object (File)
Wed, Dec 4, 6:31 AM
Unknown Object (File)
Fri, Nov 29, 4:37 PM
Unknown Object (File)
Nov 20 2024, 10:34 AM
Unknown Object (File)
Nov 20 2024, 12:26 AM
Unknown Object (File)
Nov 7 2024, 4:11 PM
Unknown Object (File)
Oct 2 2024, 3:57 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 Passed
Unit
No Test Coverage
Build Status
Buildable 35422
Build 32336: arc lint + arc unit

Event Timeline

0mp requested review of this revision.Dec 15 2020, 6:05 PM
yuripv added inline comments.
lib/libc/string/strerror.3
158

@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

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

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.