Add a function to recursively walk a subtree of config options. While
here, reimplement dump_config() using this new function.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 67929 Build 64812: arc lint + arc unit
Event Timeline
Make walk_config_nodes non-recursive, leaving recursive processing to
the callback function if needed. Also, stop walking if the callback
returns a non-zero value, returning that value to the caller.
| usr.sbin/bhyve/config.h | ||
|---|---|---|
| 50 | Well, it really only passes the current prefix to the callback. If the callback wants to call walk_config_nodes() recursively, it needs to create a new prefix from the original prefix if it wants that. Or did I miss anything? | |
| usr.sbin/bhyve/config.h | ||
|---|---|---|
| 50 | Right, so it's effectively just a second arg parameter since it's up to the callback to do something useful with it. It just seems redundant: why not have dump_config() pass the prefix string as the callback arg instead of having a separate parameter for it? | |
| usr.sbin/bhyve/config.h | ||
|---|---|---|
| 50 | I can see why it may seem that way. dump_config() uses prefix it that way, and it has no need for arg. In the virtio-scsi multi-target change, prefix isn't used at all, but arg is used to pass the virtio-scsi softc around. But that's really just an implementation detail of these two changesets. While arg is intended to be used to pass anything to the callback, prefix is really supposed to pass a prefix string of config options if the callbacks need it, as is done by dump_config(). Another change I did as an experiment reworked the PCI initialization to use walk_config_nodes() to recursively initialize the PCI devices that were defined. This used both, arg to pass the device config nvlist and prefix to keep track the bus/slot/func currently being worked on. (I didn't post this change for review as it turned out it didn't really simplify things.) Of course, it's always possible to define a special struct for such cases and pass that through arg, but it seemed nicer with this interface as it is. | |