Author: imp
Date: Wed May 30 15:08:59 2018
New Revision: 334384
URL: https://svnweb.freebsd.org/changeset/base/334384

Log:
  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.

Modified:
  head/usr.sbin/devinfo/devinfo.c

Modified: head/usr.sbin/devinfo/devinfo.c
==============================================================================
--- head/usr.sbin/devinfo/devinfo.c     Wed May 30 15:08:46 2018        
(r334383)
+++ head/usr.sbin/devinfo/devinfo.c     Wed May 30 15:08:59 2018        
(r334384)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 #include <err.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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");
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to