Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aper: Fix printf formatting on 32bit archs #101

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions skeletons/INTEGER_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
? asn_uint642INTEGER(st, (unsigned long)value)
: asn_int642INTEGER(st, value))
ASN__DECODE_FAILED;
ASN_DEBUG("Got value %ld + low %ld",
value, ct->lower_bound);
ASN_DEBUG("Got value %ld + low %lld",
value, (long long int)ct->lower_bound);
} else {
long value = 0;
if (ct->range_bits < 8) {
Expand All @@ -111,8 +111,8 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
? asn_ulong2INTEGER(st, value)
: asn_long2INTEGER(st, value))
ASN__DECODE_FAILED;
ASN_DEBUG("Got value %ld + low %ld",
value, ct->lower_bound);
ASN_DEBUG("Got value %ld + low %lld",
value, (long long int)ct->lower_bound);
}
return rval;
} else {
Expand Down Expand Up @@ -191,9 +191,10 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
|| uval > (unsigned long)ct->upper_bound)
inext = 1;
}
ASN_DEBUG("Value %lu (%02x/%lu) lb %ld ub %ld %s",
ASN_DEBUG("Value %lu (%02x/%zu) lb %lld ub %lld %s",
uval, st->buf[0], st->size,
ct->lower_bound, ct->upper_bound,
(long long int)ct->lower_bound,
(long long int)ct->upper_bound,
inext ? "ext" : "fix");
value = uval;
} else {
Expand All @@ -207,9 +208,10 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
|| value > ct->upper_bound)
inext = 1;
}
ASN_DEBUG("Value %lu (%02x/%lu) lb %ld ub %ld %s",
ASN_DEBUG("Value %lu (%02x/%zu) lb %lld ub %lld %s",
value, st->buf[0], st->size,
ct->lower_bound, ct->upper_bound,
(long long int)ct->lower_bound,
(long long int)ct->upper_bound,
inext ? "ext" : "fix");
}
if(ct->flags & APC_EXTENSIBLE) {
Expand All @@ -226,8 +228,9 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
unsigned long v;

/* #10.5.6 */
ASN_DEBUG("Encoding integer %ld (%lu) with range %d bits",
value, value - ct->lower_bound, ct->range_bits);
ASN_DEBUG("Encoding integer %ld (%lld) with range %d bits",
value, (long long int)(value - ct->lower_bound),
ct->range_bits);

v = value - ct->lower_bound;

Expand Down Expand Up @@ -284,7 +287,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}

if(ct && ct->lower_bound) {
ASN_DEBUG("Adjust lower bound to %ld", ct->lower_bound);
ASN_DEBUG("Adjust lower bound to %lld", (long long int)ct->lower_bound);
/* TODO: adjust lower bound */
ASN__ENCODE_FAILED;
}
Expand Down
6 changes: 4 additions & 2 deletions skeletons/NativeEnumerated_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ NativeEnumerated_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(ct && ct->upper_bound >= 255) {
int padding = 0;
padding = (8 - (pd->moved % 8)) % 8;
ASN_DEBUG("For NativeEnumerated %s,offset= %lu Padding bits = %d", td->name, pd->moved, padding);
ASN_DEBUG("For NativeEnumerated %s, upper bound = %lu", td->name, ct->upper_bound);
ASN_DEBUG("For NativeEnumerated %s,offset = %zu Padding bits = %d",
td->name, pd->moved, padding);
ASN_DEBUG("For NativeEnumerated %s, upper bound = %llu",
td->name, (unsigned long long)ct->upper_bound);
if(padding > 0)
per_get_few_bits(pd, padding);
}
Expand Down
24 changes: 13 additions & 11 deletions skeletons/OCTET_STRING_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(!st) RETURN(RC_FAIL);
}

ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d",
ASN_DEBUG("PER Decoding %s size %lld .. %lld bits %d",
csiz->flags & APC_EXTENSIBLE ? "extensible" : "non-extensible",
csiz->lower_bound, csiz->upper_bound, csiz->effective_bits);
(long long int)csiz->lower_bound, (long long int)csiz->upper_bound,
csiz->effective_bits);

if(csiz->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
Expand Down Expand Up @@ -136,8 +137,8 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
RETURN(RC_FAIL);
}
if(bpc) {
ASN_DEBUG("Decoding OCTET STRING size %ld",
csiz->upper_bound);
ASN_DEBUG("Decoding OCTET STRING size %lld",
(long long int)csiz->upper_bound);
ret = OCTET_STRING_per_get_characters(pd, st->buf,
csiz->upper_bound,
bpc, unit_bits,
Expand All @@ -146,8 +147,8 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
pc);
if(ret > 0) RETURN(RC_FAIL);
} else {
ASN_DEBUG("Decoding BIT STRING size %ld",
csiz->upper_bound);
ASN_DEBUG("Decoding BIT STRING size %lld",
(long long int)csiz->upper_bound);
ret = per_get_many_bits(pd, st->buf, 0,
unit_bits * csiz->upper_bound);
}
Expand Down Expand Up @@ -307,9 +308,10 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
}

ASN_DEBUG("Encoding %s into %d units of %d bits"
" (%ld..%ld, effective %d)%s",
" (%lld..%lld, effective %d)%s",
td->name, sizeinunits, unit_bits,
csiz->lower_bound, csiz->upper_bound,
(long long int)csiz->lower_bound,
(long long int)csiz->upper_bound,
csiz->effective_bits, ct_extensible ? " EXT" : "");

