diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc/loader.c | 5 | ||||
-rw-r--r-- | src/common/config-parser.c | 30 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/blogc/loader.c b/src/blogc/loader.c index 57db98f..165bb8e 100644 --- a/src/blogc/loader.c +++ b/src/blogc/loader.c @@ -62,6 +62,7 @@ blogc_template_parse_from_file(const char *f, bc_error_t **err) { if (err == NULL || *err != NULL) return NULL; + size_t len; char *s = bc_file_get_contents(f, true, &len, err); if (s == NULL) @@ -77,6 +78,7 @@ blogc_source_parse_from_file(const char *f, bc_error_t **err) { if (err == NULL || *err != NULL) return NULL; + size_t len; char *s = bc_file_get_contents(f, true, &len, err); if (s == NULL) @@ -98,6 +100,9 @@ blogc_source_parse_from_file(const char *f, bc_error_t **err) bc_slist_t* blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) { + if (err == NULL || *err != NULL) + return NULL; + bc_error_t *tmp_err = NULL; bc_slist_t *rv = NULL; unsigned int with_date = 0; diff --git a/src/common/config-parser.c b/src/common/config-parser.c index ff05f2e..bfea2d4 100644 --- a/src/common/config-parser.c +++ b/src/common/config-parser.c @@ -26,7 +26,7 @@ typedef enum { bc_config_t* bc_config_parse(const char *src, size_t src_len, bc_error_t **err) { - if (err != NULL && *err != NULL) + if (err == NULL || *err != NULL) return NULL; size_t current = 0; @@ -69,9 +69,8 @@ bc_config_parse(const char *src, size_t src_len, bc_error_t **err) state = CONFIG_SECTION_KEY; continue; } - if (err != NULL) - *err = bc_error_parser(BC_ERROR_CONFIG_PARSER, src, src_len, - current, "File must start with section."); + *err = bc_error_parser(BC_ERROR_CONFIG_PARSER, src, src_len, + current, "File must start with section."); break; case CONFIG_SECTION_START: @@ -91,9 +90,8 @@ bc_config_parse(const char *src, size_t src_len, bc_error_t **err) } if (c != '\r' && c != '\n') break; - if (err != NULL) - *err = bc_error_parser(BC_ERROR_CONFIG_PARSER, src, src_len, - current, "Section names can't have new lines."); + *err = bc_error_parser(BC_ERROR_CONFIG_PARSER, src, src_len, + current, "Section names can't have new lines."); break; case CONFIG_SECTION_KEY: @@ -105,15 +103,13 @@ bc_config_parse(const char *src, size_t src_len, bc_error_t **err) if (c != '\r' && c != '\n' && !is_last) break; // key without value, should we support it? - if (err != NULL) { - size_t end = is_last && c != '\n' && c != '\r' ? src_len : - current; - key = bc_strndup(src + start, end - start); - *err = bc_error_parser(BC_ERROR_CONFIG_PARSER, src, src_len, - current, "Key without value: %s.", key); - free(key); - key = NULL; - } + size_t end = is_last && c != '\n' && c != '\r' ? src_len : + current; + key = bc_strndup(src + start, end - start); + *err = bc_error_parser(BC_ERROR_CONFIG_PARSER, src, src_len, + current, "Key without value: %s.", key); + free(key); + key = NULL; break; case CONFIG_SECTION_VALUE_START: @@ -139,7 +135,7 @@ bc_config_parse(const char *src, size_t src_len, bc_error_t **err) } - if (err != NULL && *err != NULL) { + if (*err != NULL) { bc_config_free(rv); rv = NULL; break; |