diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-17 14:32:05 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-17 14:32:05 +0000 |
commit | 0023bacc0565ad444e8facefd1db9b622a8e07d4 (patch) | |
tree | 7ea369f429480af3b4e929839b5b487aa04064de | |
parent | 290598582085e0b442caac7a94dcc6e940118e84 (diff) | |
download | gnunet-0023bacc0565ad444e8facefd1db9b622a8e07d4.tar.gz gnunet-0023bacc0565ad444e8facefd1db9b622a8e07d4.zip |
coverity
-rw-r--r-- | src/regex/regex.c | 17 | ||||
-rw-r--r-- | src/regex/test_regex_eval_api.c | 17 | ||||
-rw-r--r-- | src/regex/test_regex_graph_api.c | 11 |
3 files changed, 30 insertions, 15 deletions
diff --git a/src/regex/regex.c b/src/regex/regex.c index 4c0f28851..d659cb949 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c | |||
@@ -513,11 +513,12 @@ GNUNET_REGEX_automaton_traverse (const struct GNUNET_REGEX_Automaton *a, | |||
513 | { | 513 | { |
514 | unsigned int count; | 514 | unsigned int count; |
515 | struct GNUNET_REGEX_State *s; | 515 | struct GNUNET_REGEX_State *s; |
516 | int marks[a->state_count]; | ||
517 | 516 | ||
518 | if (NULL == a || 0 == a->state_count) | 517 | if (NULL == a || 0 == a->state_count) |
519 | return; | 518 | return; |
520 | 519 | ||
520 | int marks[a->state_count]; | ||
521 | |||
521 | for (count = 0, s = a->states_head; NULL != s && count < a->state_count; | 522 | for (count = 0, s = a->states_head; NULL != s && count < a->state_count; |
522 | s = s->next, count++) | 523 | s = s->next, count++) |
523 | { | 524 | { |
@@ -1206,6 +1207,13 @@ automaton_create_proofs_simplify (char *R_last_ij, char *R_last_ik, | |||
1206 | static void | 1207 | static void |
1207 | automaton_create_proofs (struct GNUNET_REGEX_Automaton *a) | 1208 | automaton_create_proofs (struct GNUNET_REGEX_Automaton *a) |
1208 | { | 1209 | { |
1210 | if (NULL == a) | ||
1211 | { | ||
1212 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1213 | "Could not create proofs, automaton was NULL\n"); | ||
1214 | return; | ||
1215 | } | ||
1216 | |||
1209 | unsigned int n = a->state_count; | 1217 | unsigned int n = a->state_count; |
1210 | struct GNUNET_REGEX_State *states[n]; | 1218 | struct GNUNET_REGEX_State *states[n]; |
1211 | char *R_last[n][n]; | 1219 | char *R_last[n][n]; |
@@ -1217,13 +1225,6 @@ automaton_create_proofs (struct GNUNET_REGEX_Automaton *a) | |||
1217 | unsigned int j; | 1225 | unsigned int j; |
1218 | unsigned int k; | 1226 | unsigned int k; |
1219 | 1227 | ||
1220 | if (NULL == a) | ||
1221 | { | ||
1222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1223 | "Could not create proofs, automaton was NULL\n"); | ||
1224 | return; | ||
1225 | } | ||
1226 | |||
1227 | /* create depth-first numbering of the states, initializes 'state' */ | 1228 | /* create depth-first numbering of the states, initializes 'state' */ |
1228 | GNUNET_REGEX_automaton_traverse (a, a->start, NULL, NULL, &number_states, | 1229 | GNUNET_REGEX_automaton_traverse (a, a->start, NULL, NULL, &number_states, |
1229 | states); | 1230 | states); |
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c index 7538a25d8..35eef6d29 100644 --- a/src/regex/test_regex_eval_api.c +++ b/src/regex/test_regex_eval_api.c | |||
@@ -71,7 +71,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
71 | regmatch_t matchptr[1]; | 71 | regmatch_t matchptr[1]; |
72 | char error[200]; | 72 | char error[200]; |
73 | int result; | 73 | int result; |
74 | char *canonical_regex; | 74 | char *canonical_regex = NULL; |
75 | 75 | ||
76 | /* At least one string is needed for matching */ | 76 | /* At least one string is needed for matching */ |
77 | GNUNET_assert (str_count > 0); | 77 | GNUNET_assert (str_count > 0); |
@@ -96,7 +96,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
96 | if (NULL == dfa) | 96 | if (NULL == dfa) |
97 | { | 97 | { |
98 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); | 98 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); |
99 | return -1; | 99 | GNUNET_free (matching_str); |
100 | goto error; | ||
100 | } | 101 | } |
101 | 102 | ||
102 | eval = GNUNET_REGEX_eval (dfa, matching_str); | 103 | eval = GNUNET_REGEX_eval (dfa, matching_str); |
@@ -109,7 +110,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
109 | { | 110 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
111 | "Could not compile regex using regcomp: %s\n", rand_rx); | 112 | "Could not compile regex using regcomp: %s\n", rand_rx); |
112 | return -1; | 113 | goto error; |
113 | } | 114 | } |
114 | 115 | ||
115 | eval_check = regexec (&rx, matching_str, 1, matchptr, 0); | 116 | eval_check = regexec (&rx, matching_str, 1, matchptr, 0); |
@@ -127,7 +128,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
127 | if (NULL == dfa) | 128 | if (NULL == dfa) |
128 | { | 129 | { |
129 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); | 130 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); |
130 | return -1; | 131 | goto error; |
131 | } | 132 | } |
132 | 133 | ||
133 | eval_canonical = GNUNET_REGEX_eval (dfa, matching_str); | 134 | eval_canonical = GNUNET_REGEX_eval (dfa, matching_str); |
@@ -138,7 +139,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
139 | "Could not compile regex using regcomp: %s\n", | 140 | "Could not compile regex using regcomp: %s\n", |
140 | canonical_regex); | 141 | canonical_regex); |
141 | return -1; | 142 | goto error; |
142 | } | 143 | } |
143 | 144 | ||
144 | eval_canonical_check = regexec (&rx, matching_str, 1, matchptr, 0); | 145 | eval_canonical_check = regexec (&rx, matching_str, 1, matchptr, 0); |
@@ -169,6 +170,12 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
169 | GNUNET_free (canonical_regex); | 170 | GNUNET_free (canonical_regex); |
170 | 171 | ||
171 | return result; | 172 | return result; |
173 | |||
174 | error: | ||
175 | GNUNET_free_non_null (matching_str); | ||
176 | GNUNET_free_non_null (rand_rx); | ||
177 | GNUNET_free_non_null (canonical_regex); | ||
178 | return -1; | ||
172 | } | 179 | } |
173 | 180 | ||
174 | /** | 181 | /** |
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c index 9e8e1fb16..b20a6d07f 100644 --- a/src/regex/test_regex_graph_api.c +++ b/src/regex/test_regex_graph_api.c | |||
@@ -48,7 +48,7 @@ filecheck (const char *filename) | |||
48 | if (NULL == fp) | 48 | if (NULL == fp) |
49 | { | 49 | { |
50 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename); | 50 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename); |
51 | error++; | 51 | return ++error; |
52 | } | 52 | } |
53 | 53 | ||
54 | fseek (fp, 0L, SEEK_END); | 54 | fseek (fp, 0L, SEEK_END); |
@@ -62,7 +62,14 @@ filecheck (const char *filename) | |||
62 | error += fclose (fp); | 62 | error += fclose (fp); |
63 | 63 | ||
64 | if (!KEEP_FILES) | 64 | if (!KEEP_FILES) |
65 | unlink (filename); | 65 | { |
66 | if (0 != unlink (filename)) | ||
67 | { | ||
68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not remove temp files (%s)\n", | ||
69 | filename); | ||
70 | } | ||
71 | } | ||
72 | |||
66 | 73 | ||
67 | return error; | 74 | return error; |
68 | } | 75 | } |