/* Figure out wheter size lies within PER visible constraint */
Expand Down Expand Up @@ -339,8 +341,8 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
/* X.691, #16.6: short fixed length encoding (up to 2 octets) */
/* X.691, #16.7: long fixed length encoding (up to 64K octets) */
if(csiz->effective_bits >= 0) {
ASN_DEBUG("Encoding %lu bytes (%ld), length in %d bits",
st->size, sizeinunits - csiz->lower_bound,
ASN_DEBUG("Encoding %zu bytes (%lld), length in %d bits",
st->size, (long long int)(sizeinunits - csiz->lower_bound),
csiz->effective_bits);
if (csiz->effective_bits > 0) {
ret = aper_put_length(po, csiz->lower_bound, csiz->upper_bound,
Expand Down Expand Up @@ -369,7 +371,7 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
ASN__ENCODED_OK(er);
}

ASN_DEBUG("Encoding %lu bytes", st->size);
ASN_DEBUG("Encoding %zu bytes", st->size);

if(sizeinunits == 0) {
if(aper_put_length(po, -1, -1, 0, NULL) < 0)
Expand Down
2 changes: 1 addition & 1 deletion skeletons/aper_opentype.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ aper_open_type_put(const asn_TYPE_descriptor_t *td,
FREEMEM(buf);
if(toGo) return -1;

ASN_DEBUG("Open type put %s of length %ld + overhead (1byte?)",
ASN_DEBUG("Open type put %s of length %zd + overhead (1byte?)",
td->name, size);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion skeletons/aper_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ aper_get_nslength(asn_per_data_t *pd) {
if(per_get_few_bits(pd, 1) == 0) {
length = per_get_few_bits(pd, 6) + 1;
if(length <= 0) return -1;
ASN_DEBUG("l=%ld", length);
ASN_DEBUG("l=%zd", length);
return length;
} else {
int repeat;
Expand Down
5 changes: 3 additions & 2 deletions skeletons/constr_SEQUENCE_OF_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ SEQUENCE_OF_encode_aper(const asn_TYPE_descriptor_t *td,
if(ct) {
int not_in_root = (list->count < ct->lower_bound
|| list->count > ct->upper_bound);
ASN_DEBUG("lb %ld ub %ld %s",
ct->lower_bound, ct->upper_bound,
ASN_DEBUG("lb %lld ub %lld %s",
(long long int)ct->lower_bound,
(long long int)ct->upper_bound,
ct->flags & APC_EXTENSIBLE ? "ext" : "fix");
if(ct->flags & APC_EXTENSIBLE) {
/* Declare whether size is in extension root */
Expand Down
10 changes: 5 additions & 5 deletions skeletons/constr_SEQUENCE_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
memset(&epmd, 0, sizeof(epmd));
epmd.buffer = epres;
epmd.nbits = bmlength;
ASN_DEBUG("Read in extensions bitmap for %s of %ld bits (%x..)",
ASN_DEBUG("Read in extensions bitmap for %s of %zd bits (%x..)",
td->name, bmlength, *epres);

/* Deal with padding */
Expand All @@ -190,7 +190,7 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int present;

if(!IN_EXTENSION_GROUP(specs, edx)) {
ASN_DEBUG("%ld is not extension", edx);
ASN_DEBUG("%zu is not extension", edx);
continue;
}

Expand Down Expand Up @@ -288,7 +288,7 @@ SEQUENCE_handle_extensions_aper(const asn_TYPE_descriptor_t *td,
int present;

if(!IN_EXTENSION_GROUP(specs, edx)) {
ASN_DEBUG("%s (@%ld) is not extension", elm->type->name, edx);
ASN_DEBUG("%s (@%zu) is not extension", elm->type->name, edx);
continue;
}

Expand All @@ -302,7 +302,7 @@ SEQUENCE_handle_extensions_aper(const asn_TYPE_descriptor_t *td,
present = 1;
}

ASN_DEBUG("checking %s (@%ld) present => %d",
ASN_DEBUG("checking %s (@%zu) present => %d",
elm->type->name, edx, present);
exts_count++;
exts_present += present;
Expand Down Expand Up @@ -410,7 +410,7 @@ SEQUENCE_encode_aper(const asn_TYPE_descriptor_t *td,
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (const void * const *)((const char *)sptr + elm->memb_offset);
if(!*memb_ptr2) {
ASN_DEBUG("Element %s %ld not present",
ASN_DEBUG("Element %s %zu not present",
elm->name, edx);
if(elm->optional)
continue;
Expand Down
8 changes: 5 additions & 3 deletions skeletons/constr_SET_OF_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ SET_OF_encode_aper(const asn_TYPE_descriptor_t *td,
if(ct) {
int not_in_root =
(list->count < ct->lower_bound || list->count > ct->upper_bound);
ASN_DEBUG("lb %ld ub %ld %s", ct->lower_bound, ct->upper_bound,
ASN_DEBUG("lb %lld ub %lld %s",
(long long int)ct->lower_bound,
(long long int)ct->upper_bound,
ct->flags & APC_EXTENSIBLE ? "ext" : "fix");
if(ct->flags & APC_EXTENSIBLE) {
/* Declare whether size is in extension root */
Expand Down Expand Up @@ -130,8 +132,8 @@ SET_OF_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(ct && ct->effective_bits >= 0) {
/* X.691, #19.5: No length determinant */
nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound + 1);
ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
(long)nelems, ct->lower_bound, td->name);
ASN_DEBUG("Preparing to fetch %ld+%lld elements from %s",
(long)nelems, (long long int)ct->lower_bound, td->name);
if(nelems < 0) ASN__DECODE_STARVED;
nelems += ct->lower_bound;
} else {
Expand Down