Skip to content

Commit 305dbea

Browse files
JacobBarthelmehdgarske
authored andcommitted
add more debug info about file state and bytes processed
1 parent 7c9eaa8 commit 305dbea

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pkcs7/benchmark-streaming-envelop.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,20 @@ static int DecodePKCS7Bundle(void)
299299
}
300300

301301
if (ret == 0) {
302+
rewind(f); /* start from the beginning of the file */
302303
do {
303304
testStreamBufferSz = (int)XFREAD(testStreamBuffer, 1,
304305
sizeof(testStreamBuffer), f);
306+
if (testStreamBufferSz == 0) {
307+
printf("Read 0 bytes from file...");
308+
if (feof(f)) {
309+
printf("at end of file\n");
310+
}
311+
if (ferror(f)) {
312+
printf("encountered error with file read\n");
313+
}
314+
break;
315+
}
305316

306317
ret = wc_PKCS7_DecodeEnvelopedData(pkcs7, testStreamBuffer,
307318
testStreamBufferSz, NULL, 0);
@@ -328,6 +339,7 @@ static int DecodePKCS7Bundle(void)
328339
printf("%.2f MB/s", per);
329340
}
330341
printf(" : ret = %d\n", ret);
342+
printf("Processed %.0f bytes\n", totalSz);
331343
return ret;
332344
}
333345

0 commit comments

Comments
 (0)