git: c73b33f85a4d - main - devinfo: Add helper function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 06 May 2025 22:02:19 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=c73b33f85a4d34d221c125780a059d86a8351f0b
commit c73b33f85a4d34d221c125780a059d86a8351f0b
Author: ktullavik <ktullavik@gmail.com>
AuthorDate: 2024-10-17 19:01:51 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-05-06 22:01:46 +0000
devinfo: Add helper function
This is prep for libxo.
No functional change intended.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1480
---
usr.sbin/devinfo/devinfo.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c
index d12f9d4ec331..04809323ec70 100644
--- a/usr.sbin/devinfo/devinfo.c
+++ b/usr.sbin/devinfo/devinfo.c
@@ -52,6 +52,7 @@ static int print_device(struct devinfo_dev *, void *);
static int print_rman_resource(struct devinfo_res *, void *);
static int print_rman(struct devinfo_rman *, void *);
static int print_device_path(struct devinfo_dev *, void *);
+static void print_path(struct devinfo_dev *, char *);
struct indent_arg
{
@@ -286,6 +287,15 @@ print_device_path(struct devinfo_dev *dev, void *xname)
return (rv);
}
+static void
+print_path(struct devinfo_dev *root, char *path)
+{
+ if (devinfo_foreach_device_child(root, print_device_path, (void *)path) == 0)
+ errx(1, "%s: Not found", path);
+ if (!vflag)
+ printf("\n");
+}
+
static void __dead2
usage(void)
{
@@ -336,10 +346,7 @@ main(int argc, char *argv[])
errx(1, "can't find root device");
if (path) {
- if (devinfo_foreach_device_child(root, print_device_path, (void *)path) == 0)
- errx(1, "%s: Not found", path);
- if (!vflag)
- printf("\n");
+ print_path(root, path);
} else if (uflag) {
/* print resource usage? */
devinfo_foreach_rman(print_rman, NULL);