constness fixes, round-trip and fuzz-testing for CHOICE
diff --git a/tests/tests-asn1c-compiler/73-circular-OK.asn1.-Pfwide-types b/tests/tests-asn1c-compiler/73-circular-OK.asn1.-Pfwide-types
index 3bdfca4..3ddb5ce 100644
--- a/tests/tests-asn1c-compiler/73-circular-OK.asn1.-Pfwide-types
+++ b/tests/tests-asn1c-compiler/73-circular-OK.asn1.-Pfwide-types
@@ -42,7 +42,7 @@
.type = &asn_DEF_EpytRef,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = ""
},
};
@@ -78,7 +78,7 @@
.type = &asn_DEF_data_2,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "data"
},
};
@@ -209,7 +209,7 @@
.type = &asn_DEF_Type,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = ""
},
};
@@ -245,7 +245,7 @@
.type = &asn_DEF_stype_2,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "stype"
},
{ ATF_POINTER, 2, offsetof(struct Epyt, type),
@@ -254,7 +254,7 @@
.type = &asn_DEF_Type,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "type"
},
{ ATF_POINTER, 1, offsetof(struct Epyt, ypet),
@@ -263,7 +263,7 @@
.type = &asn_DEF_Ypet,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "ypet"
},
};
@@ -392,7 +392,7 @@
/*** <<< CODE [Ypet] >>> ***/
static int
-memb_patest1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
+memb_patest1_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const IA5String_t *st = (const IA5String_t *)sptr;
@@ -416,7 +416,7 @@
}
static int
-memb_patest2_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
+memb_patest2_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const IA5String_t *st = (const IA5String_t *)sptr;
@@ -442,25 +442,29 @@
/*** <<< STAT-DEFS [Ypet] >>> ***/
-static int asn_DFL_3_set_7(int set_value, void **sptr) {
+static int asn_DFL_3_cmp_7(const void *sptr) {
+ const INTEGER_t *st = sptr;
+
+ if(!st) {
+ return -1; /* No value is not a default value */
+ }
+
+ /* Test default value 7 */
+ long value;
+ if(asn_INTEGER2long(st, &value))
+ return -1;
+ return (value != 7);
+}
+static int asn_DFL_3_set_7(void **sptr) {
INTEGER_t *st = *sptr;
if(!st) {
- if(!set_value) return -1; /* Not a default value */
st = (*sptr = CALLOC(1, sizeof(*st)));
if(!st) return -1;
}
- if(set_value) {
- /* Install default value 7 */
- return asn_long2INTEGER(st, 7);
- } else {
- /* Test default value 7 */
- long value;
- if(asn_INTEGER2long(st, &value))
- return -1;
- return (value == 7);
- }
+ /* Install default value 7 */
+ return asn_long2INTEGER(st, 7);
}
static asn_TYPE_member_t asn_MBR_senums_4[] = {
{ ATF_POINTER, 0, 0,
@@ -469,7 +473,7 @@
.type = &asn_DEF_EnumType,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = ""
},
};
@@ -505,7 +509,7 @@
.type = &asn_DEF_Epyt,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "epyt"
},
{ ATF_POINTER, 1, offsetof(struct Ypet, plain),
@@ -514,7 +518,8 @@
.type = &asn_DEF_INTEGER,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = asn_DFL_3_set_7, /* DEFAULT 7 */
+ .default_value_cmp = asn_DFL_3_cmp_7, /* Compare DEFAULT 7 */
+ .default_value_set = asn_DFL_3_set_7, /* Set DEFAULT 7 */
.name = "plain"
},
{ ATF_NOFLAGS, 0, offsetof(struct Ypet, senums),
@@ -523,7 +528,7 @@
.type = &asn_DEF_senums_4,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "senums"
},
{ ATF_NOFLAGS, 0, offsetof(struct Ypet, patest1),
@@ -532,7 +537,7 @@
.type = &asn_DEF_IA5String,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = memb_patest1_constraint_1 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "patest1"
},
{ ATF_NOFLAGS, 0, offsetof(struct Ypet, patest2),
@@ -541,7 +546,7 @@
.type = &asn_DEF_IA5String,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = memb_patest2_constraint_1 },
- .default_value = 0,
+ 0, 0, /* No default value */
.name = "patest2"
},
};