tree: fail on non-negative return values from parse_and_open
Currently, we see a warning with specific compilers:
../nvme/nvme.c: In function 'ns_rescan':
../nvme/nvme.c:4389:19: warning: 'dev' may be used uninitialized in this function [-Wmaybe-uninitialized]
This is due to a theoretical failure path in parse_and_open(), where
argconfig_parse() returns a positive value - this would require the
global errno to be negative.
Even though the unintialised use of dev is only possible with negative
error (which shouldn't happen), we should still consider any non-zero
return value of parse_and_open a failure. This change fixes the
instances of:
err = parse_and_open(...);
if (err < 0)
changing to:
err = parse_and_open(...);
if (err)
... and also applies this to the single use of open_exclusive().
The positive return values from parse_and_open() were removed in
11542bbd; beforehand, parse_and_open() would return a fd.
Fixes: 11542bbd ("tree: Combine NVMe file descriptor into struct nvme_dev")
Fixes: https://github.com/linux-nvme/nvme-cli/issues/1647
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>