- Text output is the same.
Details
- Reviewers
- None
- Group Reviewers
manpages - Commits
- rGe725ee7eb672: mount: add libxo(3) support
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 39321 Build 36210: arc lint + arc unit
Event Timeline
sbin/mount/mount.c | ||
---|---|---|
156 | Aren't these lines (151, 152) a suitable candidate for a macro? |
Open the mount container before any calls to xo_errx
Use a macro to close the container, finish and exit.
I think the xo_emit() stuff is right, but I'm not sure.
The rest of the stuff seems good, modulo my comments.
sbin/mount/mount.c | ||
---|---|---|
69 | Minor nit: I'd align all the \ if they aren't already (it's hard to tell with phab sometimes, but I think there's a tab missing) | |
257 | This doesn't make any sense. Negative return values from main are weird. | |
675 | this is indented too far. It should just be tab 4-spaces. |
sbin/mount/mount.c | ||
---|---|---|
69 | This looks aligned in vim with freebsd.vim. |
sbin/mount/mount.c | ||
---|---|---|
711 | There are some 32-bit ints in fsid_t and we want to interpret them as unsigned bytes and print using hexadecimal representation. So it's a matter of calculating the needed space once and using that space in a loop, like this: if (sfp->f_fsid.val[0] != 0 || sfp->f_fsid.val[1] != 0) { xo_emit("{D:, }{Lw:fsid}"); fsidbuf = malloc(sizeof(sfp->f_fsid) * 2 + 1); if (fsidbuf == NULL) xo_errx(1, "malloc failed"); for (i = 0; i < sizeof(sfp->f_fsid); i++) sprintf(&fsidbuf[i * 2], "%02x", ((u_char *)&sfp->f_fsid)[i]); fsidbuf[i * 2] = '\0'; xo_emit("{:fsid}", fsidbuf); free(fsidbuf); } |
sbin/mount/mount.c | ||
---|---|---|
711 | And then it seems the two xo_emit() calls can be folded into xo_emit("{D:, }{Lw:fsid}{:fsid}", fsidbuf); |
xo_parse_args gives error messages for invalid arguments; no further error is needed.
https://libxo.readthedocs.io/en/latest/api.html?#parsing-command-line-arguments-xo-parse-args
argc = xo_parse_args(argc, argv); if (argc < 0) exit(EXIT_FAILURE);
Also looks like you've lost the space in "write: sync". Use "{Lwc:writes}{P: }{Lw:sync}".
Could you please give me more details about your comment "If I don't do this, when using --libxo json the fsid will start with (null),", since we don't want that to be happening?
Thanks,
Phil
One more thing: Does libxo need an xo_exit() function? It would be just xo_finish + exit, like your EXIT macro, but might help minimize diffs like this.
Thanks,
Phil
diff -u <(sudo /usr/obj/usr/src/amd64.amd64/sbin/mount/mount -v) <(sudo mount -v) doesn't show any difference between the outputs before and after this commit.
Could you please give me more details about your comment "If I don't do this, when using --libxo json the fsid will start with (null),", since we don't want that to be happening?
That was about a previous version of this diff and it had more to do with memory management and strings than with libxo.