Original diff: Phil Shafer
Additional code: Kim Shrier <kim@westryn.net>
Sponsored by: Norse
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
I glossed over the review. There are a lot of changes and I'm not aware of how the libxo grammar works, but if this could be done in phases it would make it a lot easier to review...
usr.bin/netstat/Makefile | ||
---|---|---|
45–46 | Use LIBADD instead of DPADD/LDADD? Just watch out for MFC issues.. | |
usr.bin/netstat/if.c | ||
129 | xo_open_list and xo_close_list can fail. I think we care because that means that the output gathering would be all for naught, correct? This comment applies to other areas where this pattern's applied as well. | |
134 | style(9): remove space between (uintmax_t) and *a; this comment (spurious space between cast and variable) applies to other additions as well. | |
254 | style(9): bad indentation -- 4 spaces after hard tab (here and elsewhere). | |
326 | This indentation looks off. Is it a phabricator bug? | |
331 | I understand what you're doing, but this seems a bit gratuitous, and ifa->ifa_name is a bit easier to grok than name. | |
416 | Should this be size_t? | |
422 | Indentation, and this also seemed like it should have been a general purpose function elsewhere.. | |
usr.bin/netstat/inet.c | ||
352 | This seems a bit gratuitous (along with the next line's whitespace change). Should this be a separate commit? | |
usr.bin/netstat/main.c | ||
864 | (Random question) should usage messages be converted to libxo...? |
- Need to close socket instances for 'netstat -a'
- Quote pointer values.
- Fixup socket output, use a single list.
- Fixup padding between CPU&Name for -Q output
- Only open socket list when doing control block print
- quote icmp-address-responses
- Need to close input-histogram
- hex address needs to be quoted
- Tests for json from netstat
- Remove stray diff markers
- debug macros
- Workaround {P: can't take 0 pad and number args seem broken.
- Deal with zero lenth LINK address.
- Need to close interface instance.
- Emit well formatted json when -q given with -w
usr.bin/netstat/inet.c | ||
---|---|---|
1233–1234 | Typo: output-histagram should be output-histogram |
usr.bin/netstat/route.c | ||
---|---|---|
918–922 | The format generated in "buffer" is suitable for printf(), but not for xo_emit(). The correct format strung for xo_emit() might be generated by: snprintf(buffer, sizeof(buffer), "{d:/%%-%d.%ds }", wid_flags, wid_flags); (untested) |
I took another direction with this, can you see if it makes sense? I now output the old flags as well as the new flags. Maybe there is even a better way to make "pretty_flags" into a key-value dict?
Do you really need the textual version of the flags when generating XML or JSON?
I do actually consider the previous version better (with tag "flags" instead of "pretty_flags"). The individual elements are not "pretty", they are just the XML/JSON way of making the flag easily accessible for testing in scripts.
There is no better way to generate the key-value dict that I know of.
The "l" modifier of xo_emit() is undocumented except in the libxo sources, but it seems to be there exactly for your use case. I'd like to use a different API for libxo, which I'm going to discuss elsewhere.
(To give an idea of what I'd rather use instead of the "l" modifier: xo_emit("{:tag/...}") within xo_open_list("tag") should imply the "l" modifier for JSON output - this modifier is a NOP for all other formats, anyway.)
Looks OK. In a future pass, the testing logic should be converted from Makefile logic that is in there now
into a test that generates a Kyuafile under /usr/tests.