From 9c2c9d805d92c846f472f994efb50e1ad2fb60b6 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 7 Feb 2018 11:57:16 +0100 Subject: Use assertions for things that should never happen --- src/sp_var_parser.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/sp_var_parser.c') diff --git a/src/sp_var_parser.c b/src/sp_var_parser.c index 8e5bdb1..b57386e 100644 --- a/src/sp_var_parser.c +++ b/src/sp_var_parser.c @@ -24,9 +24,8 @@ static bool is_var_name_valid(const char *name) { static sp_pcre *regexp_const = NULL; static sp_pcre *regexp_var = NULL; - if (!name) { - return false; - } + assert(name); + if (NULL == regexp_var || NULL == regexp_const) { regexp_var = sp_pcre_compile(REGEXP_VAR); regexp_const = sp_pcre_compile(REGEXP_CONST); @@ -46,9 +45,8 @@ static int create_var(sp_tree *tree, const char *restrict value, const char *restrict idx) { sp_tree *var_node = NULL; - if (!tree) { - return -1; - } + assert(tree); + if (tree->next == NULL && tree->type == UNDEFINED) { var_node = tree; } else { -- cgit v1.3