remove errors with ./configure --enable-Werror

This commit is contained in:
Lev Walkin 2014-01-14 01:48:37 -08:00
parent aef10c36f7
commit 5b63acf7aa
15 changed files with 151 additions and 135 deletions

View File

@ -101,7 +101,7 @@ save_object_as(PDU_t *st, enum expectation exp, enum enctype how) {
}
static PDU_t *
load_object_from(const char *fname, enum expectation expectation, char *fbuf, size_t size, enum enctype how) {
load_object_from(const char *fname, enum expectation expectation, unsigned char *fbuf, size_t size, enum enctype how) {
asn_dec_rval_t rval;
PDU_t *st = 0;
size_t csize = 1;
@ -158,6 +158,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
rval.consumed /= 8;
}
break;
case AS_DER:
case AS_CXER:
assert(!"DER or CXER not supported for load");
}
fbuf_offset += rval.consumed;
fbuf_left -= rval.consumed;
@ -172,12 +175,12 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
if(how == AS_PER) {
fprintf(stderr, "[left %d, off %d, size %zd]\n",
fbuf_left, fbuf_offset, size);
assert(fbuf_offset == size);
assert(fbuf_offset == (ssize_t)size);
} else {
assert(fbuf_offset - size < 2
|| (fbuf_offset + 1 /* "\n" */ == size
|| (fbuf_offset + 1 /* "\n" */ == (ssize_t)size
&& fbuf[size - 1] == '\n')
|| (fbuf_offset + 2 /* "\r\n" */ == size
|| (fbuf_offset + 2 /* "\r\n" */ == (ssize_t)size
&& fbuf[size - 2] == '\r'
&& fbuf[size - 1] == '\n')
);
@ -227,7 +230,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
static void
process_XER_data(const char *fname, enum expectation expectation, char *fbuf, size_t size) {
process_XER_data(const char *fname, enum expectation expectation, unsigned char *fbuf, size_t size) {
PDU_t *st;
st = load_object_from(fname, expectation, fbuf, size, AS_XER);
@ -253,10 +256,10 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
switch(expectation) {
case EXP_DIFFERENT:
assert(!xer_encoding_equal(fbuf, size, buf, buf_offset));
assert(!xer_encoding_equal((char *)fbuf, size, (char *)buf, buf_offset));
break;
case EXP_BROKEN:
assert(!xer_encoding_equal(fbuf, size, buf, buf_offset));
assert(!xer_encoding_equal((char *)fbuf, size, (char *)buf, buf_offset));
break;
case EXP_CXER_EXACT:
buf[buf_offset++] = '\n';
@ -270,7 +273,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
break;
case EXP_OK:
case EXP_PER_NOCOMP:
assert(xer_encoding_equal(fbuf, size, buf, buf_offset));
assert(xer_encoding_equal((char *)fbuf, size, (char *)buf, buf_offset));
break;
}
@ -282,7 +285,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
*/
static int
process(const char *fname) {
char fbuf[4096];
unsigned char fbuf[4096];
char *ext = strrchr(fname, '.');
enum expectation expectation;
int rd;
@ -308,14 +311,14 @@ process(const char *fname) {
fprintf(stderr, "\nProcessing file [../%s]\n", fname);
snprintf(fbuf, sizeof(fbuf), "../data-119/%s", fname);
fp = fopen(fbuf, "r");
snprintf((char *)fbuf, sizeof(fbuf), "../data-119/%s", fname);
fp = fopen((char *)fbuf, "r");
assert(fp);
rd = fread(fbuf, 1, sizeof(fbuf), fp);
fclose(fp);
assert(rd < sizeof(fbuf)); /* expect small files */
assert(rd < (ssize_t)sizeof(fbuf)); /* expect small files */
process_XER_data(fname, expectation, fbuf, rd);

View File

@ -101,7 +101,7 @@ save_object_as(PDU_t *st, enum expectation exp, enum enctype how) {
}
static PDU_t *
load_object_from(const char *fname, enum expectation expectation, char *fbuf, size_t size, enum enctype how) {
load_object_from(const char *fname, enum expectation expectation, unsigned char *fbuf, size_t size, enum enctype how) {
asn_dec_rval_t rval;
PDU_t *st = 0;
size_t csize = 1;
@ -158,6 +158,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
rval.consumed /= 8;
}
break;
case AS_DER:
case AS_CXER:
assert(!"Unexpected DER or CXER load request");
}
fbuf_offset += rval.consumed;
fbuf_left -= rval.consumed;
@ -172,12 +175,12 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
if(how == AS_PER) {
fprintf(stderr, "[left %d, off %d, size %zd]\n",
fbuf_left, fbuf_offset, size);
assert(fbuf_offset == size);
assert(fbuf_offset == (ssize_t)size);
} else {
assert(fbuf_offset - size < 2
|| (fbuf_offset + 1 /* "\n" */ == size
|| (fbuf_offset + 1 /* "\n" */ == (ssize_t)size
&& fbuf[size - 1] == '\n')
|| (fbuf_offset + 2 /* "\r\n" */ == size
|| (fbuf_offset + 2 /* "\r\n" */ == (ssize_t)size
&& fbuf[size - 2] == '\r'
&& fbuf[size - 1] == '\n')
);
@ -195,7 +198,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
}
static int
xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
xer_encoding_equal(void *obufp, size_t osize, void *nbufp, size_t nsize) {
char *obuf = obufp;
char *nbuf = nbufp;
char *oend = obuf + osize;
char *nend = nbuf + nsize;
@ -227,7 +232,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
static void
process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ssize_t size) {
process_XER_data(const char *fname, enum expectation expectation, unsigned char *fbuf, ssize_t size) {
PDU_t *st;
st = load_object_from(fname, expectation, fbuf, size, AS_XER);
@ -260,12 +265,12 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ss
break;
case EXP_CXER_EXACT:
buf[buf_offset++] = '\n';
assert(size == buf_offset);
assert((ssize_t)size == (ssize_t)buf_offset);
assert(memcmp(fbuf, buf, size) == 0);
break;
case EXP_CXER_DIFF:
buf[buf_offset++] = '\n';
assert(size != buf_offset
assert((ssize_t)size != (ssize_t)buf_offset
|| memcmp(fbuf, buf, size));
break;
case EXP_OK:
@ -282,7 +287,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ss
*/
static int
process(const char *fname) {
char fbuf[4096];
unsigned char fbuf[4096];
char *ext = strrchr(fname, '.');
enum expectation expectation;
int rd;
@ -308,14 +313,14 @@ process(const char *fname) {
fprintf(stderr, "\nProcessing file [../%s]\n", fname);
snprintf(fbuf, sizeof(fbuf), "../data-119/%s", fname);
fp = fopen(fbuf, "r");
snprintf((char *)fbuf, sizeof(fbuf), "../data-119/%s", fname);
fp = fopen((char *)fbuf, "r");
assert(fp);
rd = fread(fbuf, 1, sizeof(fbuf), fp);
fclose(fp);
assert(rd < sizeof(fbuf)); /* expect small files */
assert(rd < (ssize_t)sizeof(fbuf)); /* expect small files */
process_XER_data(fname, expectation, fbuf, rd);

View File

@ -82,7 +82,7 @@ save_object_as(PDU_t *st, enum enctype how) {
}
static PDU_t *
load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, int mustfail) {
load_object_from(const char *fname, unsigned char *fbuf, size_t size, enum enctype how, int mustfail) {
asn_dec_rval_t rval;
PDU_t *st = 0;
ssize_t csize = 1;
@ -176,12 +176,12 @@ load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, i
if(how == AS_PER) {
fprintf(stderr, "[left %d, off %d, size %zd]\n",
fbuf_left, fbuf_offset, size);
assert(fbuf_offset == size);
assert(fbuf_offset == (ssize_t)size);
} else {
assert(fbuf_offset - size < 2
|| (fbuf_offset + 1 /* "\n" */ == size
|| (fbuf_offset + 1 /* "\n" */ == (ssize_t)size
&& fbuf[size - 1] == '\n')
|| (fbuf_offset + 2 /* "\r\n" */ == size
|| (fbuf_offset + 2 /* "\r\n" */ == (ssize_t)size
&& fbuf[size - 2] == '\r'
&& fbuf[size - 1] == '\n')
);
@ -193,7 +193,9 @@ load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, i
}
static int
xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
xer_encoding_equal(void *obufp, size_t osize, void *nbufp, size_t nsize) {
char *obuf = obufp;
char *nbuf = nbufp;
char *oend = obuf + osize;
char *nend = nbuf + nsize;
@ -225,9 +227,10 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
static void
compare_with_data_out(const char *fname, char *buf, size_t size) {
compare_with_data_out(const char *fname, void *datap, size_t size) {
char *data = datap;
char outName[256];
char fbuf[1024];
unsigned char fbuf[1024];
size_t rd;
FILE *f;
char lastChar;
@ -244,7 +247,7 @@ compare_with_data_out(const char *fname, char *buf, size_t size) {
if((compare && !mustfail) && getenv("REGENERATE")) {
f = fopen(outName, "w");
fwrite(buf, 1, size, f);
fwrite(data, 1, size, f);
fclose(f);
} else {
f = fopen(outName, "r");
@ -259,17 +262,17 @@ compare_with_data_out(const char *fname, char *buf, size_t size) {
if(compare) {
assert(rd == (size_t)size);
assert(memcmp(fbuf, buf, rd) == 0);
assert(memcmp(fbuf, data, rd) == 0);
fprintf(stderr, "XER->PER recoding .in->.out match.\n");
} else {
assert(rd != (size_t)size || memcmp(fbuf, buf, rd));
assert(rd != (size_t)size || memcmp(fbuf, data, rd));
fprintf(stderr, "XER->PER recoding .in->.out diverge.\n");
}
}
}
static void
process_XER_data(const char *fname, char *fbuf, size_t size) {
process_XER_data(const char *fname, unsigned char *fbuf, size_t size) {
PDU_t *st;
st = load_object_from(fname, fbuf, size, AS_XER, 0);
@ -289,9 +292,9 @@ process_XER_data(const char *fname, char *fbuf, size_t size) {
fprintf(stderr, "=== end ===\n");
if(fname[strlen(fname) - 4] == 'X')
assert(!xer_encoding_equal(fbuf, size, buf, buf_offset));
assert(!xer_encoding_equal((char *)fbuf, size, (char *)buf, buf_offset));
else
assert(xer_encoding_equal(fbuf, size, buf, buf_offset));
assert(xer_encoding_equal((char *)fbuf, size, (char *)buf, buf_offset));
asn_DEF_PDU.free_struct(&asn_DEF_PDU, st, 0);
}
@ -301,7 +304,7 @@ process_XER_data(const char *fname, char *fbuf, size_t size) {
*/
static int
process(const char *fname) {
char fbuf[4096];
unsigned char fbuf[4096];
char *ext = strrchr(fname, '.');
int rd;
FILE *fp;
@ -311,8 +314,8 @@ process(const char *fname) {
fprintf(stderr, "\nProcessing file [../%s]\n", fname);
snprintf(fbuf, sizeof(fbuf), "../data-126/%s", fname);
fp = fopen(fbuf, "r");
snprintf((char *)fbuf, sizeof(fbuf), "../data-126/%s", fname);
fp = fopen((char *)fbuf, "r");
assert(fp);
rd = fread(fbuf, 1, sizeof(fbuf), fp);

View File

@ -93,7 +93,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
if(erval.encoded != sizeof(buf1)) {
printf("%d != %d\n", (int)erval.encoded, (int)sizeof(buf1));
}
assert(erval.encoded == sizeof(buf1));
assert(erval.encoded == (ssize_t)sizeof(buf1));
for(i = 0; i < (ssize_t)sizeof(buf1); i++) {
if(buf1[i] != buf2[i]) {
fprintf(stderr, "Recreated buffer content mismatch:\n");

View File

@ -162,7 +162,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
assert(t.i.size == 1);
assert(t.i.buf[0] == 96);
assert(t.s.size == 3);
assert(strcmp(t.s.buf, "xyz") == 0);
assert(strcmp((char *)t.s.buf, "xyz") == 0);
if(buf == buf3) {
assert(t.b);
} else {

View File

@ -133,7 +133,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
buf_pos = 0;
der_encode(&asn_DEF_Forest, &t,
bytes_compare, buf1_reconstr);
assert(buf_pos == sizeof(buf1_reconstr));
assert(buf_pos == (ssize_t)sizeof(buf1_reconstr));
asn_fprint(stderr, &asn_DEF_Forest, &t);
xer_fprint(stderr, &asn_DEF_Forest, &t);

View File

@ -136,9 +136,9 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
assert(rval.code == RC_OK);
assert(rval.consumed == consumed);
assert(strcmp(tp->a.buf, "=<&>") == 0);
assert(strcmp(tp->b.choice.b1.buf, "z") == 0
&& strcmp(tp->b.choice.b2.buf, "z") == 0);
assert(strcmp((char *)tp->a.buf, "=<&>") == 0);
assert(strcmp((char *)tp->b.choice.b1.buf, "z") == 0
&& strcmp((char *)tp->b.choice.b2.buf, "z") == 0);
asn_fprint(stderr, &asn_DEF_T, tp);
xer_fprint(stderr, &asn_DEF_T, tp);
@ -169,7 +169,7 @@ buf_fill(const void *buffer, size_t size, void *app_key) {
static void
compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
asn_enc_rval_t erval;
int i;
size_t i;
buf_size = cmp_buf_size + 100;
buf = alloca(buf_size);
@ -180,15 +180,15 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
*/
erval = der_encode(&asn_DEF_T, tp, buf_fill, 0);
assert(erval.encoded != -1);
if(erval.encoded != cmp_buf_size) {
if(erval.encoded != (ssize_t)cmp_buf_size) {
printf("%zd != %zd\n", erval.encoded, cmp_buf_size);
}
assert(erval.encoded == cmp_buf_size);
assert(erval.encoded == (ssize_t)cmp_buf_size);
for(i = 0; i < cmp_buf_size; i++) {
if(buf[i] != cmp_buf[i]) {
fprintf(stderr, "Recreated buffer content mismatch:\n");
fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n",
i,
(int)i,
buf[i], cmp_buf[i],
buf[i], cmp_buf[i]
);
@ -198,70 +198,70 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
}
static void
partial_read(uint8_t *buf, size_t size) {
partial_read(uint8_t *data, size_t size) {
T_t t, *tp;
asn_dec_rval_t rval;
size_t i1, i2;
uint8_t *buf1 = alloca(size);
uint8_t *buf2 = alloca(size);
uint8_t *buf3 = alloca(size);
uint8_t *data1 = alloca(size);
uint8_t *data2 = alloca(size);
uint8_t *data3 = alloca(size);
fprintf(stderr, "\nPartial read sequence...\n");
/*
* Divide the space (size) into three blocks in various combinations:
* |<----->i1<----->i2<----->|
* ^ buf ^ buf+size
* ^ data ^ data+size
* Try to read block by block.
*/
for(i1 = 0; i1 < size; i1++) {
for(i2 = i1; i2 < size; i2++) {
uint8_t *chunk1 = buf;
uint8_t *chunk1 = data;
size_t size1 = i1;
uint8_t *chunk2 = buf + size1;
uint8_t *chunk2 = data + size1;
size_t size2 = i2 - i1;
uint8_t *chunk3 = buf + size1 + size2;
uint8_t *chunk3 = data + size1 + size2;
size_t size3 = size - size1 - size2;
fprintf(stderr, "\n%zd:{%zd, %zd, %zd}...\n",
size, size1, size2, size3);
memset(buf1, 0, size);
memset(buf2, 0, size);
memset(buf3, 0, size);
memcpy(buf1, chunk1, size1);
memcpy(buf2, chunk2, size2);
memcpy(buf3, chunk3, size3);
memset(data1, 0, size);
memset(data2, 0, size);
memset(data3, 0, size);
memcpy(data1, chunk1, size1);
memcpy(data2, chunk2, size2);
memcpy(data3, chunk3, size3);
tp = memset(&t, 0, sizeof(t));
fprintf(stderr, "=> Chunk 1 (%zd):\n", size1);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp,
buf1, size1);
data1, size1);
assert(rval.code == RC_WMORE);
assert(rval.consumed <= size1);
if(rval.consumed < size1) {
int leftover = size1 - rval.consumed;
memcpy(buf2, buf1 + rval.consumed, leftover);
memcpy(buf2 + leftover, chunk2, size2);
memcpy(data2, data1 + rval.consumed, leftover);
memcpy(data2 + leftover, chunk2, size2);
size2 += leftover;
}
fprintf(stderr, "=> Chunk 2 (%zd):\n", size2);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp,
buf2, size2);
data2, size2);
assert(rval.code == RC_WMORE);
assert(rval.consumed <= size2);
if(rval.consumed < size2) {
int leftover = size2 - rval.consumed;
memcpy(buf3, buf2 + rval.consumed, leftover);
memcpy(buf3 + leftover, chunk3, size3);
memcpy(data3, data2 + rval.consumed, leftover);
memcpy(data3 + leftover, chunk3, size3);
size3 += leftover;
}
fprintf(stderr, "=> Chunk 3 (%zd):\n", size3);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp,
buf3, size3);
data3, size3);
assert(rval.code == RC_OK);
assert(rval.consumed == size3);
@ -283,13 +283,13 @@ xer_cb(const void *buffer, size_t size, void *key) {
}
static void
check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
check_xer(uint8_t *data, uint8_t size, char *xer_sample) {
T_t *tp = 0;
asn_dec_rval_t rval;
asn_enc_rval_t er;
size_t xer_sample_len = strlen(xer_sample);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp, data, size);
assert(rval.code == RC_OK);
assert(rval.consumed == size);
assert(tp);
@ -300,7 +300,7 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
xer_buf[xer_off] = 0;
printf("[%s] (%zd/%zd) vs [%s] (%zd)\n",
xer_buf, er.encoded, xer_off, xer_sample, xer_sample_len);
assert(er.encoded == xer_off);
assert(er.encoded == (ssize_t)xer_off);
assert(xer_off == xer_sample_len);
assert(memcmp(xer_buf, xer_sample, xer_off) == 0);
}

View File

@ -155,8 +155,8 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
/*
assert(tp->string.size == 128);
assert(strncmp(tp->string.buf, "zz") == 0);
assert(strcmp(tp->b.choice.b1.buf, "z") == 0
&& strcmp(tp->b.choice.b2.buf, "z") == 0);
assert(strcmp((char *)tp->b.choice.b1.buf, "z") == 0
&& strcmp((char *)tp->b.choice.b2.buf, "z") == 0);
*/
}
@ -185,7 +185,7 @@ buf_fill(const void *bufp, size_t size, void *app_key) {
static void
compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
asn_enc_rval_t erval;
int i;
size_t i;
buf_size = cmp_buf_size + 100;
buffer = alloca(buf_size);
@ -196,15 +196,15 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
*/
erval = der_encode(&asn_DEF_T, tp, buf_fill, 0);
assert(erval.encoded != -1);
if(erval.encoded != cmp_buf_size) {
if(erval.encoded != (ssize_t)cmp_buf_size) {
printf("%zd != %zd\n", erval.encoded, cmp_buf_size);
}
assert(erval.encoded == cmp_buf_size);
assert(erval.encoded == (ssize_t)cmp_buf_size);
for(i = 0; i < cmp_buf_size; i++) {
if(buffer[i] != cmp_buf[i]) {
fprintf(stderr, "Recreated buffer content mismatch:\n");
fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n",
i,
(int)i,
buffer[i], cmp_buf[i],
buffer[i], cmp_buf[i]
);
@ -214,70 +214,70 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
}
static void
partial_read(uint8_t *buf, size_t size) {
partial_read(uint8_t *data, size_t size) {
T_t t, *tp;
asn_dec_rval_t rval;
size_t i1, i2;
uint8_t *buf1 = alloca(size);
uint8_t *buf2 = alloca(size);
uint8_t *buf3 = alloca(size);
uint8_t *data1 = alloca(size);
uint8_t *data2 = alloca(size);
uint8_t *data3 = alloca(size);
fprintf(stderr, "\nPartial read sequence...\n");
/*
* Divide the space (size) into three blocks in various combinations:
* |<----->i1<----->i2<----->|
* ^ buf ^ buf+size
* ^ data ^ data+size
* Try to read block by block.
*/
for(i1 = 0; i1 < size; i1++) {
for(i2 = i1; i2 < size; i2++) {
uint8_t *chunk1 = buf;
uint8_t *chunk1 = data;
size_t size1 = i1;
uint8_t *chunk2 = buf + size1;
uint8_t *chunk2 = data + size1;
size_t size2 = i2 - i1;
uint8_t *chunk3 = buf + size1 + size2;
uint8_t *chunk3 = data + size1 + size2;
size_t size3 = size - size1 - size2;
fprintf(stderr, "\n%zd:{%zd, %zd, %zd}...\n",
size, size1, size2, size3);
memset(buf1, 0, size);
memset(buf2, 0, size);
memset(buf3, 0, size);
memcpy(buf1, chunk1, size1);
memcpy(buf2, chunk2, size2);
memcpy(buf3, chunk3, size3);
memset(data1, 0, size);
memset(data2, 0, size);
memset(data3, 0, size);
memcpy(data1, chunk1, size1);
memcpy(data2, chunk2, size2);
memcpy(data3, chunk3, size3);
tp = memset(&t, 0, sizeof(t));
fprintf(stderr, "=> Chunk 1 (%zd):\n", size1);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp,
buf1, size1);
data1, size1);
assert(rval.code == RC_WMORE);
assert(rval.consumed <= size1);
if(rval.consumed < size1) {
int leftover = size1 - rval.consumed;
memcpy(buf2, buf1 + rval.consumed, leftover);
memcpy(buf2 + leftover, chunk2, size2);
memcpy(data2, data1 + rval.consumed, leftover);
memcpy(data2 + leftover, chunk2, size2);
size2 += leftover;
}
fprintf(stderr, "=> Chunk 2 (%zd):\n", size2);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp,
buf2, size2);
data2, size2);
assert(rval.code == RC_WMORE);
assert(rval.consumed <= size2);
if(rval.consumed < size2) {
int leftover = size2 - rval.consumed;
memcpy(buf3, buf2 + rval.consumed, leftover);
memcpy(buf3 + leftover, chunk3, size3);
memcpy(data3, data2 + rval.consumed, leftover);
memcpy(data3 + leftover, chunk3, size3);
size3 += leftover;
}
fprintf(stderr, "=> Chunk 3 (%zd):\n", size3);
rval = ber_decode(0, &asn_DEF_T, (void **)&tp,
buf3, size3);
data3, size3);
assert(rval.code == RC_OK);
assert(rval.consumed == size3);

View File

@ -61,7 +61,7 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
assert(rval.consumed == consumed);
assert(tp->choice.seq.string.size == 16);
assert(strcmp(tp->choice.seq.string.buf, "zzzzzzzzzzzzzzzz") == 0);
assert(strcmp((char *)tp->choice.seq.string.buf, "zzzzzzzzzzzzzzzz") == 0);
assert(tp->choice.seq.alpha == NULL);
assert(tp->choice.seq.beta);
assert(*tp->choice.seq.beta == 0x4b4b4b4b);

View File

@ -102,7 +102,7 @@ main() {
assert(ret == 0);
assert(t1_new.i == 112233);
assert(t1_new.any.size == sizeof(test_any_buf1));
assert(t1_new.any.size == (ssize_t)sizeof(test_any_buf1));
assert(memcmp(t1_new.any.buf, test_any_buf1, sizeof(test_any_buf1)) == 0);
/*
@ -121,7 +121,7 @@ main() {
assert(ret == 0);
assert(t1_new.i == -112233);
assert(t1_new.any.size == sizeof(test_any_buf2));
assert(t1_new.any.size == (ssize_t)sizeof(test_any_buf2));
assert(memcmp(t1_new.any.buf, test_any_buf2, sizeof(test_any_buf2)) == 0);
/*
@ -160,7 +160,7 @@ main() {
assert(ret == 0);
assert(t2_new.i == 332211);
assert(t2_new.any->size == sizeof(test_any_buf1));
assert(t2_new.any->size == (ssize_t)sizeof(test_any_buf1));
assert(memcmp(t2_new.any->buf, test_any_buf1, sizeof(test_any_buf1)) == 0);
/*
@ -180,7 +180,7 @@ main() {
assert(ret == 0);
assert(t2_new.i == 0);
assert(t2_new.any->size == sizeof(test_any_buf2));
assert(t2_new.any->size == (ssize_t)sizeof(test_any_buf2));
assert(memcmp(t2_new.any->buf, test_any_buf2, sizeof(test_any_buf2)) == 0);
/*

View File

@ -57,12 +57,12 @@ save_object(T_t *st) {
}
static T_t *
load_object(enum expectation expectation, char *fbuf, size_t size) {
load_object(enum expectation expectation, unsigned char *fbuf, size_t size) {
asn_dec_rval_t rval;
T_t *st = 0;
int csize;
fprintf(stderr, "LOADING OBJECT OF SIZE %d\n", size);
fprintf(stderr, "LOADING OBJECT OF SIZE %d\n", (int)size);
/* Perform multiple iterations with multiple chunks sizes */
for(csize = 1; csize < 20; csize += 1) {
@ -90,7 +90,7 @@ load_object(enum expectation expectation, char *fbuf, size_t size) {
if(expectation != EXP_BROKEN) {
assert(rval.code == RC_OK);
assert(fbuf_offset == size);
assert(fbuf_offset == (ssize_t)size);
} else {
assert(rval.code != RC_OK);
fprintf(stderr, "Failed, but this was expected\n");
@ -105,7 +105,7 @@ load_object(enum expectation expectation, char *fbuf, size_t size) {
static void
process_data(enum expectation expectation, char *fbuf, ssize_t size) {
process_data(enum expectation expectation, unsigned char *fbuf, ssize_t size) {
T_t *st;
int ret;
@ -113,7 +113,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
if(!st) return;
ret = save_object(st);
assert(buf_offset < sizeof(buf));
assert(buf_offset < (ssize_t)sizeof(buf));
assert(ret == 0);
switch(expectation) {
@ -129,7 +129,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
|| memcmp(buf, fbuf, buf_offset));
break;
case EXP_OK:
assert(buf_offset == size);
assert(buf_offset == (ssize_t)size);
assert(memcmp(buf, fbuf, buf_offset) == 0);
break;
}
@ -142,7 +142,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
*/
static int
process(const char *fname) {
char fbuf[4096];
unsigned char fbuf[4096];
char *ext = strrchr(fname, '.');
enum expectation expectation;
int ret;
@ -175,7 +175,7 @@ process(const char *fname) {
rd = fread(fbuf, 1, sizeof(fbuf), fp);
fclose(fp);
assert(rd < sizeof(fbuf)); /* expect small files */
assert(rd < (ssize_t)sizeof(fbuf)); /* expect small files */
process_data(expectation, fbuf, rd);

View File

@ -10,6 +10,7 @@
#include <sys/types.h>
#include <unistd.h> /* for chdir(2) */
#include <string.h>
#include <ctype.h>
#include <dirent.h>
#include <assert.h>
#include <errno.h>
@ -88,7 +89,7 @@ save_object_as(PDU_t *st, enum der_or_xer how) {
}
static PDU_t *
load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der_or_xer how) {
load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size, enum der_or_xer how) {
asn_dec_rval_t rval;
asn_dec_rval_t (*zer_decode)(struct asn_codec_ctx_s *,
asn_TYPE_descriptor_t *, void **, const void *, size_t);
@ -141,12 +142,12 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
if(expectation != EXP_BROKEN) {
assert(rval.code == RC_OK);
if(how == AS_DER) {
assert(fbuf_offset == size);
assert(fbuf_offset == (ssize_t)size);
} else {
assert(fbuf_offset - size < 2
|| (fbuf_offset + 1 /* "\n" */ == size
|| (fbuf_offset + 1 /* "\n" */ == (ssize_t)size
&& fbuf[size - 1] == '\n')
|| (fbuf_offset + 2 /* "\r\n" */ == size
|| (fbuf_offset + 2 /* "\r\n" */ == (ssize_t)size
&& fbuf[size - 2] == '\r'
&& fbuf[size - 1] == '\n')
);
@ -164,7 +165,9 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
}
static int
xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
xer_encoding_equal(void *obufp, size_t osize, void *nbufp, size_t nsize) {
char *obuf = obufp;
char *nbuf = nbufp;
char *oend = obuf + osize;
char *nend = nbuf + nsize;
@ -196,7 +199,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
static void
process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
process_XER_data(enum expectation expectation, unsigned char *fbuf, size_t size) {
PDU_t *st;
st = load_object_from(expectation, fbuf, size, AS_XER);
@ -226,12 +229,12 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
break;
case EXP_CXER_EXACT:
buf[buf_offset++] = '\n';
assert(size == buf_offset);
assert((ssize_t)size == buf_offset);
assert(memcmp(fbuf, buf, size) == 0);
break;
case EXP_CXER_DIFF:
buf[buf_offset++] = '\n';
assert(size != buf_offset
assert((ssize_t)size != buf_offset
|| memcmp(fbuf, buf, size));
break;
case EXP_OK:
@ -247,7 +250,7 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
*/
static int
process(const char *fname) {
char fbuf[4096];
unsigned char fbuf[4096];
char *ext = strrchr(fname, '.');
enum expectation expectation;
int ret;
@ -282,7 +285,7 @@ process(const char *fname) {
rd = fread(fbuf, 1, sizeof(fbuf), fp);
fclose(fp);
assert(rd < sizeof(fbuf)); /* expect small files */
assert(rd < (ssize_t)sizeof(fbuf)); /* expect small files */
process_XER_data(expectation, fbuf, rd);

View File

@ -78,7 +78,7 @@ save_object_as(PDU_t *st, enum der_or_xer how) {
}
static PDU_t *
load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der_or_xer how) {
load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size, enum der_or_xer how) {
asn_dec_rval_t rval;
asn_dec_rval_t (*zer_decode)(struct asn_codec_ctx_s *,
asn_TYPE_descriptor_t *, void **, const void *, size_t);
@ -131,12 +131,12 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
if(expectation != EXP_BROKEN) {
assert(rval.code == RC_OK);
if(how == AS_DER) {
assert(fbuf_offset == size);
assert(fbuf_offset == (ssize_t)size);
} else {
assert(fbuf_offset - size < 2
|| (fbuf_offset + 1 /* "\n" */ == size
|| (fbuf_offset + 1 /* "\n" */ == (ssize_t)size
&& fbuf[size - 1] == '\n')
|| (fbuf_offset + 2 /* "\r\n" */ == size
|| (fbuf_offset + 2 /* "\r\n" */ == (ssize_t)size
&& fbuf[size - 2] == '\r'
&& fbuf[size - 1] == '\n')
);
@ -154,7 +154,9 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
}
static int
xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
xer_encoding_equal(void *obufp, size_t osize, void *nbufp, size_t nsize) {
char *obuf = obufp;
char *nbuf = nbufp;
char *oend = obuf + osize;
char *nend = nbuf + nsize;
@ -186,7 +188,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
static void
process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
process_XER_data(enum expectation expectation, unsigned char *fbuf, size_t size) {
PDU_t *st;
st = load_object_from(expectation, fbuf, size, AS_XER);
@ -224,7 +226,7 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
*/
static int
process(const char *fname) {
char fbuf[4096];
unsigned char fbuf[4096];
char *ext = strrchr(fname, '.');
enum expectation expectation;
int ret;
@ -257,7 +259,7 @@ process(const char *fname) {
rd = fread(fbuf, 1, sizeof(fbuf), fp);
fclose(fp);
assert(rd < sizeof(fbuf)); /* expect small files */
assert(rd > 0 && (size_t)rd < sizeof(fbuf)); /* expect small files */
process_XER_data(expectation, fbuf, rd);

View File

@ -704,8 +704,8 @@ native_long_sign(asn1cnst_range_t *r) {
if(r->left.type == ARE_VALUE
&& r->left.value >= 0
&& r->right.type == ARE_VALUE
&& r->right.value > 2147483647UL
&& r->right.value <= 4294967295UL) {
&& r->right.value > 2147483647
&& (unsigned long)r->right.value <= 4294967295UL) {
if(r->el_count == 0
&& r->left.value == 0
&& r->right.value == 4294967295UL)

View File

@ -379,7 +379,7 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
&& left.value >= 0
&& right.type == ARE_VALUE
&& right.value > 2147483647
&& right.value <= 4294967295UL)
&& (unsigned long)right.value <= 4294967295UL)
return FL_FITS_UNSIGN;