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.
This commit is contained in:
imp 2018-05-30 15:08:59 +00:00
parent c6bf8b17c5
commit ace493e034

View File

@ -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");