Skip to content

Commit

Permalink
nvme: return ret error value to open device if errno not set
Browse files Browse the repository at this point in the history
The APIs may not set errno so set errno to 0 before the device open.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Jul 18, 2024
1 parent ede9a5f commit 4596090
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,14 @@ static int get_dev(struct nvme_dev **dev, int argc, char **argv, int flags)
return ret;

devname = argv[optind];
errno = 0;

if (!strncmp(devname, "mctp:", strlen("mctp:")))
ret = open_dev_mi_mctp(dev, devname);
else
ret = open_dev_direct(dev, devname, flags);

return ret != 0 ? -errno : 0;
return ret ? errno ? -errno : ret < 0 ? ret : -ret : 0;
}

static int parse_args(int argc, char *argv[], const char *desc,
Expand Down

0 comments on commit 4596090

Please sign in to comment.