git: e90dd5d67365 - main - devinfo: Factor out helper function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 06 May 2025 22:02:23 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=e90dd5d67365c210881f665290b3b39317685c5a
commit e90dd5d67365c210881f665290b3b39317685c5a
Author: ktullavik <ktullavik@gmail.com>
AuthorDate: 2024-10-17 20:13:03 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-05-06 22:01:47 +0000
devinfo: Factor out 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 | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c
index 183b13b4201b..43d88481d903 100644
--- a/usr.sbin/devinfo/devinfo.c
+++ b/usr.sbin/devinfo/devinfo.c
@@ -264,6 +264,17 @@ print_rman(struct devinfo_rman *rman, void *arg __unused)
return(0);
}
+static void
+print_device_path_entry(struct devinfo_dev *dev)
+{
+ const char *devname = dev->dd_name[0] ? dev->dd_name : "unknown";
+
+ printf("%s", devname);
+ print_device_props(dev);
+ if (vflag)
+ printf("\n");
+}
+
static int
print_device_path(struct devinfo_dev *dev, void *xname)
{
@@ -271,20 +282,14 @@ print_device_path(struct devinfo_dev *dev, void *xname)
int rv;
if (strcmp(dev->dd_name, name) == 0) {
- printf("%s", dev->dd_name[0] ? dev->dd_name : "unknown");
- print_device_props(dev);
- if (vflag)
- printf("\n");
+ print_device_path_entry(dev);
return (1);
}
rv = devinfo_foreach_device_child(dev, print_device_path, xname);
if (rv == 1) {
printf(" ");
- printf("%s", dev->dd_name[0] ? dev->dd_name : "unknown");
- print_device_props(dev);
- if (vflag)
- printf("\n");
+ print_device_path_entry(dev);
}
return (rv);
}