summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-05-16 14:41:05 +0000
committerjsing <>2014-05-16 14:41:05 +0000
commit252be4efa78e5b1b1060d9861ebfb333ebbc34ff (patch)
treebd245dd3aeb3f506433e1f37cc008baee3d40e72
parentd6d4e206cd692584735252f0a21af1b42608bc28 (diff)
downloadopenbsd-252be4efa78e5b1b1060d9861ebfb333ebbc34ff.tar.gz
openbsd-252be4efa78e5b1b1060d9861ebfb333ebbc34ff.tar.bz2
openbsd-252be4efa78e5b1b1060d9861ebfb333ebbc34ff.zip
Fix various issues that result in compiler warnings.
Prompted by a diff from Brent Cook.
-rw-r--r--src/regress/lib/libcrypto/base64/base64test.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/regress/lib/libcrypto/base64/base64test.c b/src/regress/lib/libcrypto/base64/base64test.c
index a7d167e97d..17dcfaf302 100644
--- a/src/regress/lib/libcrypto/base64/base64test.c
+++ b/src/regress/lib/libcrypto/base64/base64test.c
@@ -19,15 +19,16 @@
19 19
20#include <err.h> 20#include <err.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <string.h>
22 23
23#define BUF_SIZE 128 24#define BUF_SIZE 128
24 25
25struct base64_test { 26struct base64_test {
26 const unsigned char in[BUF_SIZE]; 27 const unsigned char in[BUF_SIZE];
27 const size_t in_len; 28 const ssize_t in_len;
28 const unsigned char out[BUF_SIZE]; 29 const unsigned char out[BUF_SIZE];
29 const size_t out_len; 30 const ssize_t out_len;
30 const size_t valid_len; 31 const ssize_t valid_len;
31}; 32};
32 33
33/* 34/*
@@ -178,12 +179,12 @@ struct base64_test base64_no_nl_tests[] = {
178 179
179#define N_NO_NL_TESTS (sizeof(base64_no_nl_tests) / sizeof(*base64_no_nl_tests)) 180#define N_NO_NL_TESTS (sizeof(base64_no_nl_tests) / sizeof(*base64_no_nl_tests))
180 181
181int 182static int
182base64_encoding_test(int test_no, struct base64_test *bt, int test_nl) 183base64_encoding_test(int test_no, struct base64_test *bt, int test_nl)
183{ 184{
184 BIO *bio_b64, *bio_mem; 185 BIO *bio_b64, *bio_mem;
185 unsigned char *buf, *out; 186 unsigned char *buf, *out;
186 int i, len, b64len; 187 ssize_t i, len, b64len;
187 int failure = 0; 188 int failure = 0;
188 189
189 buf = malloc(BUF_SIZE); 190 buf = malloc(BUF_SIZE);
@@ -205,7 +206,7 @@ base64_encoding_test(int test_no, struct base64_test *bt, int test_nl)
205 206
206 len = BIO_write(bio_mem, bt->in, bt->in_len); 207 len = BIO_write(bio_mem, bt->in, bt->in_len);
207 if (len != bt->in_len) { 208 if (len != bt->in_len) {
208 fprintf(stderr, "FAIL: test %i - only wrote %i out of %i " 209 fprintf(stderr, "FAIL: test %i - only wrote %zi out of %zi "
209 "characters\n", test_no, len, bt->in_len); 210 "characters\n", test_no, len, bt->in_len);
210 failure = 1; 211 failure = 1;
211 goto done; 212 goto done;
@@ -232,8 +233,8 @@ base64_encoding_test(int test_no, struct base64_test *bt, int test_nl)
232 goto done; 233 goto done;
233 234
234 if (len != b64len) { 235 if (len != b64len) {
235 fprintf(stderr, "FAIL: test %i - encoding resulted in %i " 236 fprintf(stderr, "FAIL: test %i - encoding resulted in %zi "
236 "characters instead of %i\n", test_no, len, b64len); 237 "characters instead of %zi\n", test_no, len, b64len);
237 failure = 1; 238 failure = 1;
238 goto done; 239 goto done;
239 } 240 }
@@ -258,13 +259,13 @@ done:
258 return failure; 259 return failure;
259} 260}
260 261
261int 262static int
262base64_decoding_test(int test_no, struct base64_test *bt, int test_nl) 263base64_decoding_test(int test_no, struct base64_test *bt, int test_nl)
263{ 264{
264 BIO *bio_b64, *bio_mem; 265 BIO *bio_b64, *bio_mem;
265 char *buf, *input; 266 char *buf, *input;
267 ssize_t i, inlen, len;
266 int failure = 0; 268 int failure = 0;
267 int i, inlen, len;
268 269
269 buf = malloc(BUF_SIZE); 270 buf = malloc(BUF_SIZE);
270 if (buf == NULL) 271 if (buf == NULL)
@@ -295,8 +296,8 @@ base64_decoding_test(int test_no, struct base64_test *bt, int test_nl)
295 */ 296 */
296 len = BIO_read(bio_mem, buf, BUF_SIZE); 297 len = BIO_read(bio_mem, buf, BUF_SIZE);
297 if (len != bt->valid_len && (bt->in_len != 0 || len != -1)) { 298 if (len != bt->valid_len && (bt->in_len != 0 || len != -1)) {
298 fprintf(stderr, "FAIL: test %i - decoding resulted in %i " 299 fprintf(stderr, "FAIL: test %i - decoding resulted in %zi "
299 "characters instead of %i\n", test_no, len, bt->valid_len); 300 "characters instead of %zi\n", test_no, len, bt->valid_len);
300 fprintf(stderr, " input: "); 301 fprintf(stderr, " input: ");
301 for (i = 0; i < inlen; i++) 302 for (i = 0; i < inlen; i++)
302 fprintf(stderr, "%c", input[i]); 303 fprintf(stderr, "%c", input[i]);
@@ -340,7 +341,7 @@ main(int argc, char **argv)
340{ 341{
341 struct base64_test *bt; 342 struct base64_test *bt;
342 int failed = 0; 343 int failed = 0;
343 int i; 344 size_t i;
344 345
345 fprintf(stderr, "Starting combined tests...\n"); 346 fprintf(stderr, "Starting combined tests...\n");
346 347