mirror of https://gerrit.osmocom.org/asn1c
stop ignoring formatting problems, start ignoring long long extension problems
This commit is contained in:
parent
df2edbbd15
commit
9f470d60fa
|
@ -114,6 +114,9 @@ AC_ARG_ENABLE(Werror,
|
|||
[SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wgnu"])
|
||||
])
|
||||
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-long-long],
|
||||
[SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wno-long-long"])
|
||||
|
||||
AC_ARG_ENABLE(test-Werror,
|
||||
[AS_HELP_STRING([--enable-test-Werror],
|
||||
[abort compiling tests after any C compiler warning])],
|
||||
|
@ -121,9 +124,6 @@ AC_ARG_ENABLE(test-Werror,
|
|||
AS_IF([test x$enable_test_werror != xno], [
|
||||
TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -Werror -W -Wpointer-arith"
|
||||
])
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-format],
|
||||
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wno-format"])
|
||||
|
||||
|
||||
dnl If requested and -m32 is available to create 32-bit code,
|
||||
dnl treat it like a special case to be checked.
|
||||
|
|
|
@ -220,7 +220,7 @@ ANY_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
if(raw_len < 0) RETURN(RC_WMORE);
|
||||
if(raw_len == 0 && st->buf) break;
|
||||
|
||||
ASN_DEBUG("Got PER length len %zu, %s (%s)", raw_len,
|
||||
ASN_DEBUG("Got PER length len %" ASN_PRI_SIZE ", %s (%s)", raw_len,
|
||||
repeat ? "repeat" : "once", td->name);
|
||||
len_bytes = raw_len;
|
||||
len_bits = len_bytes * 8;
|
||||
|
|
|
@ -459,7 +459,7 @@ BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
size_in_bits = 8 * st->size - st->bits_unused;
|
||||
|
||||
ASN_DEBUG(
|
||||
"Encoding %s into %zu bits"
|
||||
"Encoding %s into %" ASN_PRI_SIZE " bits"
|
||||
" (%ld..%ld, effective %d)%s",
|
||||
td->name, size_in_bits, csiz->lower_bound, csiz->upper_bound,
|
||||
csiz->effective_bits, ct_extensible ? " EXT" : "");
|
||||
|
@ -488,8 +488,8 @@ BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
if(csiz->effective_bits >= 0 && !inext) {
|
||||
int add_trailer = (ssize_t)size_in_bits < csiz->lower_bound;
|
||||
ASN_DEBUG(
|
||||
"Encoding %zu bytes (%ld), length (in %d bits) trailer %d; actual "
|
||||
"value %zd",
|
||||
"Encoding %" ASN_PRI_SIZE " bytes (%ld), length (in %d bits) trailer %d; actual "
|
||||
"value %" ASN_PRI_SSIZE "",
|
||||
st->size, size_in_bits - csiz->lower_bound, csiz->effective_bits,
|
||||
add_trailer,
|
||||
add_trailer ? 0 : (ssize_t)size_in_bits - csiz->lower_bound);
|
||||
|
@ -516,7 +516,7 @@ BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
ASN_DEBUG("Encoding %zu bytes", st->size);
|
||||
ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes", st->size);
|
||||
|
||||
buf = st->buf;
|
||||
do {
|
||||
|
@ -524,7 +524,7 @@ BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
ssize_t maySave = uper_put_length(po, size_in_bits, &need_eom);
|
||||
if(maySave < 0) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Encoding %zd of %zu", maySave, size_in_bits);
|
||||
ASN_DEBUG("Encoding %" ASN_PRI_SSIZE " of %" ASN_PRI_SIZE "", maySave, size_in_bits);
|
||||
|
||||
ret = per_put_many_bits(po, buf, maySave);
|
||||
if(ret) ASN__ENCODE_FAILED;
|
||||
|
|
|
@ -118,7 +118,7 @@ BIT_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
|
|||
if(ct_size >= 0) {
|
||||
size_t ct_bytes = (ct_size + 7) >> 3;
|
||||
if(st->size > ct_bytes) {
|
||||
ASN_DEBUG("More bits in BIT STRING %s (%zd) than constrained %zd",
|
||||
ASN_DEBUG("More bits in BIT STRING %s (%" ASN_PRI_SSIZE ") than constrained %" ASN_PRI_SSIZE "",
|
||||
td->name, 8 * st->size - st->bits_unused, ct_size);
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ BMPString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
if(st && st->buf) {
|
||||
if(st->size & 1) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: invalid size %zu not divisible by 2 (%s:%d)",
|
||||
"%s: invalid size %" ASN_PRI_SIZE " not divisible by 2 (%s:%d)",
|
||||
td->name, st->size, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_cons
|
|||
if(el) {
|
||||
if(plainOrXER == 0)
|
||||
return asn__format_to_callback(cb, app_key,
|
||||
"%" PRIdMAX " (%s)", value, el->enum_name);
|
||||
"%" ASN_PRIdMAX " (%s)", value, el->enum_name);
|
||||
else
|
||||
return asn__format_to_callback(cb, app_key,
|
||||
"<%s/>", el->enum_name);
|
||||
|
@ -160,8 +160,10 @@ INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_cons
|
|||
return -1;
|
||||
} else {
|
||||
return asn__format_to_callback(cb, app_key,
|
||||
(specs && specs->field_unsigned) ? "%" PRIuMAX : "%" PRIdMAX,
|
||||
value);
|
||||
(specs && specs->field_unsigned)
|
||||
? "%" ASN_PRIuMAX
|
||||
: "%" ASN_PRIdMAX,
|
||||
value);
|
||||
}
|
||||
} else if(plainOrXER && specs && specs->strict_enumeration) {
|
||||
/*
|
||||
|
@ -729,7 +731,7 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
|| uval > (unsigned long)ct->upper_bound)
|
||||
inext = 1;
|
||||
}
|
||||
ASN_DEBUG("Value %lu (%02x/%zu) lb %lu ub %lu %s",
|
||||
ASN_DEBUG("Value %lu (%02x/%" ASN_PRI_SIZE ") lb %lu ub %lu %s",
|
||||
uval, st->buf[0], st->size,
|
||||
ct->lower_bound, ct->upper_bound,
|
||||
inext ? "ext" : "fix");
|
||||
|
@ -746,7 +748,7 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
|| value > ct->upper_bound)
|
||||
inext = 1;
|
||||
}
|
||||
ASN_DEBUG("Value %ld (%02x/%zu) lb %ld ub %ld %s",
|
||||
ASN_DEBUG("Value %ld (%02x/%" ASN_PRI_SIZE ") lb %ld ub %ld %s",
|
||||
value, st->buf[0], st->size,
|
||||
ct->lower_bound, ct->upper_bound,
|
||||
inext ? "ext" : "fix");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
CFLAGS = $(filter-out $(CODE_COVERAGE_CFLAGS), @CFLAGS@)
|
||||
CFLAGS += ${SKELETONS_CFLAGS} # Put -std=c89 at the end!
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
${srcdir}/README \
|
||||
|
@ -19,13 +18,20 @@ uninstall-local:
|
|||
-@echo -n " "
|
||||
-rm -f -r $(DESTDIR)$(pkgdatadir)
|
||||
|
||||
check_LTLIBRARIES = libasn1cskeletons.la libasn1cskeletons_32.la
|
||||
check_LTLIBRARIES = \
|
||||
libasn1cskeletons.la \
|
||||
libasn1cskeletons_c89.la \
|
||||
libasn1cskeletons_c89_32.la
|
||||
|
||||
libasn1cskeletons_c89_la_CFLAGS = $(SKELETONS_CFLAGS)
|
||||
libasn1cskeletons_c89_la_SOURCES = $(libasn1cskeletons_la_SOURCES)
|
||||
|
||||
if EXPLICIT_M32
|
||||
libasn1cskeletons_32_la_CFLAGS = $(CFLAGS_M32)
|
||||
libasn1cskeletons_32_la_SOURCES = $(libasn1cskeletons_la_SOURCES)
|
||||
libasn1cskeletons_c89_32_la_CFLAGS = $(SKELETONS_CFLAGS) $(CFLAGS_M32) -Wno-format
|
||||
libasn1cskeletons_c89_32_la_SOURCES = $(libasn1cskeletons_la_SOURCES)
|
||||
endif
|
||||
|
||||
libasn1cskeletons_la_CFLAGS = $(TESTSUITE_CFLAGS)
|
||||
libasn1cskeletons_la_SOURCES = \
|
||||
ANY.c ANY.h \
|
||||
BIT_STRING.c BIT_STRING.h \
|
||||
|
@ -95,9 +101,21 @@ libasn1cskeletons_la_SOURCES = \
|
|||
xer_encoder.c xer_encoder.h \
|
||||
xer_support.c xer_support.h
|
||||
|
||||
check_PROGRAMS = check-converter_example
|
||||
check_PROGRAMS = \
|
||||
check-converter_example \
|
||||
check-converter_c89_example \
|
||||
check-converter_c89_32_example
|
||||
LDADD = -lm
|
||||
|
||||
check_converter_example_CFLAGS = -DNO_ASN_PDU
|
||||
check_converter_example_SOURCES = converter-example.c
|
||||
check_converter_example_LDADD = libasn1cskeletons.la
|
||||
|
||||
check_converter_c89_example_CFLAGS = $(SKELETON_CFLAGS) -DNO_ASN_PDU
|
||||
check_converter_c89_example_SOURCES = converter-example.c
|
||||
check_converter_c89_example_LDADD = libasn1cskeletons_c89.la
|
||||
|
||||
check_converter_c89_32_example_CFLAGS = $(SKELETON_CFLAGS) $(CFLAGS_M32) -DNO_ASN_PDU
|
||||
check_converter_c89_32_example_SOURCES = converter-example.c
|
||||
check_converter_c89_32_example_LDADD = libasn1cskeletons_c89_32.la
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ NativeReal_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
ret = asn_REAL2double(&tmp, &d);
|
||||
if(tmp.buf != scratch) FREEMEM(tmp.buf);
|
||||
if(ret) {
|
||||
ASN_DEBUG("REAL decoded in %zu bytes, but can't convert t double",
|
||||
ASN_DEBUG("REAL decoded in %" ASN_PRI_SIZE " bytes, but can't convert t double",
|
||||
real_body_len);
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -1574,7 +1574,7 @@ OCTET_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
break;
|
||||
}
|
||||
|
||||
ASN_DEBUG("Encoding %s into %zu units of %d bits"
|
||||
ASN_DEBUG("Encoding %s into %" ASN_PRI_SIZE " units of %d bits"
|
||||
" (%ld..%ld, effective %d)%s",
|
||||
td->name, size_in_units, unit_bits,
|
||||
csiz->lower_bound, csiz->upper_bound,
|
||||
|
@ -1604,7 +1604,7 @@ OCTET_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
if(csiz->effective_bits >= 0 && !inext) {
|
||||
ASN_DEBUG("Encoding %zu bytes (%ld), length in %d bits", st->size,
|
||||
ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes (%ld), length in %d bits", st->size,
|
||||
size_in_units - csiz->lower_bound, csiz->effective_bits);
|
||||
ret = per_put_few_bits(po, size_in_units - csiz->lower_bound,
|
||||
csiz->effective_bits);
|
||||
|
@ -1616,16 +1616,16 @@ OCTET_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
ASN_DEBUG("Encoding %zu bytes", st->size);
|
||||
ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes", st->size);
|
||||
|
||||
buf = st->buf;
|
||||
ASN_DEBUG("Encoding %zu in units", size_in_units);
|
||||
ASN_DEBUG("Encoding %" ASN_PRI_SIZE " in units", size_in_units);
|
||||
do {
|
||||
int need_eom = 0;
|
||||
ssize_t may_save = uper_put_length(po, size_in_units, &need_eom);
|
||||
if(may_save < 0) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Encoding %zd of %zu%s", may_save, size_in_units,
|
||||
ASN_DEBUG("Encoding %" ASN_PRI_SSIZE " of %" ASN_PRI_SIZE "%s", may_save, size_in_units,
|
||||
need_eom ? ",+EOM" : "");
|
||||
|
||||
ret = OCTET_STRING_per_put_characters(po, buf, may_save, bpc, unit_bits,
|
||||
|
|
|
@ -71,7 +71,7 @@ OCTET_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
if(expected_length % unit_bytes != 0) {
|
||||
ASN_DEBUG(
|
||||
"Data size %zu bytes is not consistent with multiplier %zu",
|
||||
"Data size %" ASN_PRI_SIZE " bytes is not consistent with multiplier %" ASN_PRI_SIZE "",
|
||||
expected_length, unit_bytes);
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ OCTET_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
|
|||
|
||||
if(!st) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Encoding %s %zu as OCTET STRING", td ? td->name : "", st->size);
|
||||
ASN_DEBUG("Encoding %s %" ASN_PRI_SIZE " as OCTET STRING", td ? td->name : "", st->size);
|
||||
|
||||
if(ct_size >= 0) {
|
||||
/*
|
||||
|
@ -142,8 +142,8 @@ OCTET_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
|
|||
|
||||
if(st->size != unit_bytes * (size_t)ct_size) {
|
||||
ASN_DEBUG(
|
||||
"Trying to encode %s (%zu bytes) which doesn't fit SIZE "
|
||||
"constraint (%zu)",
|
||||
"Trying to encode %s (%" ASN_PRI_SIZE " bytes) which doesn't fit SIZE "
|
||||
"constraint (%" ASN_PRI_SIZE ")",
|
||||
td->name, st->size, ct_size);
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ UniversalString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
if(st && st->buf) {
|
||||
if(st->size % 4) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: invalid size %zu not divisible by 4 (%s:%d)",
|
||||
"%s: invalid size %" ASN_PRI_SIZE " not divisible by 4 (%s:%d)",
|
||||
td->name, st->size, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
overrun_encoder_cb, &buf_key);
|
||||
|
||||
if(er.encoded >= 0 && (size_t)er.encoded != buf_key.computed_size) {
|
||||
ASN_DEBUG("asn_encode() returned %zd yet produced %zu bytes",
|
||||
ASN_DEBUG("asn_encode() returned %" ASN_PRI_SSIZE " yet produced %" ASN_PRI_SIZE " bytes",
|
||||
er.encoded, buf_key.computed_size);
|
||||
assert(er.encoded < 0 || (size_t)er.encoded == buf_key.computed_size);
|
||||
}
|
||||
|
|
|
@ -38,13 +38,12 @@ asn_bit_data_string(asn_bit_data_t *pd) {
|
|||
static char buf[2][32];
|
||||
static int n;
|
||||
n = (n+1) % 2;
|
||||
snprintf(buf[n], sizeof(buf[n]),
|
||||
"{m=%ld span %+ld[%d..%d] (%d)}",
|
||||
(long)pd->moved,
|
||||
(((long)pd->buffer) & 0xf),
|
||||
(int)pd->nboff, (int)pd->nbits,
|
||||
(int)(pd->nbits - pd->nboff));
|
||||
return buf[n];
|
||||
snprintf(buf[n], sizeof(buf[n]),
|
||||
"{m=%" ASN_PRI_SIZE " span %" ASN_PRI_SIZE "[%" ASN_PRI_SIZE
|
||||
"..%" ASN_PRI_SIZE "] (%" ASN_PRI_SIZE ")}",
|
||||
pd->moved, ((uintptr_t)(pd->buffer) & 0xf), pd->nboff, pd->nbits,
|
||||
pd->nbits - pd->nboff);
|
||||
return buf[n];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -126,4 +126,21 @@ typedef unsigned int uint32_t;
|
|||
#define RSSIZE_MAX ((ssize_t)(RSIZE_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
#define ASN_PRI_SIZE "zu"
|
||||
#define ASN_PRI_SSIZE "zd"
|
||||
#define ASN_PRIuMAX PRIuMAX
|
||||
#define ASN_PRIdMAX PRIdMAX
|
||||
#else
|
||||
#define ASN_PRI_SIZE "lu"
|
||||
#define ASN_PRI_SSIZE "ld"
|
||||
#if LLONG_MAX > LONG_MAX
|
||||
#define ASN_PRIuMAX "llu"
|
||||
#define ASN_PRIdMAX "lld"
|
||||
#else
|
||||
#define ASN_PRIuMAX "lu"
|
||||
#define ASN_PRIdMAX "ld"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* ASN_SYSTEM_H */
|
||||
|
|
|
@ -202,7 +202,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
/*
|
||||
* MICROPHASE 1: Synchronize decoding.
|
||||
*/
|
||||
ASN_DEBUG("In %s SEQUENCE left %d, edx=%zu flags=%d"
|
||||
ASN_DEBUG("In %s SEQUENCE left %d, edx=%" ASN_PRI_SIZE " flags=%d"
|
||||
" opt=%d ec=%d",
|
||||
td->name, (int)ctx->left, edx,
|
||||
elements[edx].flags, elements[edx].optional,
|
||||
|
@ -226,7 +226,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Fetch the T from TLV.
|
||||
*/
|
||||
tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag);
|
||||
ASN_DEBUG("Current tag in %s SEQUENCE for element %zu "
|
||||
ASN_DEBUG("Current tag in %s SEQUENCE for element %" ASN_PRI_SIZE " "
|
||||
"(%s) is %s encoded in %d bytes, of frame %ld",
|
||||
td->name, edx, elements[edx].name,
|
||||
ber_tlv_tag_string(tlv_tag), (int)tag_len, (long)LEFT);
|
||||
|
@ -244,7 +244,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
RETURN(RC_WMORE);
|
||||
}
|
||||
} else if(((const uint8_t *)ptr)[1] == 0) {
|
||||
ASN_DEBUG("edx = %zu, opt = %d, ec=%d", edx,
|
||||
ASN_DEBUG("edx = %" ASN_PRI_SIZE ", opt = %d, ec=%d", edx,
|
||||
elements[edx].optional, td->elements_count);
|
||||
if((edx + elements[edx].optional == td->elements_count)
|
||||
|| IN_EXTENSION_GROUP(specs, edx)) {
|
||||
|
@ -342,7 +342,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
if(!IN_EXTENSION_GROUP(specs,
|
||||
edx + elements[edx].optional)) {
|
||||
ASN_DEBUG("Unexpected tag %s (at %zu)",
|
||||
ASN_DEBUG("Unexpected tag %s (at %" ASN_PRI_SIZE ")",
|
||||
ber_tlv_tag_string(tlv_tag), edx);
|
||||
ASN_DEBUG("Expected tag %s (%s)%s",
|
||||
ber_tlv_tag_string(elements[edx].tag),
|
||||
|
@ -355,7 +355,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
ssize_t skip;
|
||||
edx += elements[edx].optional;
|
||||
|
||||
ASN_DEBUG("Skipping unexpected %s (at %zu)",
|
||||
ASN_DEBUG("Skipping unexpected %s (at %" ASN_PRI_SIZE ")",
|
||||
ber_tlv_tag_string(tlv_tag), edx);
|
||||
skip = ber_skip_length(opt_codec_ctx,
|
||||
BER_TLV_CONSTRUCTED(ptr),
|
||||
|
@ -410,7 +410,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
memb_ptr2, ptr, LEFT,
|
||||
elements[edx].tag_mode);
|
||||
}
|
||||
ASN_DEBUG("In %s SEQUENCE decoded %zu %s of %d "
|
||||
ASN_DEBUG("In %s SEQUENCE decoded %" ASN_PRI_SIZE " %s of %d "
|
||||
"in %d bytes rval.code %d, size=%d",
|
||||
td->name, edx, elements[edx].type->name,
|
||||
(int)LEFT, (int)rval.consumed, rval.code, (int)size);
|
||||
|
@ -532,7 +532,7 @@ SEQUENCE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
ASN_DEBUG("Element %s %zu not present",
|
||||
ASN_DEBUG("Element %s %" ASN_PRI_SIZE " not present",
|
||||
elm->name, edx);
|
||||
if(elm->optional)
|
||||
continue;
|
||||
|
@ -554,7 +554,7 @@ SEQUENCE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
if(erval.encoded == -1)
|
||||
return erval;
|
||||
computed_size += erval.encoded;
|
||||
ASN_DEBUG("Member %zu %s estimated %ld bytes",
|
||||
ASN_DEBUG("Member %" ASN_PRI_SIZE " %s estimated %ld bytes",
|
||||
edx, elm->name, (long)erval.encoded);
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ SEQUENCE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
if(tmperval.encoded == -1)
|
||||
return tmperval;
|
||||
computed_size -= tmperval.encoded;
|
||||
ASN_DEBUG("Member %zu %s of SEQUENCE %s encoded in %ld bytes",
|
||||
ASN_DEBUG("Member %" ASN_PRI_SIZE " %s of SEQUENCE %s encoded in %ld bytes",
|
||||
edx, elm->name, td->name, (long)tmperval.encoded);
|
||||
}
|
||||
|
||||
|
@ -782,7 +782,7 @@ SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
case XCT_UNKNOWN_OP:
|
||||
case XCT_UNKNOWN_BO:
|
||||
|
||||
ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d, edx=%zu",
|
||||
ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d, edx=%" ASN_PRI_SIZE "",
|
||||
tcv, ctx->phase, edx);
|
||||
if(ctx->phase != 1) {
|
||||
break; /* Really unexpected */
|
||||
|
@ -820,7 +820,7 @@ SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
if(n != edx_end)
|
||||
continue;
|
||||
} else {
|
||||
ASN_DEBUG("Out of defined members: %zu/%u",
|
||||
ASN_DEBUG("Out of defined members: %" ASN_PRI_SIZE "/%u",
|
||||
edx, td->elements_count);
|
||||
}
|
||||
|
||||
|
@ -828,7 +828,7 @@ SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
if(IN_EXTENSION_GROUP(specs,
|
||||
edx + (edx < td->elements_count
|
||||
? elements[edx].optional : 0))) {
|
||||
ASN_DEBUG("Got anticipated extension at %zu",
|
||||
ASN_DEBUG("Got anticipated extension at %" ASN_PRI_SIZE "",
|
||||
edx);
|
||||
/*
|
||||
* Check for (XCT_BOTH or XCT_UNKNOWN_BO)
|
||||
|
@ -1197,7 +1197,7 @@ SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
bmlength = uper_get_nslength(pd);
|
||||
if(bmlength < 0) ASN__DECODE_STARVED;
|
||||
|
||||
ASN_DEBUG("Extensions %zd present in %s", bmlength, td->name);
|
||||
ASN_DEBUG("Extensions %" ASN_PRI_SSIZE " present in %s", bmlength, td->name);
|
||||
|
||||
epres = (uint8_t *)MALLOC((bmlength + 15) >> 3);
|
||||
if(!epres) ASN__DECODE_STARVED;
|
||||
|
@ -1331,7 +1331,7 @@ SEQUENCE__handle_extensions(const asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
present = 1;
|
||||
}
|
||||
|
||||
ASN_DEBUG("checking %s:%s (@%zu) present => %d", elm->name,
|
||||
ASN_DEBUG("checking %s:%s (@%" ASN_PRI_SIZE ") present => %d", elm->name,
|
||||
elm->type->name, edx, present);
|
||||
exts_count++;
|
||||
exts_present += present;
|
||||
|
@ -1439,7 +1439,7 @@ SEQUENCE_encode_uper(const asn_TYPE_descriptor_t *td,
|
|||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
ASN_DEBUG("Element %s %zu not present",
|
||||
ASN_DEBUG("Element %s %" ASN_PRI_SIZE " not present",
|
||||
elm->name, edx);
|
||||
if(elm->optional)
|
||||
continue;
|
||||
|
|
|
@ -131,7 +131,7 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
ASN_DEBUG("OER SEQUENCE %s Decoding PHASE 0", td->name);
|
||||
|
||||
ASN_DEBUG(
|
||||
"Expecting preamble bits %zu for %s (including %d extension bits)",
|
||||
"Expecting preamble bits %" ASN_PRI_SIZE " for %s (including %d extension bits)",
|
||||
preamble_bits, td->name, has_extensions_bit);
|
||||
|
||||
if(preamble_bytes > size) {
|
||||
|
|
|
@ -235,7 +235,7 @@ SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
edx = t2m->el_no;
|
||||
ctx->step = (edx << 1) + 1;
|
||||
ASN_DEBUG("Got tag %s (%s), edx %zd",
|
||||
ASN_DEBUG("Got tag %s (%s), edx %" ASN_PRI_SSIZE "",
|
||||
ber_tlv_tag_string(tlv_tag), td->name, edx);
|
||||
} else if(specs->extensible == 0) {
|
||||
ASN_DEBUG("Unexpected tag %s "
|
||||
|
@ -273,7 +273,7 @@ SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* already decoded elements.
|
||||
*/
|
||||
if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset, edx)) {
|
||||
ASN_DEBUG("SET %s: Duplicate element %s (%zd)",
|
||||
ASN_DEBUG("SET %s: Duplicate element %s (%" ASN_PRI_SSIZE ")",
|
||||
td->name, elements[edx].name, edx);
|
||||
RETURN(RC_FAIL);
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset,
|
||||
edx)) {
|
||||
ASN_DEBUG("SET %s: Duplicate element %s (%zd)",
|
||||
ASN_DEBUG("SET %s: Duplicate element %s (%" ASN_PRI_SSIZE ")",
|
||||
td->name, elements[edx].name, edx);
|
||||
RETURN(RC_FAIL);
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ SET_OF_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
case -1:
|
||||
RETURN(RC_FAIL);
|
||||
default:
|
||||
ASN_DEBUG("ptr[] = %02x, advancing %zu, length=%zu", *(const uint8_t *)ptr, len_size, length);
|
||||
ASN_DEBUG("ptr[] = %02x, advancing %" ASN_PRI_SIZE ", length=%" ASN_PRI_SIZE "", *(const uint8_t *)ptr, len_size, length);
|
||||
ADVANCE(len_size);
|
||||
ctx->left = length;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ srandomdev(void) {
|
|||
#endif /* JUNKTEST */
|
||||
|
||||
/* Debug output function */
|
||||
static void
|
||||
static void CC_PRINTFLIKE(1, 2)
|
||||
DEBUG(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
if(!opt_debug) return;
|
||||
|
@ -491,7 +491,7 @@ main(int ac, char *av[]) {
|
|||
asn_fprint(stderr, pduType, structure);
|
||||
exit(EX_UNAVAILABLE);
|
||||
}
|
||||
DEBUG("Encoded in %zd bytes of %s", erv.encoded,
|
||||
DEBUG("Encoded in %" ASN_PRI_SSIZE " bytes of %s", erv.encoded,
|
||||
ats_simple_name(osyntax));
|
||||
}
|
||||
|
||||
|
@ -529,13 +529,14 @@ buffer_dump() {
|
|||
uint8_t *p = DynamicBuffer.data + DynamicBuffer.offset;
|
||||
uint8_t *e = p + DynamicBuffer.length - (DynamicBuffer.unbits ? 1 : 0);
|
||||
if(!opt_debug) return;
|
||||
DEBUG("Buffer: { d=%p, o=%ld, l=%ld, u=%ld, a=%ld, s=%ld }",
|
||||
DynamicBuffer.data,
|
||||
(long)DynamicBuffer.offset,
|
||||
(long)DynamicBuffer.length,
|
||||
(long)DynamicBuffer.unbits,
|
||||
(long)DynamicBuffer.allocated,
|
||||
(long)DynamicBuffer.bytes_shifted);
|
||||
DEBUG("Buffer: { d=%p, o=%" ASN_PRI_SIZE ", l=%" ASN_PRI_SIZE
|
||||
", u=%" ASN_PRI_SIZE ", a=%" ASN_PRI_SIZE ", s=%" ASN_PRI_SIZE " }",
|
||||
(const void *)DynamicBuffer.data,
|
||||
DynamicBuffer.offset,
|
||||
DynamicBuffer.length,
|
||||
DynamicBuffer.unbits,
|
||||
DynamicBuffer.allocated,
|
||||
(size_t)DynamicBuffer.bytes_shifted);
|
||||
for(; p < e; p++) {
|
||||
fprintf(stderr, " %c%c%c%c%c%c%c%c",
|
||||
((*p >> 7) & 1) ? '1' : '0',
|
||||
|
@ -552,9 +553,9 @@ buffer_dump() {
|
|||
fprintf(stderr, " ");
|
||||
for(shift = 7; shift >= DynamicBuffer.unbits; shift--)
|
||||
fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0');
|
||||
fprintf(stderr, " %ld:%ld\n",
|
||||
(long)DynamicBuffer.length - 1,
|
||||
(long)8 - DynamicBuffer.unbits);
|
||||
fprintf(stderr, " %" ASN_PRI_SSIZE ":%" ASN_PRI_SSIZE "\n",
|
||||
(ssize_t)DynamicBuffer.length - 1,
|
||||
(ssize_t)8 - DynamicBuffer.unbits);
|
||||
} else {
|
||||
fprintf(stderr, " %ld\n", (long)DynamicBuffer.length);
|
||||
}
|
||||
|
@ -633,7 +634,7 @@ buffer_shift_left(size_t offset, int bits) {
|
|||
}
|
||||
*ptr <<= bits;
|
||||
|
||||
DEBUG("Unbits [%d=>", (int)DynamicBuffer.unbits);
|
||||
DEBUG("Unbits [%" ASN_PRI_SIZE "=>", DynamicBuffer.unbits);
|
||||
if(DynamicBuffer.unbits == 0) {
|
||||
DynamicBuffer.unbits += bits;
|
||||
} else {
|
||||
|
@ -644,16 +645,15 @@ buffer_shift_left(size_t offset, int bits) {
|
|||
DynamicBuffer.bytes_shifted++;
|
||||
}
|
||||
}
|
||||
DEBUG("Unbits =>%d]", (int)DynamicBuffer.unbits);
|
||||
DEBUG("Unbits =>%" ASN_PRI_SIZE "]", DynamicBuffer.unbits);
|
||||
|
||||
buffer_dump();
|
||||
|
||||
DEBUG("Shifted. Now (o=%ld, u=%ld l=%ld)",
|
||||
(long)DynamicBuffer.offset,
|
||||
(long)DynamicBuffer.unbits,
|
||||
(long)DynamicBuffer.length);
|
||||
|
||||
|
||||
DEBUG("Shifted. Now (o=%" ASN_PRI_SIZE ", u=%" ASN_PRI_SIZE
|
||||
" l=%" ASN_PRI_SIZE ")",
|
||||
DynamicBuffer.offset,
|
||||
DynamicBuffer.unbits,
|
||||
DynamicBuffer.length);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -663,15 +663,16 @@ static void add_bytes_to_buffer(const void *data2add, size_t bytes) {
|
|||
|
||||
if(bytes == 0) return;
|
||||
|
||||
DEBUG("=> add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }",
|
||||
(long)bytes,
|
||||
(long)DynamicBuffer.offset,
|
||||
(long)DynamicBuffer.length,
|
||||
(long)DynamicBuffer.unbits,
|
||||
(long)DynamicBuffer.allocated);
|
||||
DEBUG("=> add_bytes(%" ASN_PRI_SIZE ") { o=%" ASN_PRI_SIZE
|
||||
" l=%" ASN_PRI_SIZE " u=%" ASN_PRI_SIZE ", s=%" ASN_PRI_SIZE " }",
|
||||
bytes,
|
||||
DynamicBuffer.offset,
|
||||
DynamicBuffer.length,
|
||||
DynamicBuffer.unbits,
|
||||
DynamicBuffer.allocated);
|
||||
|
||||
if(DynamicBuffer.allocated
|
||||
>= (DynamicBuffer.offset + DynamicBuffer.length + bytes)) {
|
||||
>= (DynamicBuffer.offset + DynamicBuffer.length + bytes)) {
|
||||
DEBUG("\tNo buffer reallocation is necessary");
|
||||
} else if(bytes <= DynamicBuffer.offset) {
|
||||
DEBUG("\tContents shifted by %ld", DynamicBuffer.offset);
|
||||
|
@ -711,12 +712,13 @@ static void add_bytes_to_buffer(const void *data2add, size_t bytes) {
|
|||
buffer_shift_left(DynamicBuffer.length - bytes, bits);
|
||||
}
|
||||
|
||||
DEBUG("<= add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }",
|
||||
(long)bytes,
|
||||
(long)DynamicBuffer.offset,
|
||||
(long)DynamicBuffer.length,
|
||||
(long)DynamicBuffer.unbits,
|
||||
(long)DynamicBuffer.allocated);
|
||||
DEBUG("<= add_bytes(%" ASN_PRI_SIZE ") { o=%" ASN_PRI_SIZE
|
||||
" l=%" ASN_PRI_SIZE " u=%" ASN_PRI_SIZE ", s=%" ASN_PRI_SIZE " }",
|
||||
bytes,
|
||||
DynamicBuffer.offset,
|
||||
DynamicBuffer.length,
|
||||
DynamicBuffer.unbits,
|
||||
DynamicBuffer.allocated);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -803,7 +805,7 @@ data_decode_from_file(enum asn_transfer_syntax isyntax, asn_TYPE_descriptor_t *p
|
|||
i_size = rd;
|
||||
}
|
||||
|
||||
DEBUG("Decoding %ld bytes", (long)i_size);
|
||||
DEBUG("Decoding %" ASN_PRI_SIZE " bytes", i_size);
|
||||
|
||||
#ifdef JUNKTEST
|
||||
junk_bytes_with_probability(i_bptr, i_size, opt_jprob);
|
||||
|
@ -833,10 +835,9 @@ data_decode_from_file(enum asn_transfer_syntax isyntax, asn_TYPE_descriptor_t *p
|
|||
/* Continue accumulating data */
|
||||
}
|
||||
|
||||
DEBUG("decode(%ld) consumed %ld+%db (%ld), code %d",
|
||||
(long)DynamicBuffer.length,
|
||||
(long)rval.consumed, ecbits, (long)i_size,
|
||||
rval.code);
|
||||
DEBUG("decode(%" ASN_PRI_SIZE ") consumed %" ASN_PRI_SIZE
|
||||
"+%db (%" ASN_PRI_SIZE "), code %d",
|
||||
DynamicBuffer.length, rval.consumed, ecbits, i_size, rval.code);
|
||||
|
||||
if(DynamicBuffer.allocated == 0) {
|
||||
/*
|
||||
|
|
|
@ -89,7 +89,7 @@ oer_encode_primitive(const asn_TYPE_descriptor_t *td,
|
|||
|
||||
if(!st) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Encoding %s (%zu bytes)", td ? td->name : "", st->size);
|
||||
ASN_DEBUG("Encoding %s (%" ASN_PRI_SIZE " bytes)", td ? td->name : "", st->size);
|
||||
|
||||
/*
|
||||
* X.696 (08/2015) #27.2
|
||||
|
|
|
@ -38,19 +38,20 @@ uper_open_type_put(const asn_TYPE_descriptor_t *td,
|
|||
size = uper_encode_to_new_buffer(td, constraints, sptr, &buf);
|
||||
if(size <= 0) return -1;
|
||||
|
||||
ASN_DEBUG("Open type put %s of length %zd + overhead (1byte?)", td->name,
|
||||
ASN_DEBUG("Open type put %s of length %" ASN_PRI_SSIZE " + overhead (1byte?)", td->name,
|
||||
size);
|
||||
|
||||
bptr = buf;
|
||||
do {
|
||||
int need_eom = 0;
|
||||
ssize_t maySave = uper_put_length(po, size, &need_eom);
|
||||
ASN_DEBUG("Prepending length %zd to %s and allowing to save %d", size,
|
||||
td->name, (int)maySave);
|
||||
if(maySave < 0) break;
|
||||
if(per_put_many_bits(po, bptr, maySave * 8)) break;
|
||||
bptr = (char *)bptr + maySave;
|
||||
size -= maySave;
|
||||
ssize_t may_save = uper_put_length(po, size, &need_eom);
|
||||
ASN_DEBUG("Prepending length %" ASN_PRI_SSIZE
|
||||
" to %s and allowing to save %" ASN_PRI_SSIZE,
|
||||
size, td->name, may_save);
|
||||
if(may_save < 0) break;
|
||||
if(per_put_many_bits(po, bptr, may_save * 8)) break;
|
||||
bptr = (char *)bptr + may_save;
|
||||
size -= may_save;
|
||||
if(need_eom && uper_put_length(po, 0, 0)) {
|
||||
FREEMEM(buf);
|
||||
return -1;
|
||||
|
|
|
@ -146,7 +146,7 @@ xer_equivalent(const struct asn_TYPE_descriptor_s *td, const void *struct1,
|
|||
if(opt_debug_stream) {
|
||||
fprintf(opt_debug_stream,
|
||||
"Both structures encoded into the same XER byte stream "
|
||||
"of size %zu:\n%s",
|
||||
"of size %" ASN_PRI_SIZE ":\n%s",
|
||||
xb1.buffer_size, xb1.buffer);
|
||||
}
|
||||
}
|
||||
|
@ -184,8 +184,8 @@ xer_equivalent(const struct asn_TYPE_descriptor_s *td, const void *struct1,
|
|||
!= (xb1.buffer_size - rval.consumed))) {
|
||||
if(opt_debug_stream) {
|
||||
fprintf(opt_debug_stream,
|
||||
"Round-trip decode of %s required less bytes (%zu) than "
|
||||
"encoded (%zu)\n",
|
||||
"Round-trip decode of %s required less bytes (%" ASN_PRI_SIZE ") than "
|
||||
"encoded (%" ASN_PRI_SIZE ")\n",
|
||||
td->name, rval.consumed, xb1.buffer_size);
|
||||
}
|
||||
ASN_STRUCT_FREE(*td, sptr);
|
||||
|
|
Loading…
Reference in New Issue