Page MenuHomeFreeBSD

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

Authored by 0mp on Dec 15 2020, 6:05 PM.

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 OK
Unit
No Unit Test Coverage
Build Status
Buildable 35430
Build 32344: 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
157

@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
160

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
160

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.