Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/engine/eng_table.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | typedef struct st_engine_pile { | - | ||||||||||||||||||
6 | - | |||||||||||||||||||
7 | int nid; | - | ||||||||||||||||||
8 | - | |||||||||||||||||||
9 | struct stack_st_ENGINE *sk; | - | ||||||||||||||||||
10 | - | |||||||||||||||||||
11 | ENGINE *funct; | - | ||||||||||||||||||
12 | - | |||||||||||||||||||
13 | int uptodate; | - | ||||||||||||||||||
14 | } ENGINE_PILE; | - | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | struct lhash_st_ENGINE_PILE { int dummy; }; | - | ||||||||||||||||||
17 | - | |||||||||||||||||||
18 | - | |||||||||||||||||||
19 | struct st_engine_table { | - | ||||||||||||||||||
20 | struct lhash_st_ENGINE_PILE piles; | - | ||||||||||||||||||
21 | }; | - | ||||||||||||||||||
22 | - | |||||||||||||||||||
23 | typedef struct st_engine_pile_doall { | - | ||||||||||||||||||
24 | engine_table_doall_cb *cb; | - | ||||||||||||||||||
25 | void *arg; | - | ||||||||||||||||||
26 | } ENGINE_PILE_DOALL; | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | - | |||||||||||||||||||
29 | static unsigned int table_flags = 0; | - | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | - | |||||||||||||||||||
32 | unsigned int | - | ||||||||||||||||||
33 | ENGINE_get_table_flags(void) | - | ||||||||||||||||||
34 | { | - | ||||||||||||||||||
35 | return never executed: table_flags;return table_flags; never executed: return table_flags; | 0 | ||||||||||||||||||
36 | } | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | void | - | ||||||||||||||||||
39 | ENGINE_set_table_flags(unsigned int flags) | - | ||||||||||||||||||
40 | { | - | ||||||||||||||||||
41 | table_flags = flags; | - | ||||||||||||||||||
42 | } never executed: end of block | 0 | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | - | |||||||||||||||||||
45 | static unsigned long | - | ||||||||||||||||||
46 | engine_pile_hash(const ENGINE_PILE *c) | - | ||||||||||||||||||
47 | { | - | ||||||||||||||||||
48 | return never executed: c->nid;return c->nid; never executed: return c->nid; | 0 | ||||||||||||||||||
49 | } | - | ||||||||||||||||||
50 | - | |||||||||||||||||||
51 | static int | - | ||||||||||||||||||
52 | engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b) | - | ||||||||||||||||||
53 | { | - | ||||||||||||||||||
54 | return never executed: a->nid - b->nid;return a->nid - b->nid; never executed: return a->nid - b->nid; | 0 | ||||||||||||||||||
55 | } | - | ||||||||||||||||||
56 | static unsigned long engine_pile_LHASH_HASH(const void *arg) { const ENGINE_PILE *a = arg; return never executed: engine_pile_hash(a);return engine_pile_hash(a); never executed: }return engine_pile_hash(a); | 0 | ||||||||||||||||||
57 | static int engine_pile_LHASH_COMP(const void *arg1, const void *arg2) { const ENGINE_PILE *a = arg1; const ENGINE_PILE *b = arg2; return never executed: engine_pile_cmp(a,b);return engine_pile_cmp(a,b); never executed: }return engine_pile_cmp(a,b); | 0 | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | static int | - | ||||||||||||||||||
60 | int_table_check(ENGINE_TABLE **t, int create) | - | ||||||||||||||||||
61 | { | - | ||||||||||||||||||
62 | struct lhash_st_ENGINE_PILE *lh; | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | if (*
| 0 | ||||||||||||||||||
65 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
66 | if (!create
| 0 | ||||||||||||||||||
67 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
68 | if ((
| 0 | ||||||||||||||||||
69 | ((void *)0)
| 0 | ||||||||||||||||||
70 | ) | - | ||||||||||||||||||
71 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
72 | *t = (ENGINE_TABLE *)lh; | - | ||||||||||||||||||
73 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
74 | } | - | ||||||||||||||||||
75 | - | |||||||||||||||||||
76 | - | |||||||||||||||||||
77 | - | |||||||||||||||||||
78 | int | - | ||||||||||||||||||
79 | engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, | - | ||||||||||||||||||
80 | ENGINE *e, const int *nids, int num_nids, int setdefault) | - | ||||||||||||||||||
81 | { | - | ||||||||||||||||||
82 | int ret = 0, added = 0; | - | ||||||||||||||||||
83 | ENGINE_PILE tmplate, *fnd; | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | CRYPTO_lock(1|8,30,__FILE__,141); | - | ||||||||||||||||||
86 | if (!(*table)
| 0 | ||||||||||||||||||
87 | added = 1; never executed: added = 1; | 0 | ||||||||||||||||||
88 | if (!int_table_check(table, 1)
| 0 | ||||||||||||||||||
89 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
90 | if (added
| 0 | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | engine_cleanup_add_first(cleanup); never executed: engine_cleanup_add_first(cleanup); | 0 | ||||||||||||||||||
93 | while (num_nids--
| 0 | ||||||||||||||||||
94 | tmplate.nid = *nids; | - | ||||||||||||||||||
95 | fnd = ((ENGINE_PILE *)lh_retrieve(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), ((void*) (1 ? &tmplate : (ENGINE_PILE*)0)))); | - | ||||||||||||||||||
96 | if (!fnd
| 0 | ||||||||||||||||||
97 | fnd = malloc(sizeof(ENGINE_PILE)); | - | ||||||||||||||||||
98 | if (!fnd
| 0 | ||||||||||||||||||
99 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
100 | fnd->uptodate = 1; | - | ||||||||||||||||||
101 | fnd->nid = *nids; | - | ||||||||||||||||||
102 | fnd->sk = ((struct stack_st_ENGINE *)sk_new_null()); | - | ||||||||||||||||||
103 | if (!fnd->sk
| 0 | ||||||||||||||||||
104 | free(fnd); | - | ||||||||||||||||||
105 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
106 | } | - | ||||||||||||||||||
107 | fnd->funct = | - | ||||||||||||||||||
108 | ((void *)0) | - | ||||||||||||||||||
109 | ; | - | ||||||||||||||||||
110 | (void)((ENGINE_PILE *)lh_insert(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), ((void*) (1 ? fnd : (ENGINE_PILE*)0)))); | - | ||||||||||||||||||
111 | } never executed: end of block | 0 | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | (void)(ENGINE *)sk_delete_ptr(((_STACK*) (1 ? (fnd->sk) : (struct stack_st_ENGINE*)0)), ((void*) (1 ? (e) : (ENGINE*)0))); | - | ||||||||||||||||||
114 | - | |||||||||||||||||||
115 | if (!sk_push(((_STACK*) (1 ? (fnd->sk) : (struct stack_st_ENGINE*)0)), ((void*) (1 ? (e) : (ENGINE*)0)))
| 0 | ||||||||||||||||||
116 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | fnd->uptodate = 0; | - | ||||||||||||||||||
119 | if (setdefault
| 0 | ||||||||||||||||||
120 | if (!engine_unlocked_init(e)
| 0 | ||||||||||||||||||
121 | ERR_put_error(38,(0xfff),(109),__FILE__,175); | - | ||||||||||||||||||
122 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
123 | } | - | ||||||||||||||||||
124 | if (fnd->funct
| 0 | ||||||||||||||||||
125 | engine_unlocked_finish(fnd->funct, 0); never executed: engine_unlocked_finish(fnd->funct, 0); | 0 | ||||||||||||||||||
126 | fnd->funct = e; | - | ||||||||||||||||||
127 | fnd->uptodate = 1; | - | ||||||||||||||||||
128 | } never executed: end of block | 0 | ||||||||||||||||||
129 | nids++; | - | ||||||||||||||||||
130 | } never executed: end of block | 0 | ||||||||||||||||||
131 | ret = 1; | - | ||||||||||||||||||
132 | end: code before this statement never executed: end: | 0 | ||||||||||||||||||
133 | CRYPTO_lock(2|8,30,__FILE__,187); | - | ||||||||||||||||||
134 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||
135 | } | - | ||||||||||||||||||
136 | - | |||||||||||||||||||
137 | static void | - | ||||||||||||||||||
138 | int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e) | - | ||||||||||||||||||
139 | { | - | ||||||||||||||||||
140 | int n; | - | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | - | |||||||||||||||||||
143 | while ((
| 0 | ||||||||||||||||||
144 | (void)(ENGINE *)sk_delete(((_STACK*) (1 ? (pile->sk) : (struct stack_st_ENGINE*)0)), (n)); | - | ||||||||||||||||||
145 | pile->uptodate = 0; | - | ||||||||||||||||||
146 | } never executed: end of block | 0 | ||||||||||||||||||
147 | if (pile->funct == e
| 0 | ||||||||||||||||||
148 | engine_unlocked_finish(e, 0); | - | ||||||||||||||||||
149 | pile->funct = | - | ||||||||||||||||||
150 | ((void *)0) | - | ||||||||||||||||||
151 | ; | - | ||||||||||||||||||
152 | } never executed: end of block | 0 | ||||||||||||||||||
153 | } never executed: end of block | 0 | ||||||||||||||||||
154 | static void int_unregister_cb_LHASH_DOALL_ARG(void *arg1, void *arg2) { ENGINE_PILE *a = arg1; ENGINE *b = arg2; int_unregister_cb_doall_arg(a, b); } never executed: end of block | 0 | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | void | - | ||||||||||||||||||
157 | engine_table_unregister(ENGINE_TABLE **table, ENGINE *e) | - | ||||||||||||||||||
158 | { | - | ||||||||||||||||||
159 | CRYPTO_lock(1|8,30,__FILE__,211); | - | ||||||||||||||||||
160 | if (int_table_check(table, 0)
| 0 | ||||||||||||||||||
161 | lh_doall_arg(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), int_unregister_cb_LHASH_DOALL_ARG, ((void*) (1 ? e : (ENGINE*)0))) never executed: lh_doall_arg(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), int_unregister_cb_LHASH_DOALL_ARG, ((void*) (1 ? e : (ENGINE*)0))) ; | 0 | ||||||||||||||||||
162 | ; never executed: lh_doall_arg(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), int_unregister_cb_LHASH_DOALL_ARG, ((void*) (1 ? e : (ENGINE*)0))) ; | 0 | ||||||||||||||||||
163 | CRYPTO_lock(2|8,30,__FILE__,215); | - | ||||||||||||||||||
164 | } never executed: end of block | 0 | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | static void | - | ||||||||||||||||||
167 | int_cleanup_cb_doall(ENGINE_PILE *p) | - | ||||||||||||||||||
168 | { | - | ||||||||||||||||||
169 | sk_free(((_STACK*) (1 ? (p->sk) : (struct stack_st_ENGINE*)0))); | - | ||||||||||||||||||
170 | if (p->funct
| 0 | ||||||||||||||||||
171 | engine_unlocked_finish(p->funct, 0); never executed: engine_unlocked_finish(p->funct, 0); | 0 | ||||||||||||||||||
172 | free(p); | - | ||||||||||||||||||
173 | } never executed: end of block | 0 | ||||||||||||||||||
174 | static void int_cleanup_cb_LHASH_DOALL(void *arg) { ENGINE_PILE *a = arg; int_cleanup_cb_doall(a); } never executed: end of block | 0 | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | void | - | ||||||||||||||||||
177 | engine_table_cleanup(ENGINE_TABLE **table) | - | ||||||||||||||||||
178 | { | - | ||||||||||||||||||
179 | CRYPTO_lock(1|8,30,__FILE__,231); | - | ||||||||||||||||||
180 | if (*
| 0 | ||||||||||||||||||
181 | lh_doall(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), int_cleanup_cb_LHASH_DOALL) | - | ||||||||||||||||||
182 | ; | - | ||||||||||||||||||
183 | lh_free(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0)))); | - | ||||||||||||||||||
184 | *table = | - | ||||||||||||||||||
185 | ((void *)0) | - | ||||||||||||||||||
186 | ; | - | ||||||||||||||||||
187 | } never executed: end of block | 0 | ||||||||||||||||||
188 | CRYPTO_lock(2|8,30,__FILE__,238); | - | ||||||||||||||||||
189 | } never executed: end of block | 0 | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | - | |||||||||||||||||||
192 | - | |||||||||||||||||||
193 | ENGINE * | - | ||||||||||||||||||
194 | engine_table_select(ENGINE_TABLE **table, int nid) | - | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | - | |||||||||||||||||||
197 | - | |||||||||||||||||||
198 | - | |||||||||||||||||||
199 | { | - | ||||||||||||||||||
200 | ENGINE *ret = | - | ||||||||||||||||||
201 | ((void *)0) | - | ||||||||||||||||||
202 | ; | - | ||||||||||||||||||
203 | ENGINE_PILE tmplate, *fnd = | - | ||||||||||||||||||
204 | ((void *)0) | - | ||||||||||||||||||
205 | ; | - | ||||||||||||||||||
206 | int initres, loop = 0; | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | if (!(*table)
| 0-39539 | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | - | |||||||||||||||||||
211 | - | |||||||||||||||||||
212 | - | |||||||||||||||||||
213 | return executed 39539 times by 25 tests: return ((void *)0) ; Executed by:
executed 39539 times by 25 tests: return ((void *)0) ; Executed by:
| 39539 | ||||||||||||||||||
214 | ((void *)0) executed 39539 times by 25 tests: return ((void *)0) ; Executed by:
| 39539 | ||||||||||||||||||
215 | ; executed 39539 times by 25 tests: return ((void *)0) ; Executed by:
| 39539 | ||||||||||||||||||
216 | } | - | ||||||||||||||||||
217 | ERR_set_mark(); | - | ||||||||||||||||||
218 | CRYPTO_lock(1|8,30,__FILE__,262); | - | ||||||||||||||||||
219 | - | |||||||||||||||||||
220 | - | |||||||||||||||||||
221 | if (!int_table_check(table, 0)
| 0 | ||||||||||||||||||
222 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
223 | tmplate.nid = nid; | - | ||||||||||||||||||
224 | fnd = ((ENGINE_PILE *)lh_retrieve(((_LHASH *)((void*) (1 ? &(*table)->piles : (struct lhash_st_ENGINE_PILE*)0))), ((void*) (1 ? &tmplate : (ENGINE_PILE*)0)))); | - | ||||||||||||||||||
225 | if (!fnd
| 0 | ||||||||||||||||||
226 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
227 | if (fnd->funct
| 0 | ||||||||||||||||||
228 | - | |||||||||||||||||||
229 | - | |||||||||||||||||||
230 | - | |||||||||||||||||||
231 | - | |||||||||||||||||||
232 | ret = fnd->funct; | - | ||||||||||||||||||
233 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
234 | } | - | ||||||||||||||||||
235 | if (fnd->uptodate
| 0 | ||||||||||||||||||
236 | ret = fnd->funct; | - | ||||||||||||||||||
237 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | trynext: code before this statement never executed: trynext: | 0 | ||||||||||||||||||
240 | ret = ((ENGINE *)sk_value(((_STACK*) (1 ? (fnd->sk) : (struct stack_st_ENGINE*)0)), (loop++))); | - | ||||||||||||||||||
241 | if (!ret
| 0 | ||||||||||||||||||
242 | - | |||||||||||||||||||
243 | - | |||||||||||||||||||
244 | - | |||||||||||||||||||
245 | - | |||||||||||||||||||
246 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
247 | } | - | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | if ((
| 0 | ||||||||||||||||||
250 | initres = engine_unlocked_init(ret); never executed: initres = engine_unlocked_init(ret); | 0 | ||||||||||||||||||
251 | else | - | ||||||||||||||||||
252 | initres = 0; never executed: initres = 0; | 0 | ||||||||||||||||||
253 | if (initres
| 0 | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | if ((
| 0 | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | if (fnd->funct
| 0 | ||||||||||||||||||
258 | engine_unlocked_finish(fnd->funct, 0); never executed: engine_unlocked_finish(fnd->funct, 0); | 0 | ||||||||||||||||||
259 | fnd->funct = ret; | - | ||||||||||||||||||
260 | - | |||||||||||||||||||
261 | - | |||||||||||||||||||
262 | - | |||||||||||||||||||
263 | - | |||||||||||||||||||
264 | } never executed: end of block | 0 | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | - | |||||||||||||||||||
267 | - | |||||||||||||||||||
268 | - | |||||||||||||||||||
269 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
270 | } | - | ||||||||||||||||||
271 | goto never executed: trynext;goto trynext; never executed: goto trynext; | 0 | ||||||||||||||||||
272 | end: | - | ||||||||||||||||||
273 | - | |||||||||||||||||||
274 | - | |||||||||||||||||||
275 | if (fnd
| 0 | ||||||||||||||||||
276 | fnd->uptodate = 1; never executed: fnd->uptodate = 1; | 0 | ||||||||||||||||||
277 | CRYPTO_lock(2|8,30,__FILE__,329); | - | ||||||||||||||||||
278 | - | |||||||||||||||||||
279 | - | |||||||||||||||||||
280 | ERR_pop_to_mark(); | - | ||||||||||||||||||
281 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||
282 | } | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | - | |||||||||||||||||||
285 | - | |||||||||||||||||||
286 | static void | - | ||||||||||||||||||
287 | int_cb_doall_arg(ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall) | - | ||||||||||||||||||
288 | { | - | ||||||||||||||||||
289 | dall->cb(pile->nid, pile->sk, pile->funct, dall->arg); | - | ||||||||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||||||||
291 | static void int_cb_LHASH_DOALL_ARG(void *arg1, void *arg2) { ENGINE_PILE *a = arg1; ENGINE_PILE_DOALL *b = arg2; int_cb_doall_arg(a, b); } never executed: end of block | 0 | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | void | - | ||||||||||||||||||
294 | engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, void *arg) | - | ||||||||||||||||||
295 | { | - | ||||||||||||||||||
296 | ENGINE_PILE_DOALL dall; | - | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | dall.cb = cb; | - | ||||||||||||||||||
299 | dall.arg = arg; | - | ||||||||||||||||||
300 | lh_doall_arg(((_LHASH *)((void*) (1 ? &table->piles : (struct lhash_st_ENGINE_PILE*)0))), int_cb_LHASH_DOALL_ARG, ((void*) (1 ? &dall : (ENGINE_PILE_DOALL*)0))) | - | ||||||||||||||||||
301 | ; | - | ||||||||||||||||||
302 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
Switch to Source code | Preprocessed file |