From b98d2b35dff9bff4380986818b0c6d93a751752c Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 30 May 2018 15:08:59 +0000 Subject: [PATCH] devinfo_init() returns an errno, but doesn't set errno, so the error message when it fails reflects some random thing rather than what it returned. Set errno to the return value. --- usr.sbin/devinfo/devinfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c index c4ec2eeccfd0..be18c57dc5e7 100644 --- a/usr.sbin/devinfo/devinfo.c +++ b/usr.sbin/devinfo/devinfo.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -242,7 +243,7 @@ int main(int argc, char *argv[]) { struct devinfo_dev *root; - int c, uflag; + int c, uflag, rv; char *path = NULL; uflag = 0; @@ -268,8 +269,10 @@ main(int argc, char *argv[]) if (path && (rflag || uflag)) usage(); - if (devinfo_init()) + if ((rv = devinfo_init()) != 0) { + errno = rv; err(1, "devinfo_init"); + } if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == NULL) errx(1, "can't find root device");