Skip to content

Commit 12346ad

Browse files
ikegami-tigaw
authored andcommitted
tree: fix nvme_read_config() to not set errno if return 0
It should not touch errno but open() set value in json_read_config(). Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent e4a6434 commit 12346ad

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/nvme/tree.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ nvme_root_t nvme_create_root(FILE *fp, int log_level)
300300
int nvme_read_config(nvme_root_t r, const char *config_file)
301301
{
302302
int err = -1;
303+
int tmp;
303304

304305
if (!r || !config_file) {
305306
errno = ENODEV;
@@ -311,13 +312,17 @@ int nvme_read_config(nvme_root_t r, const char *config_file)
311312
errno = ENOMEM;
312313
return err;
313314
}
315+
316+
tmp = errno;
314317
err = json_read_config(r, config_file);
315318
/*
316319
* The json configuration file is optional,
317320
* so ignore errors when opening the file.
318321
*/
319-
if (err < 0 && errno != EPROTO)
320-
err = 0;
322+
if (err < 0 && errno != EPROTO) {
323+
errno = tmp;
324+
return 0;
325+
}
321326

322327
return err;
323328
}

0 commit comments

Comments
 (0)