diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c index b3b77d1f..19c81e72 100644 --- a/skeletons/BIT_STRING.c +++ b/skeletons/BIT_STRING.c @@ -126,6 +126,8 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); return er; +cb_failed: + _ASN_ENCODE_FAILED; } diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c index 992b9a89..43b890f2 100644 --- a/skeletons/BOOLEAN.c +++ b/skeletons/BOOLEAN.c @@ -148,6 +148,8 @@ BOOLEAN_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, } return er; +cb_failed: + _ASN_ENCODE_FAILED; } int diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c index 2730fc4d..e3b7a0ab 100644 --- a/skeletons/OCTET_STRING.c +++ b/skeletons/OCTET_STRING.c @@ -571,12 +571,8 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, uint8_t *end; size_t i; - if(!st || !st->buf) { - er.encoded = -1; - er.failed_type = td; - er.structure_ptr = sptr; - return er; - } + if(!st || !st->buf) + _ASN_ENCODE_FAILED; er.encoded = 0; @@ -621,6 +617,8 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, } return er; +cb_failed: + _ASN_ENCODE_FAILED; } asn_enc_rval_t @@ -636,7 +634,8 @@ OCTET_STRING_encode_xer_ascii(asn_TYPE_descriptor_t *td, void *sptr, if(!st || !st->buf) _ASN_ENCODE_FAILED; - _ASN_CALLBACK(st->buf, st->size); + if(cb(st->buf, st->size, app_key) < 0) + _ASN_ENCODE_FAILED; er.encoded = st->size; return er; diff --git a/skeletons/REAL.c b/skeletons/REAL.c index c6d90f33..6d3e55e6 100644 --- a/skeletons/REAL.c +++ b/skeletons/REAL.c @@ -12,7 +12,7 @@ #undef INT_MAX #define INT_MAX ((int)(((unsigned int)-1) >> 1)) -static const double real_zero; +static volatile double real_zero = 0.0; #ifndef NAN #define NAN (real_zero/real_zero) #endif diff --git a/skeletons/asn_internal.h b/skeletons/asn_internal.h index e8a69939..a7690eb0 100644 --- a/skeletons/asn_internal.h +++ b/skeletons/asn_internal.h @@ -46,9 +46,9 @@ static void ASN_DEBUG(const char *fmt, ...) { (void)fmt; }; /* * Invoke the application-supplied callback and fail, if something is wrong. */ -#define __ASN_E_cbc(buf, size) (cb((buf), (size), app_key) == -1) +#define __ASN_E_cbc(buf, size) (cb((buf), (size), app_key) < 0) #define _ASN_E_CALLBACK(foo) do { \ - if(foo) _ASN_ENCODE_FAILED; \ + if(foo) goto cb_failed; \ } while(0) #define _ASN_CALLBACK(buf, size) \ _ASN_E_CALLBACK(__ASN_E_cbc(buf, size)) diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c index 4db6d7b1..46fd5210 100644 --- a/skeletons/constr_CHOICE.c +++ b/skeletons/constr_CHOICE.c @@ -588,6 +588,8 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1); return er; +cb_failed: + _ASN_ENCODE_FAILED; } int diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c index 07c77728..83da765e 100644 --- a/skeletons/constr_SEQUENCE.c +++ b/skeletons/constr_SEQUENCE.c @@ -623,6 +623,8 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); return er; +cb_failed: + _ASN_ENCODE_FAILED; } int diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c index b99831f9..3d526d01 100644 --- a/skeletons/constr_SEQUENCE_OF.c +++ b/skeletons/constr_SEQUENCE_OF.c @@ -128,5 +128,7 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); return er; +cb_failed: + _ASN_ENCODE_FAILED; } diff --git a/skeletons/xer_encoder.c b/skeletons/xer_encoder.c index 3c97a8f7..d3f04d66 100644 --- a/skeletons/xer_encoder.c +++ b/skeletons/xer_encoder.c @@ -19,12 +19,7 @@ xer_encode(asn_TYPE_descriptor_t *td, void *sptr, size_t mlen; int xcan = (xer_flags & XER_F_CANONICAL) ? 1 : 2; - if(!td || !sptr) { - er.encoded = -1; - er.failed_type = td; - er.structure_ptr = sptr; - return er; - } + if(!td || !sptr) goto cb_failed; mname = td->name; mlen = strlen(mname); @@ -34,11 +29,13 @@ xer_encode(asn_TYPE_descriptor_t *td, void *sptr, tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key); if(tmper.encoded == -1) return tmper; - _ASN_CALLBACK3("\n",xcan); + _ASN_CALLBACK3("\n", xcan); - er.encoded = 2 + (2 * xcan) + (2 * mlen) + tmper.encoded; + er.encoded = 4 + xcan + (2 * mlen) + tmper.encoded; return er; +cb_failed: + _ASN_ENCODE_FAILED; } /*