Skip to content

Commit

Permalink
readers: simplify jgf reader unpack logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshcorbett committed Sep 5, 2024
1 parent 2a925da commit 088f26a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions resource/readers/resource_reader_jgf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element,
goto done;
}
if ((json_unpack (metadata,
"{ s:s s:s s:s s:I s:I s:I s?:i s:b s:s s:I }",
"{ s:s s:s s:s s:I s:I s:I s?:i s:b s:s s:I s:o s?o }",
"type",
&f.type,
"basename",
Expand All @@ -384,23 +384,18 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element,
"unit",
&f.unit,
"size",
&f.size))
&f.size,
"paths",
paths,
"properties",
properties))
< 0) {
errno = EINVAL;
m_err_msg += __FUNCTION__;
m_err_msg += ": malformed metadata in an JGF node for ";
m_err_msg += std::string (f.vertex_id) + "\n";
goto done;
}
if ((p = json_object_get (metadata, "paths")) == NULL) {
errno = EINVAL;
m_err_msg += __FUNCTION__;
m_err_msg += ": key (paths) does not exist in an JGF node for ";
m_err_msg += std::string (f.vertex_id) + ".\n";
goto done;
}
*properties = json_object_get (metadata, "properties");
*paths = p;
if (*properties && !json_is_object (*properties)) {
errno = EINVAL;
m_err_msg += __FUNCTION__;
Expand Down

0 comments on commit 088f26a

Please sign in to comment.