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
3
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
4
4
*
@@ -193,23 +193,23 @@ bio_chain_pop_test(void)
193
193
}
194
194
195
195
static int
196
- walk_forward (BIO * start , BIO * end , size_t expected_length ,
197
- size_t i , size_t j , const char * fn , const char * description )
196
+ walk_forward (BIO * start , BIO * end , size_t expected_len , size_t i , size_t j ,
197
+ const char * fn , const char * description )
198
198
{
199
199
BIO * prev , * next ;
200
- size_t length ;
200
+ size_t len ;
201
201
int ret = 0 ;
202
202
203
203
if (start == NULL || end == NULL )
204
204
goto done ;
205
205
206
206
next = start ;
207
- length = 0 ;
207
+ len = 0 ;
208
208
209
209
do {
210
210
prev = next ;
211
211
next = BIO_next (prev );
212
- length ++ ;
212
+ len ++ ;
213
213
} while (next != NULL );
214
214
215
215
if (prev != end ) {
@@ -218,10 +218,10 @@ walk_forward(BIO *start, BIO *end, size_t expected_length,
218
218
goto err ;
219
219
}
220
220
221
- if (length != expected_length ) {
221
+ if (len != expected_len ) {
222
222
fprintf (stderr , "%s case (%zu, %zu) %s length "
223
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
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
235
235
static int
236
- walk_backward (BIO * start , BIO * end , size_t expected_length ,
237
- size_t i , size_t j , const char * fn , const char * description )
236
+ walk_backward (BIO * start , BIO * end , size_t expected_len , size_t i , size_t j ,
237
+ const char * fn , const char * description )
238
238
{
239
239
BIO * prev , * next ;
240
- size_t length ;
240
+ size_t len ;
241
241
int ret = 0 ;
242
242
243
243
if (start == NULL || end == NULL )
244
244
goto done ;
245
245
246
- length = 0 ;
246
+ len = 0 ;
247
247
prev = end ;
248
248
do {
249
249
next = prev ;
250
250
prev = BIO_prev (prev );
251
- length ++ ;
251
+ len ++ ;
252
252
} while (prev != NULL );
253
253
254
254
if (next != start ) {
@@ -257,10 +257,10 @@ walk_backward(BIO *start, BIO *end, size_t expected_length,
257
257
goto err ;
258
258
}
259
259
260
- if (length != expected_length ) {
260
+ if (len != expected_len ) {
261
261
fprintf (stderr , "%s case (%zu, %zu) %s length "
262
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
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
274
274
static int
275
- check_chain (BIO * start , BIO * end , size_t expected_length ,
276
- size_t i , size_t j , const char * fn , const char * description )
275
+ check_chain (BIO * start , BIO * end , size_t expected_len , size_t i , size_t j ,
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
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
281
return 0 ;
282
282
283
283
return 1 ;
@@ -332,7 +332,7 @@ link_chains_at(size_t i, size_t j, int use_bio_push)
332
332
BIO * A [LINK_CHAIN_A_LEN ], * B [LINK_CHAIN_B_LEN ];
333
333
BIO * new_start , * new_end ;
334
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
336
int failed = 1 ;
337
337
338
338
memset (A , 0 , sizeof (A ));
@@ -354,29 +354,29 @@ link_chains_at(size_t i, size_t j, int use_bio_push)
354
354
new_start = A [0 ];
355
355
new_end = B [nitems (B ) - 1 ];
356
356
357
- oldhead_length = j ;
357
+ oldhead_len = j ;
358
358
oldhead_start = B [0 ];
359
359
oldhead_end = BIO_prev (B [j ]);
360
360
361
361
/* If we push B[0] or set next to B[0], the oldhead chain is empty. */
362
362
if (j == 0 ) {
363
- oldhead_length = 0 ;
363
+ oldhead_len = 0 ;
364
364
oldhead_start = NULL ;
365
365
}
366
366
367
367
if (use_bio_push ) {
368
- new_length = nitems (A ) + nitems (B ) - j ;
368
+ new_len = nitems (A ) + nitems (B ) - j ;
369
369
370
370
/* oldtail doesn't exist in the BIO_push() case. */
371
371
oldtail_start = NULL ;
372
372
oldtail_end = NULL ;
373
- oldtail_length = 0 ;
373
+ oldtail_len = 0 ;
374
374
} else {
375
- new_length = i + 1 + nitems (B ) - j ;
375
+ new_len = i + 1 + nitems (B ) - j ;
376
376
377
377
oldtail_start = BIO_next (A [i ]);
378
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
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
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
404
"oldhead" ))
405
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
408
"oldtail" ))
409
409
goto err ;
410
410
0 commit comments