Page MenuHomeFreeBSD

ftw.3: Add examples
ClosedPublic

Authored by 0mp on Sep 22 2019, 12:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 6:50 AM
Unknown Object (File)
Mon, Oct 28, 8:27 AM
Unknown Object (File)
Oct 14 2024, 8:51 AM
Unknown Object (File)
Oct 5 2024, 5:00 AM
Unknown Object (File)
Oct 5 2024, 5:00 AM
Unknown Object (File)
Oct 5 2024, 4:59 AM
Unknown Object (File)
Oct 5 2024, 4:59 AM
Unknown Object (File)
Oct 5 2024, 4:59 AM
Subscribers

Diff Detail

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

Event Timeline

The description of what it does makes sense, although I can't spot if that's actually what the code does.
Otherwise, LGTM.

jilles added inline comments.
lib/libc/gen/ftw.3
162 ↗(On Diff #62417)

Given that POSIX.1-2008tc2 says that ftw() is obsolete and applications should use nftw() instead, it seems better to have the example use nftw() instead.

163 ↗(On Diff #62417)

can be used.

189 ↗(On Diff #62417)

Not having a default in this switch feels somewhat uncomfortable, especially because POSIX says FTW_SL is a valid value here.

0mp planned changes to this revision.Feb 1 2020, 10:26 AM

Use nftw instead of ftw

0mp marked 3 inline comments as done.Feb 3 2020, 4:31 PM

The example now uses nftw() instead of ftw().

Is is ready now?

lib/libc/gen/ftw.3
162 ↗(On Diff #62417)

Great idea! Thanks!

163 ↗(On Diff #62417)

Done!

189 ↗(On Diff #62417)

I've included all the types now into the switch.

0mp marked 3 inline comments as done.Feb 4 2020, 8:50 AM
lib/libc/gen/ftw.3
189 ↗(On Diff #62417)

Especially for example code it would be better to have defined behaviour for all values of typeflag. Consider that people might copy and paste.

lib/libc/gen/ftw.3
189 ↗(On Diff #62417)

@jilles, Hmmm, the example now has a case statement for every possible value of typeflag. I think I don't understand your comment. Am I missing something?

lib/libc/gen/ftw.3
189 ↗(On Diff #62417)

Paranoia in case the code is edited to remove cases or to add a flag (that does not exist yet) requesting a new typeflag value. Initializing type or adding a default would avoid that.

0mp planned changes to this revision.Feb 18 2020, 11:35 AM

Add a default case to the switch statement

This revision is now accepted and ready to land.Mar 4 2020, 9:06 PM
This revision was automatically updated to reflect the committed changes.