Commit 8946c21d authored by Uri Blumenthal's avatar Uri Blumenthal

Add initializers to address valgrind error reports

parent 4a668cbf
......@@ -64,8 +64,8 @@ INTEGER_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
void *app_key) {
const INTEGER_t *st = (const INTEGER_t *)sptr;
asn_enc_rval_t rval;
INTEGER_t effective_integer;
asn_enc_rval_t rval = {0};
INTEGER_t effective_integer = {0};
ASN_DEBUG("%s %s as INTEGER (tm=%d)",
cb?"Encoding":"Estimating", td->name, tag_mode);
......@@ -77,7 +77,7 @@ INTEGER_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
if(st->buf) {
uint8_t *buf = st->buf;
uint8_t *end1 = buf + st->size - 1;
int shift;
int shift = 0;
/* Compute the number of superfluous leading bytes */
for(; buf < end1; buf++) {
......@@ -102,16 +102,16 @@ INTEGER_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
/* Remove leading superfluous bytes from the integer */
shift = buf - st->buf;
if(shift) {
union {
const uint8_t *c_buf;
uint8_t *nc_buf;
} unconst;
unconst.c_buf = st->buf;
effective_integer.buf = unconst.nc_buf + shift;
effective_integer.size = st->size - shift;
st = &effective_integer;
}
union {
const uint8_t *c_buf;
uint8_t *nc_buf;
} unconst;
unconst.c_buf = st->buf;
effective_integer.buf = unconst.nc_buf + shift;
effective_integer.size = st->size - shift;
st = &effective_integer;
}
}
rval = der_encode_primitive(td, st, tag_mode, tag, cb, app_key);
......@@ -135,10 +135,10 @@ INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_cons
char scratch[32];
uint8_t *buf = st->buf;
uint8_t *buf_end = st->buf + st->size;
intmax_t value;
intmax_t value = 0;
ssize_t wrote = 0;
char *p;
int ret;
char *p = NULL;
int ret = -1;
if(specs && specs->field_unsigned)
ret = asn_INTEGER2umax(st, (uintmax_t *)&value);
......@@ -209,7 +209,7 @@ int
INTEGER_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
const INTEGER_t *st = (const INTEGER_t *)sptr;
ssize_t ret;
ssize_t ret = -1;
(void)ilevel;
......
......@@ -561,9 +561,9 @@ CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
void *st = *struct_ptr; /* Target structure. */
asn_struct_ctx_t *ctx; /* Decoder context */
asn_dec_rval_t rval; /* Return value of a decoder */
asn_dec_rval_t rval = {0}; /* Return value of a decoder */
ssize_t consumed_myself = 0; /* Consumed bytes from ptr */
size_t edx; /* Element index */
size_t edx = 0; /* Element index */
/*
* Create the target structure if it is not present already.
......@@ -781,8 +781,8 @@ CHOICE_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
void *app_key) {
const asn_CHOICE_specifics_t *specs =
(const asn_CHOICE_specifics_t *)td->specifics;
asn_enc_rval_t er;
unsigned present;
asn_enc_rval_t er = {0};
unsigned present = 0;
if(!sptr)
ASN__ENCODE_FAILED;
......@@ -836,13 +836,13 @@ CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
asn_per_data_t *pd) {
const asn_CHOICE_specifics_t *specs =
(const asn_CHOICE_specifics_t *)td->specifics;
asn_dec_rval_t rv;
asn_dec_rval_t rv = {0};
const asn_per_constraint_t *ct;
asn_TYPE_member_t *elm; /* CHOICE's element */
void *memb_ptr;
void **memb_ptr2;
asn_TYPE_member_t *elm = {0}; /* CHOICE's element */
void *memb_ptr = NULL;
void **memb_ptr2 = NULL;
void *st = *sptr;
int value;
int value = 0;
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
ASN__DECODE_FAILED;
......@@ -921,11 +921,11 @@ CHOICE_encode_uper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, const void *sptr,
asn_per_outp_t *po) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
asn_TYPE_member_t *elm; /* CHOICE's element */
asn_TYPE_member_t *elm = {0}; /* CHOICE's element */
const asn_per_constraint_t *ct;
const void *memb_ptr;
unsigned present;
int present_enc;
const void *memb_ptr = NULL;
unsigned present = 0;
int present_enc = 0;
if(!sptr) ASN__ENCODE_FAILED;
......@@ -1015,13 +1015,13 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
asn_dec_rval_t rv;
asn_dec_rval_t rv = {0};
const asn_per_constraint_t *ct;
asn_TYPE_member_t *elm; /* CHOICE's element */
void *memb_ptr;
void **memb_ptr2;
asn_TYPE_member_t *elm = {0}; /* CHOICE's element */
void *memb_ptr = NULL;
void **memb_ptr2 = NULL;
void *st = *sptr;
int value;
int value = 0;
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
ASN__DECODE_FAILED;
......@@ -1098,10 +1098,10 @@ CHOICE_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
const asn_TYPE_member_t *elm; /* CHOICE's element */
const asn_TYPE_member_t *elm = {0}; /* CHOICE's element */
const asn_per_constraint_t *ct;
const void *memb_ptr;
int present;
const void *memb_ptr = NULL;
int present = 0;
if(!sptr) ASN__ENCODE_FAILED;
......@@ -1180,7 +1180,7 @@ int
CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
unsigned present;
unsigned present = 0;
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
......@@ -1222,7 +1222,7 @@ CHOICE_free(const asn_TYPE_descriptor_t *td, void *ptr,
enum asn_struct_free_method method) {
const asn_CHOICE_specifics_t *specs =
(const asn_CHOICE_specifics_t *)td->specifics;
unsigned present;
unsigned present = 0;
if(!td || !ptr)
return;
......@@ -1276,8 +1276,8 @@ CHOICE_free(const asn_TYPE_descriptor_t *td, void *ptr,
static unsigned
_fetch_present_idx(const void *struct_ptr, unsigned pres_offset,
unsigned pres_size) {
const void *present_ptr;
unsigned present;
const void *present_ptr = NULL;
unsigned present = 0;
present_ptr = ((const char *)struct_ptr) + pres_offset;
......@@ -1354,8 +1354,8 @@ _get_member_ptr(const asn_TYPE_descriptor_t *td, const void *sptr,
int
CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) {
asn_TYPE_member_t *aelm;
asn_TYPE_member_t *belm;
asn_TYPE_member_t *aelm = NULL;
asn_TYPE_member_t *belm = NULL;
unsigned apresent = 0;
unsigned bpresent = 0;
const void *amember = _get_member_ptr(td, aptr, &aelm, &apresent);
......
......@@ -16,8 +16,8 @@ asn_enc_rval_t
uper_encode(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, const void *sptr,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_per_outp_t po;
asn_enc_rval_t er;
asn_per_outp_t po = {0};
asn_enc_rval_t er = {0};
/*
* Invoke type-specific encoder.
......@@ -71,7 +71,7 @@ asn_enc_rval_t
uper_encode_to_buffer(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, void *buffer, size_t buffer_size) {
enc_to_buf_arg key;
enc_to_buf_arg key = {0};
key.buffer = buffer;
key.left = buffer_size;
......@@ -114,8 +114,8 @@ ssize_t
uper_encode_to_new_buffer(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, void **buffer_r) {
asn_enc_rval_t er;
enc_dyn_arg key;
asn_enc_rval_t er = {0};
enc_dyn_arg key = {0};
memset(&key, 0, sizeof(key));
......@@ -148,7 +148,7 @@ uper_encode_to_new_buffer(const asn_TYPE_descriptor_t *td,
/* Flush partially filled buffer */
static int
_uper_encode_flush_outp(asn_per_outp_t *po) {
uint8_t *buf;
uint8_t *buf = {0};
if(po->nboff == 0 && po->buffer == po->tmpspace)
return 0;
......@@ -167,7 +167,7 @@ asn_enc_rval_t
aper_encode_to_buffer(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, void *buffer, size_t buffer_size) {
enc_to_buf_arg key;
enc_to_buf_arg key = {0};
key.buffer = buffer;
key.left = buffer_size;
......@@ -181,8 +181,8 @@ ssize_t
aper_encode_to_new_buffer(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, void **buffer_r) {
asn_enc_rval_t er;
enc_dyn_arg key;
asn_enc_rval_t er = {0};
enc_dyn_arg key = {0};
memset(&key, 0, sizeof(key));
......@@ -210,7 +210,7 @@ aper_encode_to_new_buffer(const asn_TYPE_descriptor_t *td,
static int
_aper_encode_flush_outp(asn_per_outp_t *po) {
uint8_t *buf;
uint8_t *buf = NULL;
if(po->nboff == 0 && po->buffer == po->tmpspace)
return 0;
......@@ -232,8 +232,8 @@ asn_enc_rval_t
aper_encode(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
asn_per_outp_t po;
asn_enc_rval_t er;
asn_per_outp_t po = {0};
asn_enc_rval_t er = {0};
/*
* Invoke type-specific encoder.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment