From 088f26a1c92aba1e90a332fb8635ce9cfa96d7e1 Mon Sep 17 00:00:00 2001 From: James Corbett Date: Wed, 4 Sep 2024 13:05:07 -0700 Subject: [PATCH] readers: simplify jgf reader unpack logic --- resource/readers/resource_reader_jgf.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/resource/readers/resource_reader_jgf.cpp b/resource/readers/resource_reader_jgf.cpp index f3ad63fb3..3f319ddc5 100644 --- a/resource/readers/resource_reader_jgf.cpp +++ b/resource/readers/resource_reader_jgf.cpp @@ -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", @@ -384,7 +384,11 @@ 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__; @@ -392,15 +396,6 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element, 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__;