enforsed compilation with -W -Werror
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@10 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c
index 19b6ff2..4914b20 100644
--- a/skeletons/BIT_STRING.c
+++ b/skeletons/BIT_STRING.c
@@ -66,6 +66,8 @@
uint8_t *end;
char *p = scratch;
+ (void)td; /* Unused argument */
+
if(!st || !st->buf) return cb("<absent>", 8, app_key);
ilevel += 4;
diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c
index 596974e..93584c8 100644
--- a/skeletons/BMPString.c
+++ b/skeletons/BMPString.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_BMPString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
/*
@@ -37,6 +38,9 @@
char scratch[128]; /* Scratchpad buffer */
char *p;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(!st || !st->buf) return cb("<absent>", 8, app_key);
wchar = (uint16_t *)st->buf;
diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c
index 705d37e..9391316 100644
--- a/skeletons/BOOLEAN.c
+++ b/skeletons/BOOLEAN.c
@@ -21,7 +21,8 @@
asn1_DEF_BOOLEAN_tags,
sizeof(asn1_DEF_BOOLEAN_tags)/sizeof(asn1_DEF_BOOLEAN_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
/*
@@ -33,7 +34,7 @@
int tag_mode) {
BOOLEAN_t *st = *bool_structure;
ber_dec_rval_t rval;
- ber_dec_ctx_t ctx = { 0 };
+ ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
ber_tlv_len_t length;
ber_tlv_len_t lidx;
@@ -61,7 +62,7 @@
buf_ptr += rval.consumed;
size -= rval.consumed;
- if(length > size) {
+ if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
rval.consumed = 0;
return rval;
@@ -128,6 +129,9 @@
asn_app_consume_bytes_f *cb, void *app_key) {
const BOOLEAN_t *st = sptr;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(st) {
if(st->value)
return cb("TRUE", 4, app_key);
diff --git a/skeletons/ENUMERATED.c b/skeletons/ENUMERATED.c
index 1f1ae89..3fff368 100644
--- a/skeletons/ENUMERATED.c
+++ b/skeletons/ENUMERATED.c
@@ -21,6 +21,7 @@
asn1_DEF_ENUMERATED_tags,
sizeof(asn1_DEF_ENUMERATED_tags)/sizeof(asn1_DEF_ENUMERATED_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Primitive */
+ 0, /* Primitive */
+ 0 /* No specifics */
};
diff --git a/skeletons/GeneralString.c b/skeletons/GeneralString.c
index d69c5f1..6bc7e47 100644
--- a/skeletons/GeneralString.c
+++ b/skeletons/GeneralString.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_GeneralString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 01d7a73..1dadb92 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -30,6 +30,7 @@
/ sizeof(asn1_DEF_GeneralizedTime_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
#endif /* __NO_ASN_TABLE__ */
@@ -59,6 +60,9 @@
asn_app_consume_bytes_f *cb, void *app_key) {
const GeneralizedTime_t *st = sptr;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(st && st->buf) {
char buf[32];
struct tm tm;
@@ -72,7 +76,7 @@
"%04d-%02d-%02d %02d:%02d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
- assert(ret > 0 && ret < sizeof(buf));
+ assert(ret > 0 && ret < (int)sizeof(buf));
return cb(buf, ret, app_key);
} else {
return cb("<absent>", 8, app_key);
diff --git a/skeletons/GraphicString.c b/skeletons/GraphicString.c
index 5c89685..412f3c7 100644
--- a/skeletons/GraphicString.c
+++ b/skeletons/GraphicString.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_GraphicString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/IA5String.c b/skeletons/IA5String.c
index c4afcb0..902de85 100644
--- a/skeletons/IA5String.c
+++ b/skeletons/IA5String.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_IA5String_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
int
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index b1a8c29..d20379f 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -23,7 +23,8 @@
asn1_DEF_INTEGER_tags,
sizeof(asn1_DEF_INTEGER_tags)/sizeof(asn1_DEF_INTEGER_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
/*
@@ -34,7 +35,7 @@
void **int_structure, void *buf_ptr, size_t size, int tag_mode) {
INTEGER_t *st = *int_structure;
ber_dec_rval_t rval;
- ber_dec_ctx_t ctx = { 0 };
+ ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
ber_tlv_len_t length;
/*
@@ -67,7 +68,7 @@
*/
buf_ptr += rval.consumed;
size -= rval.consumed;
- if(length > size) {
+ if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
rval.consumed = 0;
return rval;
@@ -193,25 +194,28 @@
char *p;
int ret;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(!st && !st->buf) return cb("<absent>", 8, app_key);
if(st->size == 0)
return cb("0", 1, app_key);
/* Simple case: the integer size is small */
- if(st->size < sizeof(accum) || (st->buf[0] & 0x80)) {
+ if((size_t)st->size < sizeof(accum) || (st->buf[0] & 0x80)) {
accum = (st->buf[0] & 0x80) ? -1 : 0;
for(; buf < buf_end; buf++)
accum = (accum << 8) | *buf;
ret = snprintf(scratch, sizeof(scratch), "%ld", accum);
- assert(ret > 0 && ret < sizeof(scratch));
+ assert(ret > 0 && ret < (int)sizeof(scratch));
return cb(scratch, ret, app_key);
}
/* Output in the long xx:yy:zz... format */
for(p = scratch; buf < buf_end; buf++) {
static char h2c[16] = "0123456789ABCDEF";
- if((p - scratch) >= (sizeof(scratch) / 2)) {
+ if((p - scratch) >= (ssize_t)(sizeof(scratch) / 2)) {
/* Flush buffer */
if(cb(scratch, p - scratch, app_key))
return -1;
diff --git a/skeletons/ISO646String.c b/skeletons/ISO646String.c
index 08b3169..2df623c 100644
--- a/skeletons/ISO646String.c
+++ b/skeletons/ISO646String.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_ISO646String_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/NULL.c b/skeletons/NULL.c
index 9027e2c..4ea0669 100644
--- a/skeletons/NULL.c
+++ b/skeletons/NULL.c
@@ -22,7 +22,8 @@
asn1_DEF_NULL_tags,
sizeof(asn1_DEF_NULL_tags)/sizeof(asn1_DEF_NULL_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
der_enc_rval_t
@@ -43,6 +44,10 @@
int
NULL_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
+
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(sptr) {
return cb("<present>", 9, app_key);
} else {
diff --git a/skeletons/NativeEnumerated.c b/skeletons/NativeEnumerated.c
index b6d21ed..bfb2bff 100644
--- a/skeletons/NativeEnumerated.c
+++ b/skeletons/NativeEnumerated.c
@@ -28,5 +28,6 @@
asn1_DEF_NativeEnumerated_tags,
sizeof(asn1_DEF_NativeEnumerated_tags)/sizeof(asn1_DEF_NativeEnumerated_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c
index d42540e..8203695 100644
--- a/skeletons/NativeInteger.c
+++ b/skeletons/NativeInteger.c
@@ -30,7 +30,8 @@
asn1_DEF_NativeInteger_tags,
sizeof(asn1_DEF_NativeInteger_tags)/sizeof(asn1_DEF_NativeInteger_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
/*
@@ -41,7 +42,7 @@
void **int_ptr, void *buf_ptr, size_t size, int tag_mode) {
int *Int = *int_ptr;
ber_dec_rval_t rval;
- ber_dec_ctx_t ctx = { 0 };
+ ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
ber_tlv_len_t length;
/*
@@ -74,7 +75,7 @@
*/
buf_ptr += rval.consumed;
size -= rval.consumed;
- if(length > size) {
+ if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
rval.consumed = 0;
return rval;
@@ -168,9 +169,12 @@
char scratch[32];
int ret;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(Int) {
ret = snprintf(scratch, sizeof(scratch), "%d", *Int);
- assert(ret > 0 && ret < sizeof(scratch));
+ assert(ret > 0 && ret < (int)sizeof(scratch));
return cb(scratch, ret, app_key);
} else {
return cb("<absent>", 8, app_key);
diff --git a/skeletons/NumericString.c b/skeletons/NumericString.c
index a007496..ba58923 100644
--- a/skeletons/NumericString.c
+++ b/skeletons/NumericString.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_NumericString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
int
diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c
index bcbcdca..0a27c8c 100644
--- a/skeletons/OBJECT_IDENTIFIER.c
+++ b/skeletons/OBJECT_IDENTIFIER.c
@@ -24,7 +24,8 @@
sizeof(asn1_DEF_OBJECT_IDENTIFIER_tags)
/ sizeof(asn1_DEF_OBJECT_IDENTIFIER_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
@@ -94,8 +95,8 @@
unsigned long accum;
uint8_t *arcend = arcbuf + arclen;
- if(arclen * 7 > 8 * sizeof(accum)) {
- if(arclen * 7 <= 8 * (sizeof(accum) + 1)) {
+ if((size_t)arclen * 7 > 8 * sizeof(accum)) {
+ if((size_t)arclen * 7 <= 8 * (sizeof(accum) + 1)) {
if((*arcbuf & ~0x8f)) {
errno = ERANGE; /* Overflow */
return -1;
@@ -110,8 +111,8 @@
for(accum = 0; arcbuf < arcend; arcbuf++)
accum = (accum << 7) | (*arcbuf & ~0x80);
+ assert(accum >= (unsigned long)-add);
accum += add; /* Actually, a negative value */
- assert(accum >= 0);
*rvalue = accum;
@@ -144,6 +145,9 @@
int add = 0;
int i;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(!st || !st->buf)
return cb("<absent>", 8, app_key);
diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index fc5c532..53a1a0d 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -25,6 +25,7 @@
/ sizeof(asn1_DEF_OCTET_STRING_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine (primitive and constructed) */
+ 0 /* No specifics */
};
#define _CH_PHASE(ctx, inc) do { \
@@ -48,27 +49,27 @@
return rval; \
} while(0)
-#define APPEND(bufptr, bufsize) do { \
- int _ns = ctx->step; /* Allocated */ \
- if(_ns <= (st->size + bufsize)) { \
- void *ptr; \
- do { _ns = _ns ? _ns<<2 : 16; } \
- while(_ns <= (st->size + bufsize)); \
- ptr = REALLOC(st->buf, _ns); \
- if(ptr) { \
- st->buf = ptr; \
- ctx->step = _ns; \
- } else { \
- RETURN(RC_FAIL); \
- } \
- } \
- memcpy(st->buf + st->size, bufptr, bufsize); \
- st->size += bufsize; \
- if(st->size < 0) \
- /* Why even care?.. JIC */ \
- RETURN(RC_FAIL); \
- /* Convenient nul-termination */ \
- st->buf[st->size] = '\0'; \
+#define APPEND(bufptr, bufsize) do { \
+ size_t _ns = ctx->step; /* Allocated */ \
+ if(_ns <= (size_t)(st->size + bufsize)) { \
+ void *ptr; \
+ do { _ns = _ns ? _ns<<2 : 16; } \
+ while(_ns <= (size_t)(st->size + bufsize)); \
+ ptr = REALLOC(st->buf, _ns); \
+ if(ptr) { \
+ st->buf = ptr; \
+ ctx->step = _ns; \
+ } else { \
+ RETURN(RC_FAIL); \
+ } \
+ } \
+ memcpy(st->buf + st->size, bufptr, bufsize); \
+ st->size += bufsize; \
+ if(st->size < 0) \
+ /* Why even care?.. JIC */ \
+ RETURN(RC_FAIL); \
+ /* Convenient nul-termination */ \
+ st->buf[st->size] = '\0'; \
} while(0)
/*
@@ -315,7 +316,7 @@
assert(sel->left >= 0);
- len = (size < sel->left) ? size : sel->left;
+ len = ((ber_tlv_len_t)size < sel->left) ? size : sel->left;
if(len > 0) {
if(is_bit_str && sel->bits_chopped == 0) {
/*
@@ -350,7 +351,7 @@
/*
* Primitive form, no stack required.
*/
- if(size < ctx->left) {
+ if(size < (size_t)ctx->left) {
APPEND(buf_ptr, size);
ctx->left -= size;
ADVANCE(size);
@@ -465,6 +466,8 @@
size_t i;
int ret;
+ (void)td; /* Unused argument */
+
if(!st || !st->buf) return cb("<absent>", 8, app_key);
/*
@@ -494,6 +497,9 @@
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
const OCTET_STRING_t *st = sptr;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(st && st->buf) {
return cb(st->buf, st->size, app_key);
} else {
diff --git a/skeletons/ObjectDescriptor.c b/skeletons/ObjectDescriptor.c
index 5a39380..db699ca 100644
--- a/skeletons/ObjectDescriptor.c
+++ b/skeletons/ObjectDescriptor.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_ObjectDescriptor_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/PrintableString.c b/skeletons/PrintableString.c
index 32ee7da..8589bd2 100644
--- a/skeletons/PrintableString.c
+++ b/skeletons/PrintableString.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_PrintableString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/RELATIVE-OID.c b/skeletons/RELATIVE-OID.c
index f657210..4fdad3d 100644
--- a/skeletons/RELATIVE-OID.c
+++ b/skeletons/RELATIVE-OID.c
@@ -24,7 +24,8 @@
sizeof(asn1_DEF_RELATIVE_OID_tags)
/ sizeof(asn1_DEF_RELATIVE_OID_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
- 0 /* Always in primitive form */
+ 0, /* Always in primitive form */
+ 0 /* No specifics */
};
int
@@ -34,6 +35,9 @@
int startn;
int i;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(!st || !st->buf)
return cb("<absent>", 8, app_key);
diff --git a/skeletons/T61String.c b/skeletons/T61String.c
index e6dceb7..2ba5d32 100644
--- a/skeletons/T61String.c
+++ b/skeletons/T61String.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_T61String_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/TeletexString.c b/skeletons/TeletexString.c
index 1076c8a..dafbd58 100644
--- a/skeletons/TeletexString.c
+++ b/skeletons/TeletexString.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_TeletexString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/UTCTime.c b/skeletons/UTCTime.c
index e2f758e..5ce2708 100644
--- a/skeletons/UTCTime.c
+++ b/skeletons/UTCTime.c
@@ -29,6 +29,7 @@
/ sizeof(asn1_DEF_UTCTime_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
#endif /* __NO_ASN_TABLE__ */
@@ -58,6 +59,9 @@
asn_app_consume_bytes_f *cb, void *app_key) {
const UTCTime_t *st = sptr;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(st && st->buf) {
char buf[32];
struct tm tm;
@@ -71,7 +75,7 @@
"%04d-%02d-%02d %02d:%02d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
- assert(ret > 0 && ret < sizeof(buf));
+ assert(ret > 0 && ret < (int)sizeof(buf));
return cb(buf, ret, app_key);
} else {
return cb("<absent>", 8, app_key);
@@ -83,7 +87,8 @@
char buf[17+2]; /* "AAMMJJhhmmss+hhmm" = 17, + 2 = 19 */
GeneralizedTime_t gt;
- if(!st || !st->buf || st->size < 11 || st->size > (sizeof(buf) - 2)) {
+ if(!st || !st->buf
+ || st->size < 11 || st->size > ((int)sizeof(buf) - 2)) {
errno = EINVAL;
return -1;
}
diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c
index fdd13d8..4ec15b8 100644
--- a/skeletons/UTF8String.c
+++ b/skeletons/UTF8String.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_UTF8String_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
static int _UTF8String_h1[16] = {
@@ -104,6 +105,9 @@
asn_app_consume_bytes_f *cb, void *app_key) {
const UTF8String_t *st = sptr;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(st && st->buf) {
return cb(st->buf, st->size, app_key);
} else {
diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c
index 7d75e07..1e3444e 100644
--- a/skeletons/UniversalString.c
+++ b/skeletons/UniversalString.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_UniversalString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
@@ -35,6 +36,9 @@
char scratch[128]; /* Scratchpad buffer */
char *p;
+ (void)td; /* Unused argument */
+ (void)ilevel; /* Unused argument */
+
if(!st || !st->buf) return cb("<absent>", 8, app_key);
wchar = (uint32_t *)st->buf;
diff --git a/skeletons/VideotexString.c b/skeletons/VideotexString.c
index ab92ebd..d9293be 100644
--- a/skeletons/VideotexString.c
+++ b/skeletons/VideotexString.c
@@ -23,5 +23,6 @@
/ sizeof(asn1_DEF_VideotexString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/VisibleString.c b/skeletons/VisibleString.c
index af9525f..4a335a3 100644
--- a/skeletons/VisibleString.c
+++ b/skeletons/VisibleString.c
@@ -23,6 +23,7 @@
/ sizeof(asn1_DEF_VisibleString_tags[0]),
1, /* Single UNIVERSAL tag may be implicitly overriden */
-1, /* Both ways are fine */
+ 0 /* No specifics */
};
diff --git a/skeletons/ber_decoder.c b/skeletons/ber_decoder.c
index 135e791..ab8d671 100644
--- a/skeletons/ber_decoder.c
+++ b/skeletons/ber_decoder.c
@@ -210,7 +210,7 @@
ADVANCE(tag_len + len_len);
limit_len -= (tag_len + len_len);
- if(size > limit_len) {
+ if((ssize_t)size > limit_len) {
/*
* Make sure that we won't consume more bytes
* from the large buffer than the inferred limit.
diff --git a/skeletons/ber_tlv_length.c b/skeletons/ber_tlv_length.c
index cd08f6a..71850f0 100644
--- a/skeletons/ber_tlv_length.c
+++ b/skeletons/ber_tlv_length.c
@@ -24,7 +24,7 @@
return 1;
} else {
ber_tlv_len_t len;
- ssize_t skipped;
+ size_t skipped;
if(_is_constructed && oct == 0x80) {
*len_r = -1; /* Indefinite length */
@@ -65,7 +65,7 @@
ber_tlv_len_t vlen; /* Length of V in TLV */
ssize_t tl; /* Length of L in TLV */
ssize_t ll; /* Length of L in TLV */
- ssize_t skip;
+ size_t skip;
/*
* Determine the size of L in TLV.
@@ -118,7 +118,7 @@
ssize_t
der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) {
- ssize_t computed_size; /* Size of len encoding */
+ size_t computed_size; /* Size of len encoding */
uint8_t *buf = bufp;
uint8_t *end;
int i;
diff --git a/skeletons/ber_tlv_tag.c b/skeletons/ber_tlv_tag.c
index 50c9e69..a6cccec 100644
--- a/skeletons/ber_tlv_tag.c
+++ b/skeletons/ber_tlv_tag.c
@@ -10,7 +10,7 @@
ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
ber_tlv_tag_t val;
ber_tlv_tag_t tclass;
- ssize_t skipped;
+ size_t skipped;
if(size == 0)
return 0;
@@ -61,7 +61,7 @@
ssize_t ret;
ret = ber_tlv_tag_snprint(tag, buf, sizeof(buf));
- if(ret >= sizeof(buf) || ret < 2) {
+ if(ret >= (ssize_t)sizeof(buf) || ret < 2) {
errno = EPERM;
return -1;
}
@@ -103,7 +103,7 @@
ber_tlv_tag_t tval = BER_TAG_VALUE(tag);
uint8_t *buf = bufp;
uint8_t *end;
- ssize_t computed_size;
+ size_t computed_size;
int i;
if(tval <= 30) {
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index e6d08ba..1ecbbce 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -11,7 +11,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
-#define LEFT ((size<ctx->left)?size:ctx->left)
+#define LEFT ((size<(size_t)ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
@@ -24,7 +24,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
-#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size)
+#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index 6704dd8..7168967 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -9,7 +9,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
-#define LEFT ((size<ctx->left)?size:ctx->left)
+#define LEFT ((size<(size_t)ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
@@ -22,7 +22,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
-#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size)
+#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c
index cdddf60..a839949 100644
--- a/skeletons/constr_SEQUENCE_OF.c
+++ b/skeletons/constr_SEQUENCE_OF.c
@@ -68,7 +68,7 @@
encoding_size += erval.encoded;
}
- if(computed_size != encoding_size) {
+ if(computed_size != (size_t)encoding_size) {
/*
* Encoded size is not equal to the computed size.
*/
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index f1df9c1..d0cac1d 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -11,7 +11,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
-#define LEFT ((size<ctx->left)?size:ctx->left)
+#define LEFT ((size<(size_t)ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
@@ -24,7 +24,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
-#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size)
+#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c
index 9dcf638..e398db8 100644
--- a/skeletons/constr_SET_OF.c
+++ b/skeletons/constr_SET_OF.c
@@ -10,7 +10,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
-#define LEFT ((size<ctx->left)?size:ctx->left)
+#define LEFT ((size<(size_t)ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
@@ -23,7 +23,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
-#define SIZE_VIOLATION (ctx->left != -1 && ctx->left <= size)
+#define SIZE_VIOLATION (ctx->left != -1 && (size_t)ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
@@ -178,7 +178,7 @@
}
/* Outmost tag may be unknown and cannot be fetched/compared */
- if(element->tag != -1) {
+ if(element->tag != (ber_tlv_tag_t)-1) {
if(BER_TAGS_EQUAL(tlv_tag, element->tag)) {
/*
* The new list member of expected type has arrived.
@@ -334,7 +334,7 @@
computed_size += erval.encoded;
/* Compute maximum encoding's size */
- if(max_encoded_len < erval.encoded)
+ if(max_encoded_len < (size_t)erval.encoded)
max_encoded_len = erval.encoded;
}
@@ -429,7 +429,7 @@
}
FREEMEM(encoded_els);
- if(ret || computed_size != encoding_size) {
+ if(ret || computed_size != (size_t)encoding_size) {
/*
* Standard callback failed, or
* encoded size is not equal to the computed size.
diff --git a/skeletons/constraints.c b/skeletons/constraints.c
index 13a1b40..cf31706 100644
--- a/skeletons/constraints.c
+++ b/skeletons/constraints.c
@@ -4,6 +4,12 @@
int
asn_generic_no_constraint(asn1_TYPE_descriptor_t *type_descriptor,
const void *struct_ptr, asn_app_consume_bytes_f *cb, void *key) {
+
+ (void)type_descriptor; /* Unused argument */
+ (void)struct_ptr; /* Unused argument */
+ (void)cb; /* Unused argument */
+ (void)key; /* Unused argument */
+
/* Nothing to check */
return 0;
}
@@ -11,6 +17,12 @@
int
asn_generic_unknown_constraint(asn1_TYPE_descriptor_t *type_descriptor,
const void *struct_ptr, asn_app_consume_bytes_f *cb, void *key) {
+
+ (void)type_descriptor; /* Unused argument */
+ (void)struct_ptr; /* Unused argument */
+ (void)cb; /* Unused argument */
+ (void)key; /* Unused argument */
+
/* Unknown how to check */
return 0;
}
@@ -86,7 +98,7 @@
/* Fall through */
}
- if(ret < sizeof(buf)) {
+ if(ret < (ssize_t)sizeof(buf)) {
cb(buf, ret, key);
return;
}
@@ -102,7 +114,7 @@
va_start(ap, fmt);
ret = vsnprintf(buf, len, fmt, ap);
va_end(ap);
- if(ret < 0 || ret >= len) {
+ if(ret < 0 || ret >= (ssize_t)len) {
ret = sizeof("<broken vsnprintf>") - 1;
memcpy(buf, "<broken vsnprintf>", ret + 1);
}
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index f275f9c..72a33eb 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -118,7 +118,7 @@
/* Serialize tag (T from TLV) into possibly zero-length buffer */
tmp = der_tlv_tag_serialize(tag, buf, buf_size);
- if(tmp == -1 || tmp > sizeof(buf)) return -1;
+ if(tmp == -1 || tmp > (ssize_t)sizeof(buf)) return -1;
size += tmp;
/* Serialize length (L from TLV) into possibly zero-length buffer */