Page MenuHomeFreeBSD

ftw.3: Add examples
ClosedPublic

Authored by 0mp on Sep 22 2019, 12:31 PM.
Tags
None
Referenced Files
F106860439: D21750.id67710.diff
Mon, Jan 6, 1:38 PM
Unknown Object (File)
Sun, Jan 5, 9:08 PM
Unknown Object (File)
Thu, Dec 26, 7:15 PM
Unknown Object (File)
Thu, Dec 26, 5:01 PM
Unknown Object (File)
Wed, Dec 25, 5:25 PM
Unknown Object (File)
Tue, Dec 24, 9:05 PM
Unknown Object (File)
Mon, Dec 23, 1:59 PM
Unknown Object (File)
Dec 2 2024, 4:33 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.