Skip to content

Commit

Permalink
tree: fix nvme_read_config() to not set errno if return 0
Browse files Browse the repository at this point in the history
It should not touch errno but open() set value in json_read_config().

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
  • Loading branch information
ikegami-t authored and igaw committed Aug 1, 2024
1 parent e4a6434 commit 12346ad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ nvme_root_t nvme_create_root(FILE *fp, int log_level)
int nvme_read_config(nvme_root_t r, const char *config_file)
{
int err = -1;
int tmp;

if (!r || !config_file) {
errno = ENODEV;
Expand All @@ -311,13 +312,17 @@ int nvme_read_config(nvme_root_t r, const char *config_file)
errno = ENOMEM;
return err;
}

tmp = errno;
err = json_read_config(r, config_file);
/*
* The json configuration file is optional,
* so ignore errors when opening the file.
*/
if (err < 0 && errno != EPROTO)
err = 0;
if (err < 0 && errno != EPROTO) {
errno = tmp;
return 0;
}

return err;
}
Expand Down

0 comments on commit 12346ad

Please sign in to comment.