| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/stack/stack.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | static const int min_nodes = 4; | - | ||||||||||||||||||||||||
| 8 | static const int max_nodes = | - | ||||||||||||||||||||||||
| 9 | (18446744073709551615UL) | - | ||||||||||||||||||||||||
| 10 | / sizeof(void *) < 0x7fffffff | - | ||||||||||||||||||||||||
| 11 | ? (int)( | - | ||||||||||||||||||||||||
| 12 | (18446744073709551615UL) | - | ||||||||||||||||||||||||
| 13 | / sizeof(void *)) | - | ||||||||||||||||||||||||
| 14 | : 0x7fffffff; | - | ||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | struct stack_st { | - | ||||||||||||||||||||||||
| 17 | int num; | - | ||||||||||||||||||||||||
| 18 | const void **data; | - | ||||||||||||||||||||||||
| 19 | int sorted; | - | ||||||||||||||||||||||||
| 20 | int num_alloc; | - | ||||||||||||||||||||||||
| 21 | OPENSSL_sk_compfunc comp; | - | ||||||||||||||||||||||||
| 22 | }; | - | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, OPENSSL_sk_compfunc c) | - | ||||||||||||||||||||||||
| 25 | { | - | ||||||||||||||||||||||||
| 26 | OPENSSL_sk_compfunc old = sk->comp; | - | ||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | if (sk->comp != c
| 0-18503 | ||||||||||||||||||||||||
| 29 | sk->sorted = 0; executed 18503 times by 1 test: sk->sorted = 0;Executed by:
| 18503 | ||||||||||||||||||||||||
| 30 | sk->comp = c; | - | ||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | return executed 18503 times by 1 test: old;return old;Executed by:
executed 18503 times by 1 test: return old;Executed by:
| 18503 | ||||||||||||||||||||||||
| 33 | } | - | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *sk) | - | ||||||||||||||||||||||||
| 36 | { | - | ||||||||||||||||||||||||
| 37 | OPENSSL_STACK *ret; | - | ||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||
| 39 | if ((
| 0-32389 | ||||||||||||||||||||||||
| 40 | ((void *)0)
| 0-32389 | ||||||||||||||||||||||||
| 41 | ) { | - | ||||||||||||||||||||||||
| 42 | ERR_put_error(15,(128),((1|64)),__FILE__,50); | - | ||||||||||||||||||||||||
| 43 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 44 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 45 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 46 | } | - | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | *ret = *sk; | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | if (sk->num == 0
| 247-32142 | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | ret->data = | - | ||||||||||||||||||||||||
| 54 | ((void *)0) | - | ||||||||||||||||||||||||
| 55 | ; | - | ||||||||||||||||||||||||
| 56 | ret->num_alloc = 0; | - | ||||||||||||||||||||||||
| 57 | return executed 247 times by 1 test: ret;return ret;Executed by:
executed 247 times by 1 test: return ret;Executed by:
| 247 | ||||||||||||||||||||||||
| 58 | } | - | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | if ((
| 0-32142 | ||||||||||||||||||||||||
| 61 | ((void *)0)
| 0-32142 | ||||||||||||||||||||||||
| 62 | ) | - | ||||||||||||||||||||||||
| 63 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 64 | memcpy(ret->data, sk->data, sizeof(void *) * sk->num); | - | ||||||||||||||||||||||||
| 65 | return executed 32142 times by 1 test: ret;return ret;Executed by:
executed 32142 times by 1 test: return ret;Executed by:
| 32142 | ||||||||||||||||||||||||
| 66 | err: | - | ||||||||||||||||||||||||
| 67 | OPENSSL_sk_free(ret); | - | ||||||||||||||||||||||||
| 68 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 69 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 70 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 71 | } | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, | - | ||||||||||||||||||||||||
| 74 | OPENSSL_sk_copyfunc copy_func, | - | ||||||||||||||||||||||||
| 75 | OPENSSL_sk_freefunc free_func) | - | ||||||||||||||||||||||||
| 76 | { | - | ||||||||||||||||||||||||
| 77 | OPENSSL_STACK *ret; | - | ||||||||||||||||||||||||
| 78 | int i; | - | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | if ((
| 0-50 | ||||||||||||||||||||||||
| 81 | ((void *)0)
| 0-50 | ||||||||||||||||||||||||
| 82 | ) { | - | ||||||||||||||||||||||||
| 83 | ERR_put_error(15,(127),((1|64)),__FILE__,81); | - | ||||||||||||||||||||||||
| 84 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 85 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 86 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 87 | } | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | *ret = *sk; | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | if (sk->num == 0
| 0-50 | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | ret->data = | - | ||||||||||||||||||||||||
| 95 | ((void *)0) | - | ||||||||||||||||||||||||
| 96 | ; | - | ||||||||||||||||||||||||
| 97 | ret->num_alloc = 0; | - | ||||||||||||||||||||||||
| 98 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 99 | } | - | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | ret->num_alloc = sk->num > min_nodes
| 1-49 | ||||||||||||||||||||||||
| 102 | ret->data = CRYPTO_zalloc(sizeof(*ret->data) * ret->num_alloc, __FILE__, 96); | - | ||||||||||||||||||||||||
| 103 | if (ret->data ==
| 0-50 | ||||||||||||||||||||||||
| 104 | ((void *)0)
| 0-50 | ||||||||||||||||||||||||
| 105 | ) { | - | ||||||||||||||||||||||||
| 106 | CRYPTO_free(ret, __FILE__, 98); | - | ||||||||||||||||||||||||
| 107 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 108 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 109 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 110 | } | - | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | for (i = 0; i < ret->num
| 50-59 | ||||||||||||||||||||||||
| 113 | if (sk->data[i] ==
| 0-59 | ||||||||||||||||||||||||
| 114 | ((void *)0)
| 0-59 | ||||||||||||||||||||||||
| 115 | ) | - | ||||||||||||||||||||||||
| 116 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 117 | if ((
| 0-59 | ||||||||||||||||||||||||
| 118 | ((void *)0)
| 0-59 | ||||||||||||||||||||||||
| 119 | ) { | - | ||||||||||||||||||||||||
| 120 | while (--
| 0 | ||||||||||||||||||||||||
| 121 | if (ret->data[i] !=
| 0 | ||||||||||||||||||||||||
| 122 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 123 | ) | - | ||||||||||||||||||||||||
| 124 | free_func((void *)ret->data[i]); never executed: free_func((void *)ret->data[i]); | 0 | ||||||||||||||||||||||||
| 125 | OPENSSL_sk_free(ret); | - | ||||||||||||||||||||||||
| 126 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 127 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 128 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 129 | } | - | ||||||||||||||||||||||||
| 130 | } executed 59 times by 1 test: end of blockExecuted by:
| 59 | ||||||||||||||||||||||||
| 131 | return executed 50 times by 1 test: ret;return ret;Executed by:
executed 50 times by 1 test: return ret;Executed by:
| 50 | ||||||||||||||||||||||||
| 132 | } | - | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | OPENSSL_STACK *OPENSSL_sk_new_null(void) | - | ||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||
| 136 | return executed 1046102 times by 1 test: OPENSSL_sk_new_reserve(return OPENSSL_sk_new_reserve( ((void *)0) , 0);Executed by:
executed 1046102 times by 1 test: return OPENSSL_sk_new_reserve( ((void *)0) , 0);Executed by:
| 1046102 | ||||||||||||||||||||||||
| 137 | ((void *)0) executed 1046102 times by 1 test: return OPENSSL_sk_new_reserve( ((void *)0) , 0);Executed by:
| 1046102 | ||||||||||||||||||||||||
| 138 | , 0); executed 1046102 times by 1 test: return OPENSSL_sk_new_reserve( ((void *)0) , 0);Executed by:
| 1046102 | ||||||||||||||||||||||||
| 139 | } | - | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc c) | - | ||||||||||||||||||||||||
| 142 | { | - | ||||||||||||||||||||||||
| 143 | return executed 12314 times by 1 test: OPENSSL_sk_new_reserve(c, 0);return OPENSSL_sk_new_reserve(c, 0);Executed by:
executed 12314 times by 1 test: return OPENSSL_sk_new_reserve(c, 0);Executed by:
| 12314 | ||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||
| 145 | static inline int compute_growth(int target, int current) | - | ||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||
| 147 | const int limit = (max_nodes / 3) * 2 + (max_nodes % 3
| 0-228580 | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | while (current < target
| 228580 | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | if (current >= max_nodes
| 0-228580 | ||||||||||||||||||||||||
| 152 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | current = current < limit
| 0-228580 | ||||||||||||||||||||||||
| 156 | } executed 228580 times by 1 test: end of blockExecuted by:
| 228580 | ||||||||||||||||||||||||
| 157 | return executed 228580 times by 1 test: current;return current;Executed by:
executed 228580 times by 1 test: return current;Executed by:
| 228580 | ||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | static int sk_reserve(OPENSSL_STACK *st, int n, int exact) | - | ||||||||||||||||||||||||
| 162 | { | - | ||||||||||||||||||||||||
| 163 | const void **tmpdata; | - | ||||||||||||||||||||||||
| 164 | int num_alloc; | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | if (n > max_nodes - st->num
| 0-3135864 | ||||||||||||||||||||||||
| 168 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | num_alloc = st->num + n; | - | ||||||||||||||||||||||||
| 172 | if (num_alloc < min_nodes
| 814185-2321679 | ||||||||||||||||||||||||
| 173 | num_alloc = min_nodes; executed 814185 times by 1 test: num_alloc = min_nodes;Executed by:
| 814185 | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | if (st->data ==
| 544576-2591288 | ||||||||||||||||||||||||
| 177 | ((void *)0)
| 544576-2591288 | ||||||||||||||||||||||||
| 178 | ) { | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | if ((
| 0-544576 | ||||||||||||||||||||||||
| 184 | ((void *)0)
| 0-544576 | ||||||||||||||||||||||||
| 185 | ) { | - | ||||||||||||||||||||||||
| 186 | ERR_put_error(15,(129),((1|64)),__FILE__,181); | - | ||||||||||||||||||||||||
| 187 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 188 | } | - | ||||||||||||||||||||||||
| 189 | st->num_alloc = num_alloc; | - | ||||||||||||||||||||||||
| 190 | return executed 544576 times by 1 test: 1;return 1;Executed by:
executed 544576 times by 1 test: return 1;Executed by:
| 544576 | ||||||||||||||||||||||||
| 191 | } | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | if (!exact
| 0-2591288 | ||||||||||||||||||||||||
| 194 | if (num_alloc <= st->num_alloc
| 228580-2362708 | ||||||||||||||||||||||||
| 195 | return executed 2362708 times by 1 test: 1;return 1;Executed by:
executed 2362708 times by 1 test: return 1;Executed by:
| 2362708 | ||||||||||||||||||||||||
| 196 | num_alloc = compute_growth(num_alloc, st->num_alloc); | - | ||||||||||||||||||||||||
| 197 | if (num_alloc == 0
| 0-228580 | ||||||||||||||||||||||||
| 198 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 199 | } executed 228580 times by 1 test: else if (num_alloc == st->num_allocend of blockExecuted by:
| 0-228580 | ||||||||||||||||||||||||
| 200 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 201 | } | - | ||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | tmpdata = CRYPTO_realloc((void *)st->data, sizeof(void *) * num_alloc, __FILE__, 198); | - | ||||||||||||||||||||||||
| 204 | if (tmpdata ==
| 0-228580 | ||||||||||||||||||||||||
| 205 | ((void *)0)
| 0-228580 | ||||||||||||||||||||||||
| 206 | ) | - | ||||||||||||||||||||||||
| 207 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | st->data = tmpdata; | - | ||||||||||||||||||||||||
| 210 | st->num_alloc = num_alloc; | - | ||||||||||||||||||||||||
| 211 | return executed 228580 times by 1 test: 1;return 1;Executed by:
executed 228580 times by 1 test: return 1;Executed by:
| 228580 | ||||||||||||||||||||||||
| 212 | } | - | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n) | - | ||||||||||||||||||||||||
| 215 | { | - | ||||||||||||||||||||||||
| 216 | OPENSSL_STACK *st = CRYPTO_zalloc(sizeof(OPENSSL_STACK), __FILE__, 209); | - | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | if (st ==
| 0-1058471 | ||||||||||||||||||||||||
| 219 | ((void *)0)
| 0-1058471 | ||||||||||||||||||||||||
| 220 | ) | - | ||||||||||||||||||||||||
| 221 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 222 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 223 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | st->comp = c; | - | ||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||
| 227 | if (n <= 0
| 24-1058447 | ||||||||||||||||||||||||
| 228 | return executed 1058447 times by 1 test: st;return st;Executed by:
executed 1058447 times by 1 test: return st;Executed by:
| 1058447 | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | if (!sk_reserve(st, n, 1)
| 0-24 | ||||||||||||||||||||||||
| 231 | OPENSSL_sk_free(st); | - | ||||||||||||||||||||||||
| 232 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 233 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 234 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 235 | } | - | ||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | return executed 24 times by 1 test: st;return st;Executed by:
executed 24 times by 1 test: return st;Executed by:
| 24 | ||||||||||||||||||||||||
| 238 | } | - | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n) | - | ||||||||||||||||||||||||
| 241 | { | - | ||||||||||||||||||||||||
| 242 | if (st ==
| 0-6 | ||||||||||||||||||||||||
| 243 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 244 | ) | - | ||||||||||||||||||||||||
| 245 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | if (n < 0
| 0-6 | ||||||||||||||||||||||||
| 248 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 249 | return executed 6 times by 1 test: sk_reserve(st, n, 1);return sk_reserve(st, n, 1);Executed by:
executed 6 times by 1 test: return sk_reserve(st, n, 1);Executed by:
| 6 | ||||||||||||||||||||||||
| 250 | } | - | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc) | - | ||||||||||||||||||||||||
| 253 | { | - | ||||||||||||||||||||||||
| 254 | if (st ==
| 0-3135834 | ||||||||||||||||||||||||
| 255 | ((void *)0)
| 0-3135834 | ||||||||||||||||||||||||
| 256 | || st->num == max_nodes
| 0-3135834 | ||||||||||||||||||||||||
| 257 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | if (!sk_reserve(st, 1, 0)
| 0-3135834 | ||||||||||||||||||||||||
| 260 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | if ((
| 4-3134474 | ||||||||||||||||||||||||
| 263 | st->data[st->num] = data; | - | ||||||||||||||||||||||||
| 264 | } executed 3134478 times by 1 test: else {end of blockExecuted by:
| 3134478 | ||||||||||||||||||||||||
| 265 | memmove(&st->data[loc + 1], &st->data[loc], | - | ||||||||||||||||||||||||
| 266 | sizeof(st->data[0]) * (st->num - loc)); | - | ||||||||||||||||||||||||
| 267 | st->data[loc] = data; | - | ||||||||||||||||||||||||
| 268 | } executed 1356 times by 1 test: end of blockExecuted by:
| 1356 | ||||||||||||||||||||||||
| 269 | st->num++; | - | ||||||||||||||||||||||||
| 270 | st->sorted = 0; | - | ||||||||||||||||||||||||
| 271 | return executed 3135834 times by 1 test: st->num;return st->num;Executed by:
executed 3135834 times by 1 test: return st->num;Executed by:
| 3135834 | ||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||
| 274 | static inline void *internal_delete(OPENSSL_STACK *st, int loc) | - | ||||||||||||||||||||||||
| 275 | { | - | ||||||||||||||||||||||||
| 276 | const void *ret = st->data[loc]; | - | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | if (loc != st->num - 1
| 12813-15089 | ||||||||||||||||||||||||
| 279 | memmove(&st->data[loc], &st->data[loc + 1], executed 15089 times by 1 test: memmove(&st->data[loc], &st->data[loc + 1], sizeof(st->data[0]) * (st->num - loc - 1));Executed by:
| 15089 | ||||||||||||||||||||||||
| 280 | sizeof(st->data[0]) * (st->num - loc - 1)); executed 15089 times by 1 test: memmove(&st->data[loc], &st->data[loc + 1], sizeof(st->data[0]) * (st->num - loc - 1));Executed by:
| 15089 | ||||||||||||||||||||||||
| 281 | st->num--; | - | ||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | return executed 27902 times by 1 test: (void *)ret;return (void *)ret;Executed by:
executed 27902 times by 1 test: return (void *)ret;Executed by:
| 27902 | ||||||||||||||||||||||||
| 284 | } | - | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p) | - | ||||||||||||||||||||||||
| 287 | { | - | ||||||||||||||||||||||||
| 288 | int i; | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | for (i = 0; i < st->num
| 2936-67776 | ||||||||||||||||||||||||
| 291 | if (st->data[i] == p
| 13274-54502 | ||||||||||||||||||||||||
| 292 | return executed 13274 times by 1 test: internal_delete(st, i);return internal_delete(st, i);Executed by:
executed 13274 times by 1 test: return internal_delete(st, i);Executed by:
| 13274 | ||||||||||||||||||||||||
| 293 | return executed 2936 times by 1 test: return ((void *)0) ;Executed by:
executed 2936 times by 1 test: return ((void *)0) ;Executed by:
| 2936 | ||||||||||||||||||||||||
| 294 | ((void *)0) executed 2936 times by 1 test: return ((void *)0) ;Executed by:
| 2936 | ||||||||||||||||||||||||
| 295 | ; executed 2936 times by 1 test: return ((void *)0) ;Executed by:
| 2936 | ||||||||||||||||||||||||
| 296 | } | - | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc) | - | ||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||
| 300 | if (st ==
| 0-11389 | ||||||||||||||||||||||||
| 301 | ((void *)0)
| 0-11389 | ||||||||||||||||||||||||
| 302 | || loc < 0
| 0-11389 | ||||||||||||||||||||||||
| 303 | return executed 4 times by 1 test: return ((void *)0) ;Executed by:
executed 4 times by 1 test: return ((void *)0) ;Executed by:
| 4 | ||||||||||||||||||||||||
| 304 | ((void *)0) executed 4 times by 1 test: return ((void *)0) ;Executed by:
| 4 | ||||||||||||||||||||||||
| 305 | ; executed 4 times by 1 test: return ((void *)0) ;Executed by:
| 4 | ||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | return executed 11385 times by 1 test: internal_delete(st, loc);return internal_delete(st, loc);Executed by:
executed 11385 times by 1 test: return internal_delete(st, loc);Executed by:
| 11385 | ||||||||||||||||||||||||
| 308 | } | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | static int internal_find(OPENSSL_STACK *st, const void *data, | - | ||||||||||||||||||||||||
| 311 | int ret_val_options) | - | ||||||||||||||||||||||||
| 312 | { | - | ||||||||||||||||||||||||
| 313 | const void *r; | - | ||||||||||||||||||||||||
| 314 | int i; | - | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | if (st ==
| 0-19488 | ||||||||||||||||||||||||
| 317 | ((void *)0)
| 0-19488 | ||||||||||||||||||||||||
| 318 | || st->num == 0
| 9698-9790 | ||||||||||||||||||||||||
| 319 | return executed 9790 times by 1 test: -1;return -1;Executed by:
executed 9790 times by 1 test: return -1;Executed by:
| 9790 | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | if (st->comp ==
| 4255-5443 | ||||||||||||||||||||||||
| 322 | ((void *)0)
| 4255-5443 | ||||||||||||||||||||||||
| 323 | ) { | - | ||||||||||||||||||||||||
| 324 | for (i = 0; i < st->num
| 1580-52586 | ||||||||||||||||||||||||
| 325 | if (st->data[i] == data
| 2675-49911 | ||||||||||||||||||||||||
| 326 | return executed 2675 times by 1 test: i;return i;Executed by:
executed 2675 times by 1 test: return i;Executed by:
| 2675 | ||||||||||||||||||||||||
| 327 | return executed 1580 times by 1 test: -1;return -1;Executed by:
executed 1580 times by 1 test: return -1;Executed by:
| 1580 | ||||||||||||||||||||||||
| 328 | } | - | ||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | if (!st->sorted
| 1086-4357 | ||||||||||||||||||||||||
| 331 | if (st->num > 1
| 50-1036 | ||||||||||||||||||||||||
| 332 | qsort(st->data, st->num, sizeof(void *), st->comp); executed 50 times by 1 test: qsort(st->data, st->num, sizeof(void *), st->comp);Executed by:
| 50 | ||||||||||||||||||||||||
| 333 | st->sorted = 1; | - | ||||||||||||||||||||||||
| 334 | } executed 1086 times by 1 test: end of blockExecuted by:
| 1086 | ||||||||||||||||||||||||
| 335 | if (data ==
| 0-5443 | ||||||||||||||||||||||||
| 336 | ((void *)0)
| 0-5443 | ||||||||||||||||||||||||
| 337 | ) | - | ||||||||||||||||||||||||
| 338 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 339 | r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp, | - | ||||||||||||||||||||||||
| 340 | ret_val_options); | - | ||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | return executed 5443 times by 1 test: r == return r == ((void *)0) ? -1 : (int)((const void **)r - st->data);Executed by:
executed 5443 times by 1 test: return r == ((void *)0) ? -1 : (int)((const void **)r - st->data);Executed by:
| 101-5443 | ||||||||||||||||||||||||
| 343 | ((void *)0)
executed 5443 times by 1 test: return r == ((void *)0) ? -1 : (int)((const void **)r - st->data);Executed by:
| 101-5443 | ||||||||||||||||||||||||
| 344 | ? -1 : (int)((const void **)r - st->data); executed 5443 times by 1 test: return r == ((void *)0) ? -1 : (int)((const void **)r - st->data);Executed by:
| 5443 | ||||||||||||||||||||||||
| 345 | } | - | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data) | - | ||||||||||||||||||||||||
| 348 | { | - | ||||||||||||||||||||||||
| 349 | return executed 19424 times by 1 test: internal_find(st, data, 0x02);return internal_find(st, data, 0x02);Executed by:
executed 19424 times by 1 test: return internal_find(st, data, 0x02);Executed by:
| 19424 | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data) | - | ||||||||||||||||||||||||
| 353 | { | - | ||||||||||||||||||||||||
| 354 | return executed 64 times by 1 test: internal_find(st, data, 0x01);return internal_find(st, data, 0x01);Executed by:
executed 64 times by 1 test: return internal_find(st, data, 0x01);Executed by:
| 64 | ||||||||||||||||||||||||
| 355 | } | - | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data) | - | ||||||||||||||||||||||||
| 358 | { | - | ||||||||||||||||||||||||
| 359 | if (st ==
| 0-3115079 | ||||||||||||||||||||||||
| 360 | ((void *)0)
| 0-3115079 | ||||||||||||||||||||||||
| 361 | ) | - | ||||||||||||||||||||||||
| 362 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 363 | return executed 3115079 times by 1 test: OPENSSL_sk_insert(st, data, st->num);return OPENSSL_sk_insert(st, data, st->num);Executed by:
executed 3115079 times by 1 test: return OPENSSL_sk_insert(st, data, st->num);Executed by:
| 3115079 | ||||||||||||||||||||||||
| 364 | } | - | ||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data) | - | ||||||||||||||||||||||||
| 367 | { | - | ||||||||||||||||||||||||
| 368 | return executed 24 times by 1 test: OPENSSL_sk_insert(st, data, 0);return OPENSSL_sk_insert(st, data, 0);Executed by:
executed 24 times by 1 test: return OPENSSL_sk_insert(st, data, 0);Executed by:
| 24 | ||||||||||||||||||||||||
| 369 | } | - | ||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||
| 371 | void *OPENSSL_sk_shift(OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 372 | { | - | ||||||||||||||||||||||||
| 373 | if (st ==
| 0-1704 | ||||||||||||||||||||||||
| 374 | ((void *)0)
| 0-1704 | ||||||||||||||||||||||||
| 375 | || st->num == 0
| 27-1677 | ||||||||||||||||||||||||
| 376 | return executed 27 times by 1 test: return ((void *)0) ;Executed by:
executed 27 times by 1 test: return ((void *)0) ;Executed by:
| 27 | ||||||||||||||||||||||||
| 377 | ((void *)0) executed 27 times by 1 test: return ((void *)0) ;Executed by:
| 27 | ||||||||||||||||||||||||
| 378 | ; executed 27 times by 1 test: return ((void *)0) ;Executed by:
| 27 | ||||||||||||||||||||||||
| 379 | return executed 1677 times by 1 test: internal_delete(st, 0);return internal_delete(st, 0);Executed by:
executed 1677 times by 1 test: return internal_delete(st, 0);Executed by:
| 1677 | ||||||||||||||||||||||||
| 380 | } | - | ||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||
| 382 | void *OPENSSL_sk_pop(OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 383 | { | - | ||||||||||||||||||||||||
| 384 | if (st ==
| 1583-1931 | ||||||||||||||||||||||||
| 385 | ((void *)0)
| 1583-1931 | ||||||||||||||||||||||||
| 386 | || st->num == 0
| 17-1566 | ||||||||||||||||||||||||
| 387 | return executed 1948 times by 1 test: return ((void *)0) ;Executed by:
executed 1948 times by 1 test: return ((void *)0) ;Executed by:
| 1948 | ||||||||||||||||||||||||
| 388 | ((void *)0) executed 1948 times by 1 test: return ((void *)0) ;Executed by:
| 1948 | ||||||||||||||||||||||||
| 389 | ; executed 1948 times by 1 test: return ((void *)0) ;Executed by:
| 1948 | ||||||||||||||||||||||||
| 390 | return executed 1566 times by 1 test: internal_delete(st, st->num - 1);return internal_delete(st, st->num - 1);Executed by:
executed 1566 times by 1 test: return internal_delete(st, st->num - 1);Executed by:
| 1566 | ||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | void OPENSSL_sk_zero(OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 394 | { | - | ||||||||||||||||||||||||
| 395 | if (st ==
| 0-4 | ||||||||||||||||||||||||
| 396 | ((void *)0)
| 0-4 | ||||||||||||||||||||||||
| 397 | || st->num == 0
| 0-4 | ||||||||||||||||||||||||
| 398 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 399 | memset(st->data, 0, sizeof(*st->data) * st->num); | - | ||||||||||||||||||||||||
| 400 | st->num = 0; | - | ||||||||||||||||||||||||
| 401 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||
| 403 | void OPENSSL_sk_pop_free(OPENSSL_STACK *st, OPENSSL_sk_freefunc func) | - | ||||||||||||||||||||||||
| 404 | { | - | ||||||||||||||||||||||||
| 405 | int i; | - | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | if (st ==
| 613487-619635 | ||||||||||||||||||||||||
| 408 | ((void *)0)
| 613487-619635 | ||||||||||||||||||||||||
| 409 | ) | - | ||||||||||||||||||||||||
| 410 | return; executed 619635 times by 12 tests: return;Executed by:
| 619635 | ||||||||||||||||||||||||
| 411 | for (i = 0; i < st->num
| 534853-613487 | ||||||||||||||||||||||||
| 412 | if (st->data[i] !=
| 5081-529772 | ||||||||||||||||||||||||
| 413 | ((void *)0)
| 5081-529772 | ||||||||||||||||||||||||
| 414 | ) | - | ||||||||||||||||||||||||
| 415 | func((char *)st->data[i]); executed 529772 times by 1 test: func((char *)st->data[i]);Executed by:
| 529772 | ||||||||||||||||||||||||
| 416 | OPENSSL_sk_free(st); | - | ||||||||||||||||||||||||
| 417 | } executed 613487 times by 1 test: end of blockExecuted by:
| 613487 | ||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | void OPENSSL_sk_free(OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 420 | { | - | ||||||||||||||||||||||||
| 421 | if (st ==
| 890422-1090910 | ||||||||||||||||||||||||
| 422 | ((void *)0)
| 890422-1090910 | ||||||||||||||||||||||||
| 423 | ) | - | ||||||||||||||||||||||||
| 424 | return; executed 890422 times by 12 tests: return;Executed by:
| 890422 | ||||||||||||||||||||||||
| 425 | CRYPTO_free(st->data, __FILE__, 376); | - | ||||||||||||||||||||||||
| 426 | CRYPTO_free(st, __FILE__, 377); | - | ||||||||||||||||||||||||
| 427 | } executed 1090910 times by 1 test: end of blockExecuted by:
| 1090910 | ||||||||||||||||||||||||
| 428 | - | |||||||||||||||||||||||||
| 429 | int OPENSSL_sk_num(const OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 430 | { | - | ||||||||||||||||||||||||
| 431 | return executed 9183832 times by 12 tests: st == return st == ((void *)0) ? -1 : st->num;Executed by:
executed 9183832 times by 12 tests: return st == ((void *)0) ? -1 : st->num;Executed by:
| 1292008-9183832 | ||||||||||||||||||||||||
| 432 | ((void *)0)
executed 9183832 times by 12 tests: return st == ((void *)0) ? -1 : st->num;Executed by:
| 1292008-9183832 | ||||||||||||||||||||||||
| 433 | ? -1 : st->num; executed 9183832 times by 12 tests: return st == ((void *)0) ? -1 : st->num;Executed by:
| 9183832 | ||||||||||||||||||||||||
| 434 | } | - | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i) | - | ||||||||||||||||||||||||
| 437 | { | - | ||||||||||||||||||||||||
| 438 | if (st ==
| 0-7047030 | ||||||||||||||||||||||||
| 439 | ((void *)0)
| 0-7047030 | ||||||||||||||||||||||||
| 440 | || i < 0
| 2386-7043949 | ||||||||||||||||||||||||
| 441 | return executed 5467 times by 1 test: return ((void *)0) ;Executed by:
executed 5467 times by 1 test: return ((void *)0) ;Executed by:
| 5467 | ||||||||||||||||||||||||
| 442 | ((void *)0) executed 5467 times by 1 test: return ((void *)0) ;Executed by:
| 5467 | ||||||||||||||||||||||||
| 443 | ; executed 5467 times by 1 test: return ((void *)0) ;Executed by:
| 5467 | ||||||||||||||||||||||||
| 444 | return executed 7041563 times by 1 test: (void *)st->data[i];return (void *)st->data[i];Executed by:
executed 7041563 times by 1 test: return (void *)st->data[i];Executed by:
| 7041563 | ||||||||||||||||||||||||
| 445 | } | - | ||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data) | - | ||||||||||||||||||||||||
| 448 | { | - | ||||||||||||||||||||||||
| 449 | if (st ==
| 0-108271 | ||||||||||||||||||||||||
| 450 | ((void *)0)
| 0-108271 | ||||||||||||||||||||||||
| 451 | || i < 0
| 0-108271 | ||||||||||||||||||||||||
| 452 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 453 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 454 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 455 | st->data[i] = data; | - | ||||||||||||||||||||||||
| 456 | st->sorted = 0; | - | ||||||||||||||||||||||||
| 457 | return executed 108271 times by 1 test: (void *)st->data[i];return (void *)st->data[i];Executed by:
executed 108271 times by 1 test: return (void *)st->data[i];Executed by:
| 108271 | ||||||||||||||||||||||||
| 458 | } | - | ||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | void OPENSSL_sk_sort(OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 461 | { | - | ||||||||||||||||||||||||
| 462 | if (st !=
| 0-15736 | ||||||||||||||||||||||||
| 463 | ((void *)0)
| 0-15736 | ||||||||||||||||||||||||
| 464 | && !st->sorted
| 0-15736 | ||||||||||||||||||||||||
| 465 | ((void *)0)
| 0-15736 | ||||||||||||||||||||||||
| 466 | ) { | - | ||||||||||||||||||||||||
| 467 | if (st->num > 1
| 317-15419 | ||||||||||||||||||||||||
| 468 | qsort(st->data, st->num, sizeof(void *), st->comp); executed 15419 times by 1 test: qsort(st->data, st->num, sizeof(void *), st->comp);Executed by:
| 15419 | ||||||||||||||||||||||||
| 469 | st->sorted = 1; | - | ||||||||||||||||||||||||
| 470 | } executed 15736 times by 1 test: end of blockExecuted by:
| 15736 | ||||||||||||||||||||||||
| 471 | } executed 15736 times by 1 test: end of blockExecuted by:
| 15736 | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st) | - | ||||||||||||||||||||||||
| 474 | { | - | ||||||||||||||||||||||||
| 475 | return executed 9 times by 1 test: st == return st == ((void *)0) ? 1 : st->sorted;Executed by:
executed 9 times by 1 test: return st == ((void *)0) ? 1 : st->sorted;Executed by:
| 0-9 | ||||||||||||||||||||||||
| 476 | ((void *)0)
executed 9 times by 1 test: return st == ((void *)0) ? 1 : st->sorted;Executed by:
| 0-9 | ||||||||||||||||||||||||
| 477 | ? 1 : st->sorted; executed 9 times by 1 test: return st == ((void *)0) ? 1 : st->sorted;Executed by:
| 9 | ||||||||||||||||||||||||
| 478 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |