Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 May 2018 15:08:59 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334384 - head/usr.sbin/devinfo
Message-ID:  <201805301508.w4UF8xxo008774@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805301508.w4UF8xxo008774>