Page MenuHomeFreeBSD

rs: Use getopt() and strtol() instead of mannual parsing.
ClosedPublic

Authored by jhb on Sep 29 2022, 10:48 PM.
Tags
None
Referenced Files
F103819127: D36834.id113175.diff
Fri, Nov 29, 8:49 PM
F103814582: D36834.id111254.diff
Fri, Nov 29, 7:20 PM
Unknown Object (File)
Tue, Nov 26, 6:31 AM
Unknown Object (File)
Oct 11 2024, 10:20 PM
Unknown Object (File)
Oct 3 2024, 6:28 PM
Unknown Object (File)
Oct 2 2024, 5:27 AM
Unknown Object (File)
Sep 30 2024, 11:21 PM
Unknown Object (File)
Sep 27 2024, 12:02 PM
Subscribers

Details

Summary

This uses the "::" extension to getopt() to handle options which take
an optional argument.

The updated flag tests were all wrong before and only passed because
the manual parser failed to raise errors when a required argument was
missing. The invalid argument test now gets a better error message.

In general the tests are pretty worthless. They don't actually test
any real functionality of the tool and provide a false sense that the
tests actually mean something.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 47648
Build 44535: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Sep 29 2022, 10:48 PM

I will probably trim the last paragraph from the log since I ended up adding a followup commit to flesh out the tests more.

brooks added inline comments.
usr.bin/rs/rs.cc
427–437

It looks like these are dead code?

This revision is now accepted and ready to land.Sep 29 2022, 11:27 PM
emaste added inline comments.
usr.bin/rs/tests/rs_test.sh
103

these ones were actually buggy tests before?

usr.bin/rs/rs.cc
427–437

Yes, sorry. These options are not documented in the manpage and nothing uses the cord, icbd, or ocbd variables.

usr.bin/rs/tests/rs_test.sh
103

Yes. These should have been failing with an error due to missing a required argument.