summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-12-08 18:16:28 +0000
committertb <>2022-12-08 18:16:28 +0000
commitb291e5dd95d6d7904a1d86d44d6e946ecad78dd4 (patch)
tree706e2d2929ae0e66aeee3c0040238fcef6289e5f
parentcf4d00d7e24e1e37cd14fcb1b8713d8df7ce6da3 (diff)
downloadopenbsd-b291e5dd95d6d7904a1d86d44d6e946ecad78dd4.tar.gz
openbsd-b291e5dd95d6d7904a1d86d44d6e946ecad78dd4.tar.bz2
openbsd-b291e5dd95d6d7904a1d86d44d6e946ecad78dd4.zip
bio chain test: rename a few variables for consistency
-rw-r--r--src/regress/lib/libcrypto/bio/bio_chain.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/regress/lib/libcrypto/bio/bio_chain.c b/src/regress/lib/libcrypto/bio/bio_chain.c
index 3453312e06..dce864fdfa 100644
--- a/src/regress/lib/libcrypto/bio/bio_chain.c
+++ b/src/regress/lib/libcrypto/bio/bio_chain.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_chain.c,v 1.4 2022/12/08 18:15:36 tb Exp $ */ 1/* $OpenBSD: bio_chain.c,v 1.5 2022/12/08 18:16:28 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -193,23 +193,23 @@ bio_chain_pop_test(void)
193} 193}
194 194
195static int 195static int
196walk_forward(BIO *start, BIO *end, size_t expected_length, 196walk_forward(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j,
197 size_t i, size_t j, const char *fn, const char *description) 197 const char *fn, const char *description)
198{ 198{
199 BIO *prev, *next; 199 BIO *prev, *next;
200 size_t length; 200 size_t len;
201 int ret = 0; 201 int ret = 0;
202 202
203 if (start == NULL || end == NULL) 203 if (start == NULL || end == NULL)
204 goto done; 204 goto done;
205 205
206 next = start; 206 next = start;
207 length = 0; 207 len = 0;
208 208
209 do { 209 do {
210 prev = next; 210 prev = next;
211 next = BIO_next(prev); 211 next = BIO_next(prev);
212 length++; 212 len++;
213 } while (next != NULL); 213 } while (next != NULL);
214 214
215 if (prev != end) { 215 if (prev != end) {
@@ -218,10 +218,10 @@ walk_forward(BIO *start, BIO *end, size_t expected_length,
218 goto err; 218 goto err;
219 } 219 }
220 220
221 if (length != expected_length) { 221 if (len != expected_len) {
222 fprintf(stderr, "%s case (%zu, %zu) %s length " 222 fprintf(stderr, "%s case (%zu, %zu) %s length "
223 "(walking forward) want: %zu, got %zu\n", 223 "(walking forward) want: %zu, got %zu\n",
224 fn, i, j, description, expected_length, length); 224 fn, i, j, description, expected_len, len);
225 goto err; 225 goto err;
226 } 226 }
227 227
@@ -233,22 +233,22 @@ walk_forward(BIO *start, BIO *end, size_t expected_length,
233} 233}
234 234
235static int 235static int
236walk_backward(BIO *start, BIO *end, size_t expected_length, 236walk_backward(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j,
237 size_t i, size_t j, const char *fn, const char *description) 237 const char *fn, const char *description)
238{ 238{
239 BIO *prev, *next; 239 BIO *prev, *next;
240 size_t length; 240 size_t len;
241 int ret = 0; 241 int ret = 0;
242 242
243 if (start == NULL || end == NULL) 243 if (start == NULL || end == NULL)
244 goto done; 244 goto done;
245 245
246 length = 0; 246 len = 0;
247 prev = end; 247 prev = end;
248 do { 248 do {
249 next = prev; 249 next = prev;
250 prev = BIO_prev(prev); 250 prev = BIO_prev(prev);
251 length++; 251 len++;
252 } while (prev != NULL); 252 } while (prev != NULL);
253 253
254 if (next != start) { 254 if (next != start) {
@@ -257,10 +257,10 @@ walk_backward(BIO *start, BIO *end, size_t expected_length,
257 goto err; 257 goto err;
258 } 258 }
259 259
260 if (length != expected_length) { 260 if (len != expected_len) {
261 fprintf(stderr, "%s case (%zu, %zu) %s length " 261 fprintf(stderr, "%s case (%zu, %zu) %s length "
262 "(walking backward) want: %zu, got %zu\n", 262 "(walking backward) want: %zu, got %zu\n",
263 fn, i, j, description, expected_length, length); 263 fn, i, j, description, expected_len, len);
264 goto err; 264 goto err;
265 } 265 }
266 266
@@ -272,12 +272,12 @@ walk_backward(BIO *start, BIO *end, size_t expected_length,
272} 272}
273 273
274static int 274static int
275check_chain(BIO *start, BIO *end, size_t expected_length, 275check_chain(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j,
276 size_t i, size_t j, const char *fn, const char *description) 276 const char *fn, const char *description)
277{ 277{
278 if (!walk_forward(start, end, expected_length, i, j, fn, description)) 278 if (!walk_forward(start, end, expected_len, i, j, fn, description))
279 return 0; 279 return 0;
280 if (!walk_backward(start, end, expected_length, i, j, fn, description)) 280 if (!walk_backward(start, end, expected_len, i, j, fn, description))
281 return 0; 281 return 0;
282 282
283 return 1; 283 return 1;
@@ -332,7 +332,7 @@ link_chains_at(size_t i, size_t j, int use_bio_push)
332 BIO *A[LINK_CHAIN_A_LEN], *B[LINK_CHAIN_B_LEN]; 332 BIO *A[LINK_CHAIN_A_LEN], *B[LINK_CHAIN_B_LEN];
333 BIO *new_start, *new_end; 333 BIO *new_start, *new_end;
334 BIO *oldhead_start, *oldhead_end, *oldtail_start, *oldtail_end; 334 BIO *oldhead_start, *oldhead_end, *oldtail_start, *oldtail_end;
335 size_t new_length, oldhead_length, oldtail_length; 335 size_t new_len, oldhead_len, oldtail_len;
336 int failed = 1; 336 int failed = 1;
337 337
338 memset(A, 0, sizeof(A)); 338 memset(A, 0, sizeof(A));
@@ -354,29 +354,29 @@ link_chains_at(size_t i, size_t j, int use_bio_push)
354 new_start = A[0]; 354 new_start = A[0];
355 new_end = B[nitems(B) - 1]; 355 new_end = B[nitems(B) - 1];
356 356
357 oldhead_length = j; 357 oldhead_len = j;
358 oldhead_start = B[0]; 358 oldhead_start = B[0];
359 oldhead_end = BIO_prev(B[j]); 359 oldhead_end = BIO_prev(B[j]);
360 360
361 /* If we push B[0] or set next to B[0], the oldhead chain is empty. */ 361 /* If we push B[0] or set next to B[0], the oldhead chain is empty. */
362 if (j == 0) { 362 if (j == 0) {
363 oldhead_length = 0; 363 oldhead_len = 0;
364 oldhead_start = NULL; 364 oldhead_start = NULL;
365 } 365 }
366 366
367 if (use_bio_push) { 367 if (use_bio_push) {
368 new_length = nitems(A) + nitems(B) - j; 368 new_len = nitems(A) + nitems(B) - j;
369 369
370 /* oldtail doesn't exist in the BIO_push() case. */ 370 /* oldtail doesn't exist in the BIO_push() case. */
371 oldtail_start = NULL; 371 oldtail_start = NULL;
372 oldtail_end = NULL; 372 oldtail_end = NULL;
373 oldtail_length = 0; 373 oldtail_len = 0;
374 } else { 374 } else {
375 new_length = i + 1 + nitems(B) - j; 375 new_len = i + 1 + nitems(B) - j;
376 376
377 oldtail_start = BIO_next(A[i]); 377 oldtail_start = BIO_next(A[i]);
378 oldtail_end = A[nitems(A) - 1]; 378 oldtail_end = A[nitems(A) - 1];
379 oldtail_length = nitems(A) - i - 1; 379 oldtail_len = nitems(A) - i - 1;
380 } 380 }
381 381
382 /* 382 /*
@@ -397,14 +397,14 @@ link_chains_at(size_t i, size_t j, int use_bio_push)
397 * Check that all the chains match our expectations. 397 * Check that all the chains match our expectations.
398 */ 398 */
399 399
400 if (!check_chain(new_start, new_end, new_length, i, j, fn, "new chain")) 400 if (!check_chain(new_start, new_end, new_len, i, j, fn, "new chain"))
401 goto err; 401 goto err;
402 402
403 if (!check_chain(oldhead_start, oldhead_end, oldhead_length, i, j, fn, 403 if (!check_chain(oldhead_start, oldhead_end, oldhead_len, i, j, fn,
404 "oldhead")) 404 "oldhead"))
405 goto err; 405 goto err;
406 406
407 if (!check_chain(oldtail_start, oldtail_end, oldtail_length, i, j, fn, 407 if (!check_chain(oldtail_start, oldtail_end, oldtail_len, i, j, fn,
408 "oldtail")) 408 "oldtail"))
409 goto err; 409 goto err;
410 410