diff options
author | David Robillard <d@drobilla.net> | 2021-09-09 13:57:43 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | bd24b8f6d558bafbbb16d9490ebe3478dbf130bd (patch) | |
tree | 592c5ebc7694a80952b193de0adea0f4e640ec65 /src/node.c | |
parent | 1fb84760a8230637a806e8e83410fc7fb6d446d2 (diff) | |
download | serd-bd24b8f6d558bafbbb16d9490ebe3478dbf130bd.tar.gz serd-bd24b8f6d558bafbbb16d9490ebe3478dbf130bd.tar.bz2 serd-bd24b8f6d558bafbbb16d9490ebe3478dbf130bd.zip |
Use more human-readable status codes
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 33 |
1 files changed, 16 insertions, 17 deletions
@@ -93,9 +93,8 @@ serd_node_malloc(const size_t size) SerdNode* serd_node_try_malloc(const SerdWriteResult r) { - return (r.status && r.status != SERD_ERR_OVERFLOW) - ? NULL - : serd_node_malloc(r.count); + return (r.status && r.status != SERD_OVERFLOW) ? NULL + : serd_node_malloc(r.count); } void @@ -153,7 +152,7 @@ serd_node_construct_simple(const size_t buf_size, { const size_t total_size = sizeof(SerdNode) + serd_node_pad_length(string.len); if (!buf || total_size > buf_size) { - return result(SERD_ERR_OVERFLOW, total_size); + return result(SERD_OVERFLOW, total_size); } SerdNode* const node = (SerdNode*)buf; @@ -221,18 +220,18 @@ serd_node_construct_literal(const size_t buf_size, } if ((flags & SERD_HAS_DATATYPE) && (flags & SERD_HAS_LANGUAGE)) { - return result(SERD_ERR_BAD_ARG, 0); + return result(SERD_BAD_ARG, 0); } if (!meta.len) { - return result(SERD_ERR_BAD_ARG, 0); + return result(SERD_BAD_ARG, 0); } if (((flags & SERD_HAS_DATATYPE) && (!serd_uri_string_has_scheme(meta.buf) || !strcmp(meta.buf, NS_RDF "langString"))) || ((flags & SERD_HAS_LANGUAGE) && !is_langtag(meta))) { - return result(SERD_ERR_BAD_ARG, 0); + return result(SERD_BAD_ARG, 0); } const size_t padded_length = serd_node_pad_length(string.len); @@ -240,7 +239,7 @@ serd_node_construct_literal(const size_t buf_size, const size_t meta_size = sizeof(SerdNode) + serd_node_pad_length(meta.len); const size_t total_size = sizeof(SerdNode) + padded_length + meta_size; if (!buf || total_size > buf_size) { - return result(SERD_ERR_OVERFLOW, total_size); + return result(SERD_OVERFLOW, total_size); } SerdNode* const node = (SerdNode*)buf; @@ -271,7 +270,7 @@ serd_node_construct(const size_t buf_size, return ((type == SERD_LITERAL) ? serd_node_construct_literal(buf_size, buf, string, flags, meta) : (meta.len > 0u) - ? result(SERD_ERR_BAD_ARG, 0) + ? result(SERD_BAD_ARG, 0) : serd_node_construct_token(buf_size, buf, type, string)); } @@ -350,7 +349,7 @@ serd_node_construct_integer(const size_t buf_size, const SerdStringView datatype) { if (datatype.len && !serd_uri_string_has_scheme(datatype.buf)) { - return result(SERD_ERR_BAD_ARG, 0); + return result(SERD_BAD_ARG, 0); } char temp[24] = {0}; @@ -378,7 +377,7 @@ serd_node_construct_base64(const size_t buf_size, // Verify argument sanity if (!value || !value_size || (datatype.len && !serd_uri_string_has_scheme(datatype.buf))) { - return result(SERD_ERR_BAD_ARG, 0); + return result(SERD_BAD_ARG, 0); } // Determine the type to use (default to xsd:base64Binary) @@ -393,7 +392,7 @@ serd_node_construct_base64(const size_t buf_size, const size_t padded_length = serd_node_pad_length(r.count); const size_t total_size = sizeof(SerdNode) + padded_length + type_size; if (!buf || total_size > buf_size) { - return result(SERD_ERR_OVERFLOW, total_size); + return result(SERD_OVERFLOW, total_size); } SerdNode* const node = (SerdNode*)buf; @@ -438,7 +437,7 @@ serd_node_construct_uri(const size_t buf_size, const size_t length = serd_uri_string_length(uri); const size_t required_size = sizeof(SerdNode) + serd_node_pad_length(length); if (!buf || buf_size < required_size) { - return result(SERD_ERR_OVERFLOW, required_size); + return result(SERD_OVERFLOW, required_size); } // Write node header @@ -464,7 +463,7 @@ serd_node_new(const SerdNodeType type, const SerdStringView meta) { SerdWriteResult r = serd_node_construct(0, NULL, type, string, flags, meta); - if (r.status != SERD_ERR_OVERFLOW) { + if (r.status != SERD_OVERFLOW) { return NULL; } @@ -602,8 +601,8 @@ serd_get_base64(const SerdNode* const node, const ExessVariableResult r = exess_read_base64(buf_size, buf, serd_node_string(node)); - return r.status == EXESS_NO_SPACE ? result(SERD_ERR_OVERFLOW, max_size) - : r.status ? result(SERD_ERR_BAD_SYNTAX, 0u) + return r.status == EXESS_NO_SPACE ? result(SERD_OVERFLOW, max_size) + : r.status ? result(SERD_BAD_SYNTAX, 0u) : result(SERD_SUCCESS, r.write_count); } @@ -749,7 +748,7 @@ serd_node_construct_file_uri(const size_t buf_size, } if (!buf || count > buf_size) { - return result(SERD_ERR_OVERFLOW, count); + return result(SERD_OVERFLOW, count); } node->length = length; |