diff options
author | szengel <szengel@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-07-23 14:35:26 +0000 |
---|---|---|
committer | szengel <szengel@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-07-23 14:35:26 +0000 |
commit | 6f018f444a228a923aa853853d91382cccfed0cc (patch) | |
tree | aa0e629a5ecb903a199569765da31c3d0e21203e /src/regex/regex.c | |
parent | 65caa36d2c352d5c930b7326959d5a615516554e (diff) |
Fixed coverty issues
git-svn-id: https://gnunet.org/svn/gnunet@22847 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/regex/regex.c')
-rw-r--r-- | src/regex/regex.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/regex/regex.c b/src/regex/regex.c index a17d5a57f6..2152167dc3 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c @@ -1600,7 +1600,7 @@ nfa_fragment_create (struct GNUNET_REGEX_State *start, n->start = NULL; n->end = NULL; - if (NULL == start && NULL == end) + if (NULL == start || NULL == end) return n; automaton_add_state (n, end); @@ -1813,7 +1813,7 @@ nfa_add_concatenation (struct GNUNET_REGEX_Context *ctx) { struct GNUNET_REGEX_Automaton *a; struct GNUNET_REGEX_Automaton *b; - struct GNUNET_REGEX_Automaton *new; + struct GNUNET_REGEX_Automaton *new_nfa; b = ctx->stack_tail; GNUNET_assert (NULL != b); @@ -1826,15 +1826,15 @@ nfa_add_concatenation (struct GNUNET_REGEX_Context *ctx) a->end->accepting = 0; b->end->accepting = 1; - new = nfa_fragment_create (NULL, NULL); - nfa_add_states (new, a->states_head, a->states_tail); - nfa_add_states (new, b->states_head, b->states_tail); - new->start = a->start; - new->end = b->end; + new_nfa = nfa_fragment_create (NULL, NULL); + nfa_add_states (new_nfa, a->states_head, a->states_tail); + nfa_add_states (new_nfa, b->states_head, b->states_tail); + new_nfa->start = a->start; + new_nfa->end = b->end; automaton_fragment_clear (a); automaton_fragment_clear (b); - GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); + GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa); } @@ -1847,12 +1847,11 @@ static void nfa_add_star_op (struct GNUNET_REGEX_Context *ctx) { struct GNUNET_REGEX_Automaton *a; - struct GNUNET_REGEX_Automaton *new; + struct GNUNET_REGEX_Automaton *new_nfa; struct GNUNET_REGEX_State *start; struct GNUNET_REGEX_State *end; a = ctx->stack_tail; - GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a); if (NULL == a) { @@ -1861,6 +1860,8 @@ nfa_add_star_op (struct GNUNET_REGEX_Context *ctx) return; } + GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a); + start = nfa_state_create (ctx, 0); end = nfa_state_create (ctx, 1); @@ -1872,11 +1873,11 @@ nfa_add_star_op (struct GNUNET_REGEX_Context *ctx) a->end->accepting = 0; end->accepting = 1; - new = nfa_fragment_create (start, end); - nfa_add_states (new, a->states_head, a->states_tail); + new_nfa = nfa_fragment_create (start, end); + nfa_add_states (new_nfa, a->states_head, a->states_tail); automaton_fragment_clear (a); - GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); + GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa); } @@ -1908,13 +1909,12 @@ static void nfa_add_question_op (struct GNUNET_REGEX_Context *ctx) { struct GNUNET_REGEX_Automaton *a; - struct GNUNET_REGEX_Automaton *new; + struct GNUNET_REGEX_Automaton *new_nfa; struct GNUNET_REGEX_State *start; struct GNUNET_REGEX_State *end; a = ctx->stack_tail; - GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a); - + if (NULL == a) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1922,6 +1922,8 @@ nfa_add_question_op (struct GNUNET_REGEX_Context *ctx) return; } + GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a); + start = nfa_state_create (ctx, 0); end = nfa_state_create (ctx, 1); @@ -1931,11 +1933,11 @@ nfa_add_question_op (struct GNUNET_REGEX_Context *ctx) a->end->accepting = 0; - new = nfa_fragment_create (start, end); - nfa_add_states (new, a->states_head, a->states_tail); + new_nfa = nfa_fragment_create (start, end); + nfa_add_states (new_nfa, a->states_head, a->states_tail); automaton_fragment_clear (a); - GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); + GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa); } @@ -1950,7 +1952,7 @@ nfa_add_alternation (struct GNUNET_REGEX_Context *ctx) { struct GNUNET_REGEX_Automaton *a; struct GNUNET_REGEX_Automaton *b; - struct GNUNET_REGEX_Automaton *new; + struct GNUNET_REGEX_Automaton *new_nfa; struct GNUNET_REGEX_State *start; struct GNUNET_REGEX_State *end; @@ -1973,13 +1975,13 @@ nfa_add_alternation (struct GNUNET_REGEX_Context *ctx) b->end->accepting = 0; end->accepting = 1; - new = nfa_fragment_create (start, end); - nfa_add_states (new, a->states_head, a->states_tail); - nfa_add_states (new, b->states_head, b->states_tail); + new_nfa = nfa_fragment_create (start, end); + nfa_add_states (new_nfa, a->states_head, a->states_tail); + nfa_add_states (new_nfa, b->states_head, b->states_tail); automaton_fragment_clear (a); automaton_fragment_clear (b); - GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); + GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa); } @@ -2137,6 +2139,7 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len) case 92: /* escape: \ */ regexp++; count++; + /* fall through! */ default: if (atomcount > 1) { |