The branch main has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=a3eab01304884e13342bdaca4cf5204fa97ba456
commit a3eab01304884e13342bdaca4cf5204fa97ba456 Author: Faraz Vahedi <k...@kfv.io> AuthorDate: 2024-10-27 12:01:39 +0000 Commit: Mariusz Zaborski <osho...@freebsd.org> CommitDate: 2025-08-11 14:13:40 +0000 lsvfs(1): Make slight refactor Signed-off-by: Faraz Vahedi <k...@kfv.io> Reviewed by: markj, asomers (both earlier version) Pull Request: https://github.com/freebsd/freebsd-src/pull/1498 --- usr.bin/lsvfs/lsvfs.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/usr.bin/lsvfs/lsvfs.c b/usr.bin/lsvfs/lsvfs.c index 04ed38e8d978..5477d96434ac 100644 --- a/usr.bin/lsvfs/lsvfs.c +++ b/usr.bin/lsvfs/lsvfs.c @@ -39,8 +39,8 @@ int main(int argc, char **argv) { struct xvfsconf vfc, *xvfsp; - size_t buflen; - int cnt, i, rv = 0; + size_t cnt, buflen; + int rv = 0; argc--, argv++; @@ -59,15 +59,14 @@ main(int argc, char **argv) } } else { if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) - err(1, "sysctl(vfs.conflist)"); - xvfsp = malloc(buflen); - if (xvfsp == NULL) - errx(1, "malloc failed"); + err(EXIT_FAILURE, "sysctl(vfs.conflist)"); + if ((xvfsp = malloc(buflen)) == NULL) + errx(EXIT_FAILURE, "malloc failed"); if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) - err(1, "sysctl(vfs.conflist)"); + err(EXIT_FAILURE, "sysctl(vfs.conflist)"); cnt = buflen / sizeof(struct xvfsconf); - for (i = 0; i < cnt; i++) { + for (size_t i = 0; i < cnt; i++) { printf(FMT, xvfsp[i].vfc_name, xvfsp[i].vfc_typenum, xvfsp[i].vfc_refcount, fmt_flags(xvfsp[i].vfc_flags)); @@ -82,10 +81,9 @@ static const char * fmt_flags(int flags) { static char buf[sizeof(struct flaglist) * sizeof(fl)]; - int i; buf[0] = '\0'; - for (i = 0; i < (int)nitems(fl); i++) { + for (size_t i = 0; i < (int)nitems(fl); i++) { if ((flags & fl[i].flag) != 0) { strlcat(buf, fl[i].str, sizeof(buf)); strlcat(buf, ", ", sizeof(buf));