presence unsigned
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index e7adbf7..435d592 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -67,7 +67,7 @@
static void _set_present_idx(void *sptr, int offset, int size, int pres);
static const void *_get_member_ptr(const asn_TYPE_descriptor_t *,
const void *sptr, asn_TYPE_member_t **elm,
- signed *present);
+ unsigned *present);
/*
* Tags are canonically sorted in the tag to member table.
@@ -365,7 +365,7 @@
asn_enc_rval_t erval;
void *memb_ptr;
size_t computed_size = 0;
- signed present;
+ unsigned present;
if(!sptr) ASN__ENCODE_FAILED;
@@ -379,7 +379,7 @@
* If the structure was not initialized, it cannot be encoded:
* can't deduce what to encode in the choice type.
*/
- if(present <= 0 || (unsigned)present > td->elements_count) {
+ if(present == 0 || present > td->elements_count) {
if(present == 0 && td->elements_count == 0) {
/* The CHOICE is empty?! */
erval.encoded = 0;
@@ -450,7 +450,7 @@
ber_tlv_tag_t
CHOICE_outmost_tag(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
- signed present;
+ unsigned present;
assert(tag_mode == 0); (void)tag_mode;
assert(tag == 0); (void)tag;
@@ -460,7 +460,7 @@
*/
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
- if(present > 0 && (unsigned)present <= td->elements_count) {
+ if(present > 0 && present <= td->elements_count) {
const asn_TYPE_member_t *elm = &td->elements[present-1];
const void *memb_ptr;
@@ -483,7 +483,7 @@
CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
- signed present;
+ unsigned present;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -496,7 +496,7 @@
* Figure out which CHOICE element is encoded.
*/
present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
- if(present > 0 && (unsigned)present <= td->elements_count) {
+ if(present > 0 && present <= td->elements_count) {
asn_TYPE_member_t *elm = &td->elements[present-1];
const void *memb_ptr;
@@ -780,7 +780,7 @@
asn_app_consume_bytes_f *cb, void *app_key) {
asn_CHOICE_specifics_t *specs=(asn_CHOICE_specifics_t *)td->specifics;
asn_enc_rval_t er;
- signed present;
+ unsigned present;
if(!sptr)
ASN__ENCODE_FAILED;
@@ -790,7 +790,7 @@
*/
present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
- if(present <= 0 || (unsigned)present > td->elements_count) {
+ if(present == 0 || present > td->elements_count) {
ASN__ENCODE_FAILED;
} else {
asn_enc_rval_t tmper;
@@ -917,7 +917,7 @@
asn_TYPE_member_t *elm; /* CHOICE's element */
const asn_per_constraint_t *ct;
void *memb_ptr;
- signed present;
+ unsigned present;
int present_enc;
if(!sptr) ASN__ENCODE_FAILED;
@@ -928,14 +928,13 @@
else if(td->per_constraints) ct = &td->per_constraints->value;
else ct = 0;
- present = _fetch_present_idx(sptr,
- specs->pres_offset, specs->pres_size);
+ present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
- /*
+ /*
* If the structure was not initialized properly, it cannot be encoded:
* can't deduce what to encode in the choice type.
*/
- if(present <= 0 || (unsigned)present > td->elements_count)
+ if(present == 0 || present > td->elements_count)
ASN__ENCODE_FAILED;
else
present--;
@@ -998,7 +997,7 @@
CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
- signed present;
+ unsigned present;
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
@@ -1010,7 +1009,7 @@
/*
* Print that element.
*/
- if(present > 0 && (unsigned)present <= td->elements_count) {
+ if(present > 0 && present <= td->elements_count) {
asn_TYPE_member_t *elm = &td->elements[present-1];
const void *memb_ptr;
@@ -1038,7 +1037,7 @@
void
CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
- signed present;
+ unsigned present;
if(!td || !ptr)
return;
@@ -1053,7 +1052,7 @@
/*
* Free that element.
*/
- if(present > 0 && (unsigned)present <= td->elements_count) {
+ if(present > 0 && present <= td->elements_count) {
asn_TYPE_member_t *elm = &td->elements[present-1];
void *memb_ptr;
@@ -1085,7 +1084,7 @@
static signed
_fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) {
const void *present_ptr;
- signed present;
+ unsigned present;
present_ptr = ((const char *)struct_ptr) + pres_offset;
@@ -1119,9 +1118,9 @@
static const void *
_get_member_ptr(const asn_TYPE_descriptor_t *td, const void *sptr,
- asn_TYPE_member_t **elm_ptr, signed *present_out) {
+ asn_TYPE_member_t **elm_ptr, unsigned *present_out) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
- signed present;
+ unsigned present;
if(!sptr) {
*elm_ptr = NULL;
@@ -1139,7 +1138,7 @@
* The presence index is intentionally 1-based to avoid
* treating zeroed structure as a valid one.
*/
- if(present > 0 && (unsigned)present <= td->elements_count) {
+ if(present > 0 && present <= td->elements_count) {
asn_TYPE_member_t *const elm = &td->elements[present - 1];
const void *memb_ptr;
@@ -1162,8 +1161,8 @@
CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) {
asn_TYPE_member_t *aelm;
asn_TYPE_member_t *belm;
- signed apresent = 0;
- signed bpresent = 0;
+ unsigned apresent = 0;
+ unsigned bpresent = 0;
const void *amember = _get_member_ptr(td, aptr, &aelm, &apresent);
const void *bmember = _get_member_ptr(td, bptr, &belm, &apresent);