Page MenuHomeFreeBSD

config: drop dependency on libsbuf
ClosedPublic

Authored by kevans on Jan 30 2023, 3:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 22, 8:06 AM
Unknown Object (File)
Apr 27 2024, 8:33 PM
Unknown Object (File)
Apr 27 2024, 8:33 PM
Unknown Object (File)
Apr 27 2024, 8:33 PM
Unknown Object (File)
Apr 27 2024, 8:33 PM
Unknown Object (File)
Apr 27 2024, 8:33 PM
Unknown Object (File)
Apr 23 2024, 1:01 AM
Unknown Object (File)
Feb 14 2024, 12:22 PM
Subscribers

Details

Summary

Use an std::stringstream instead. get_word() and get_quoted_word() both
return a buffer that's presumed to not need release, so solve this by
returning a new special configword type that holds a string or eof/eol
state. This cleans up caller checking for EOF/EOL to make it more
explicit what they're doing, at least in the EOL cases which previously
checked for NULL.

Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans created this revision.

Same C++ caveat
this looks like a fairly mechanical translation. I didn't see anything worth remarking on, except the depend stuff.
I'd try to have more eyes on it though... it's long enough a mistake might slip through (though the odds of that are somewhat reduced by a make universe and test booting)

tools/build/depend-cleanup.sh
110–114

Hmmm, you should have corrected the prior version instead of changing it here.

This revision is now accepted and ready to land.Jan 30 2023, 4:50 PM
usr.sbin/config/config.h
44 ↗(On Diff #116046)

Is this because mkheaders.c isn't converted? In which case what's stopping it?

78 ↗(On Diff #116046)

If you had operator* then one could use &* to do the same, a common pattern used in LLVM to unwrap things

usr.sbin/config/main.cc
52 ↗(On Diff #116046)

I have no clue what style(9) says about C++ but this seems like an odd order? It's alphabetical other than dirent.h at the moment.

usr.sbin/config/config.h
44 ↗(On Diff #116046)

mkheaders.c but also lang.l and config.y

78 ↗(On Diff #116046)

Looking at it again, the cast is to more cleanly support implicit conversions in strdup()/strcmp()/etc, but how about this new version? (Adding an operator-> that allows configword->c_str() instead of explicit casts in a couple of output places)

78 ↗(On Diff #116046)

That is: "mostly desirable to more cleanly ..."

Add an operator->, use it for some explicit c string conversions

This revision now requires review to proceed.Feb 6 2023, 4:31 AM
usr.sbin/config/config.h
78 ↗(On Diff #116046)

Yeah that's nicer, though if you have -> you should also make * consistent (const std::string &operator*() const)

Provide a logically consistent operator*

This revision was not accepted when it landed; it landed in state Needs Review.Feb 9 2023, 5:27 AM
This revision was automatically updated to reflect the committed changes.