aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-07-23 14:35:26 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-07-23 14:35:26 +0000
commit427082beae826e666335621c1aff95524a0e964f (patch)
treeaa0e629a5ecb903a199569765da31c3d0e21203e /src/regex
parent8d85db2c476afef7cd312e38ea91f90ce5e76898 (diff)
downloadgnunet-427082beae826e666335621c1aff95524a0e964f.tar.gz
gnunet-427082beae826e666335621c1aff95524a0e964f.zip
Fixed coverty issues
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/regex.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/regex/regex.c b/src/regex/regex.c
index a17d5a57f..2152167dc 100644
--- a/src/regex/regex.c
+++ b/src/regex/regex.c
@@ -1600,7 +1600,7 @@ nfa_fragment_create (struct GNUNET_REGEX_State *start,
1600 n->start = NULL; 1600 n->start = NULL;
1601 n->end = NULL; 1601 n->end = NULL;
1602 1602
1603 if (NULL == start && NULL == end) 1603 if (NULL == start || NULL == end)
1604 return n; 1604 return n;
1605 1605
1606 automaton_add_state (n, end); 1606 automaton_add_state (n, end);
@@ -1813,7 +1813,7 @@ nfa_add_concatenation (struct GNUNET_REGEX_Context *ctx)
1813{ 1813{
1814 struct GNUNET_REGEX_Automaton *a; 1814 struct GNUNET_REGEX_Automaton *a;
1815 struct GNUNET_REGEX_Automaton *b; 1815 struct GNUNET_REGEX_Automaton *b;
1816 struct GNUNET_REGEX_Automaton *new; 1816 struct GNUNET_REGEX_Automaton *new_nfa;
1817 1817
1818 b = ctx->stack_tail; 1818 b = ctx->stack_tail;
1819 GNUNET_assert (NULL != b); 1819 GNUNET_assert (NULL != b);
@@ -1826,15 +1826,15 @@ nfa_add_concatenation (struct GNUNET_REGEX_Context *ctx)
1826 a->end->accepting = 0; 1826 a->end->accepting = 0;
1827 b->end->accepting = 1; 1827 b->end->accepting = 1;
1828 1828
1829 new = nfa_fragment_create (NULL, NULL); 1829 new_nfa = nfa_fragment_create (NULL, NULL);
1830 nfa_add_states (new, a->states_head, a->states_tail); 1830 nfa_add_states (new_nfa, a->states_head, a->states_tail);
1831 nfa_add_states (new, b->states_head, b->states_tail); 1831 nfa_add_states (new_nfa, b->states_head, b->states_tail);
1832 new->start = a->start; 1832 new_nfa->start = a->start;
1833 new->end = b->end; 1833 new_nfa->end = b->end;
1834 automaton_fragment_clear (a); 1834 automaton_fragment_clear (a);
1835 automaton_fragment_clear (b); 1835 automaton_fragment_clear (b);
1836 1836
1837 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); 1837 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa);
1838} 1838}
1839 1839
1840 1840
@@ -1847,12 +1847,11 @@ static void
1847nfa_add_star_op (struct GNUNET_REGEX_Context *ctx) 1847nfa_add_star_op (struct GNUNET_REGEX_Context *ctx)
1848{ 1848{
1849 struct GNUNET_REGEX_Automaton *a; 1849 struct GNUNET_REGEX_Automaton *a;
1850 struct GNUNET_REGEX_Automaton *new; 1850 struct GNUNET_REGEX_Automaton *new_nfa;
1851 struct GNUNET_REGEX_State *start; 1851 struct GNUNET_REGEX_State *start;
1852 struct GNUNET_REGEX_State *end; 1852 struct GNUNET_REGEX_State *end;
1853 1853
1854 a = ctx->stack_tail; 1854 a = ctx->stack_tail;
1855 GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a);
1856 1855
1857 if (NULL == a) 1856 if (NULL == a)
1858 { 1857 {
@@ -1861,6 +1860,8 @@ nfa_add_star_op (struct GNUNET_REGEX_Context *ctx)
1861 return; 1860 return;
1862 } 1861 }
1863 1862
1863 GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a);
1864
1864 start = nfa_state_create (ctx, 0); 1865 start = nfa_state_create (ctx, 0);
1865 end = nfa_state_create (ctx, 1); 1866 end = nfa_state_create (ctx, 1);
1866 1867
@@ -1872,11 +1873,11 @@ nfa_add_star_op (struct GNUNET_REGEX_Context *ctx)
1872 a->end->accepting = 0; 1873 a->end->accepting = 0;
1873 end->accepting = 1; 1874 end->accepting = 1;
1874 1875
1875 new = nfa_fragment_create (start, end); 1876 new_nfa = nfa_fragment_create (start, end);
1876 nfa_add_states (new, a->states_head, a->states_tail); 1877 nfa_add_states (new_nfa, a->states_head, a->states_tail);
1877 automaton_fragment_clear (a); 1878 automaton_fragment_clear (a);
1878 1879
1879 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); 1880 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa);
1880} 1881}
1881 1882
1882 1883
@@ -1908,13 +1909,12 @@ static void
1908nfa_add_question_op (struct GNUNET_REGEX_Context *ctx) 1909nfa_add_question_op (struct GNUNET_REGEX_Context *ctx)
1909{ 1910{
1910 struct GNUNET_REGEX_Automaton *a; 1911 struct GNUNET_REGEX_Automaton *a;
1911 struct GNUNET_REGEX_Automaton *new; 1912 struct GNUNET_REGEX_Automaton *new_nfa;
1912 struct GNUNET_REGEX_State *start; 1913 struct GNUNET_REGEX_State *start;
1913 struct GNUNET_REGEX_State *end; 1914 struct GNUNET_REGEX_State *end;
1914 1915
1915 a = ctx->stack_tail; 1916 a = ctx->stack_tail;
1916 GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a); 1917
1917
1918 if (NULL == a) 1918 if (NULL == a)
1919 { 1919 {
1920 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1920 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1922,6 +1922,8 @@ nfa_add_question_op (struct GNUNET_REGEX_Context *ctx)
1922 return; 1922 return;
1923 } 1923 }
1924 1924
1925 GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a);
1926
1925 start = nfa_state_create (ctx, 0); 1927 start = nfa_state_create (ctx, 0);
1926 end = nfa_state_create (ctx, 1); 1928 end = nfa_state_create (ctx, 1);
1927 1929
@@ -1931,11 +1933,11 @@ nfa_add_question_op (struct GNUNET_REGEX_Context *ctx)
1931 1933
1932 a->end->accepting = 0; 1934 a->end->accepting = 0;
1933 1935
1934 new = nfa_fragment_create (start, end); 1936 new_nfa = nfa_fragment_create (start, end);
1935 nfa_add_states (new, a->states_head, a->states_tail); 1937 nfa_add_states (new_nfa, a->states_head, a->states_tail);
1936 automaton_fragment_clear (a); 1938 automaton_fragment_clear (a);
1937 1939
1938 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); 1940 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa);
1939} 1941}
1940 1942
1941 1943
@@ -1950,7 +1952,7 @@ nfa_add_alternation (struct GNUNET_REGEX_Context *ctx)
1950{ 1952{
1951 struct GNUNET_REGEX_Automaton *a; 1953 struct GNUNET_REGEX_Automaton *a;
1952 struct GNUNET_REGEX_Automaton *b; 1954 struct GNUNET_REGEX_Automaton *b;
1953 struct GNUNET_REGEX_Automaton *new; 1955 struct GNUNET_REGEX_Automaton *new_nfa;
1954 struct GNUNET_REGEX_State *start; 1956 struct GNUNET_REGEX_State *start;
1955 struct GNUNET_REGEX_State *end; 1957 struct GNUNET_REGEX_State *end;
1956 1958
@@ -1973,13 +1975,13 @@ nfa_add_alternation (struct GNUNET_REGEX_Context *ctx)
1973 b->end->accepting = 0; 1975 b->end->accepting = 0;
1974 end->accepting = 1; 1976 end->accepting = 1;
1975 1977
1976 new = nfa_fragment_create (start, end); 1978 new_nfa = nfa_fragment_create (start, end);
1977 nfa_add_states (new, a->states_head, a->states_tail); 1979 nfa_add_states (new_nfa, a->states_head, a->states_tail);
1978 nfa_add_states (new, b->states_head, b->states_tail); 1980 nfa_add_states (new_nfa, b->states_head, b->states_tail);
1979 automaton_fragment_clear (a); 1981 automaton_fragment_clear (a);
1980 automaton_fragment_clear (b); 1982 automaton_fragment_clear (b);
1981 1983
1982 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new); 1984 GNUNET_CONTAINER_DLL_insert_tail (ctx->stack_head, ctx->stack_tail, new_nfa);
1983} 1985}
1984 1986
1985 1987
@@ -2137,6 +2139,7 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len)
2137 case 92: /* escape: \ */ 2139 case 92: /* escape: \ */
2138 regexp++; 2140 regexp++;
2139 count++; 2141 count++;
2142 /* fall through! */
2140 default: 2143 default:
2141 if (atomcount > 1) 2144 if (atomcount > 1)
2142 { 2145 {