Page MenuHomeFreeBSD

ftw.3: Add examples

Authored by 0mp on Sep 22 2019, 12:31 PM.

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; 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.
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?

162 ↗(On Diff #62417)

Great idea! Thanks!

163 ↗(On Diff #62417)


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
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.

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?

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.