Commit aa61a0f8 authored by Lev Walkin's avatar Lev Walkin

pointer warning fixes

parent daeb2160
......@@ -7,6 +7,7 @@
* Add -fline-refs to avoid being unfriendly to version control systems.
* Default constraint checking fix.
Thanks to Bartosz Marcinkiewicz <bma@megawatt.com.pl>
* Get rid of non-standard pointer arithmetics on void* pointer.
0.9.24: 2013-Mar-16
......
......@@ -73,6 +73,7 @@ static enum xer_pbd_rval
NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
(void)td;
(void)sptr;
(void)chunk_buf; /* Going to be empty according to the rules below. */
/*
* There must be no content in self-terminating <NULL/> tag.
......
......@@ -195,7 +195,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}
/* Restore parsing context */
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
switch(ctx->phase) {
case 0:
......@@ -1143,7 +1143,7 @@ OCTET_STRING__decode_xer(asn_codec_ctx_t *opt_codec_ctx,
}
/* Restore parsing context */
ctx = (asn_struct_ctx_t *)(((void *)*sptr) + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)(((char *)*sptr) + specs->ctx_offset);
return xer_decode_general(opt_codec_ctx, ctx, *sptr, xml_tag,
buf_ptr, size, opt_unexpected_tag_decoder, body_receiver);
......@@ -1716,7 +1716,7 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
? (asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_DEF_OCTET_STRING_specs;
asn_struct_ctx_t *ctx = (asn_struct_ctx_t *)
((void *)st + specs->ctx_offset);
((char *)st + specs->ctx_offset);
struct _stack *stck;
if(!td || !st)
......
......@@ -34,7 +34,7 @@
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
ptr = ((const void *)ptr) + num;\
ptr = ((const char *)ptr) + num;\
size -= num; \
if(ctx->left >= 0) \
ctx->left -= num; \
......@@ -133,7 +133,7 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Start to parse where left previously
......@@ -211,7 +211,7 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
skip = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
(const void *)ptr + tag_len,
(const char *)ptr + tag_len,
LEFT - tag_len);
switch(skip) {
......@@ -244,7 +244,7 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
*/
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st + elm->memb_offset);
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
/*
* A pointer to a pointer
......@@ -390,7 +390,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
*/
elm = &td->elements[present-1];
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(memb_ptr == 0) {
if(elm->optional) {
erval.encoded = 0;
......@@ -400,7 +400,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
/*
......@@ -463,10 +463,10 @@ CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)
((const void *)ptr + elm->memb_offset);
((const char *)ptr + elm->memb_offset);
} else {
memb_ptr = (const void *)
((const void *)ptr + elm->memb_offset);
((const char *)ptr + elm->memb_offset);
}
return asn_TYPE_outmost_tag(elm->type, memb_ptr,
......@@ -498,7 +498,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const void *)sptr + elm->memb_offset);
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional)
return 0;
......@@ -508,7 +508,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
} else {
memb_ptr = (const void *)((const void *)sptr + elm->memb_offset);
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
}
if(elm->memb_constraints) {
......@@ -535,7 +535,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
buf_ptr = ((const void *)buf_ptr) + num;\
buf_ptr = (const void *)(((const char *)buf_ptr) + num); \
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -574,7 +574,7 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
if(ctx->phase == 0 && !*xml_tag)
ctx->phase = 1; /* Skip the outer tag checking phase */
......@@ -605,7 +605,7 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st
memb_ptr2 = (void **)((char *)st
+ elm->memb_offset);
} else {
memb_ptr = (char *)st + elm->memb_offset;
......@@ -797,10 +797,10 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
unsigned int mlen = strlen(mname);
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) _ASN_ENCODE_FAILED;
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
er.encoded = 0;
......@@ -884,7 +884,7 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
elm = &td->elements[value];
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st + elm->memb_offset);
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
memb_ptr = (char *)st + elm->memb_offset;
memb_ptr2 = &memb_ptr;
......@@ -962,7 +962,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
elm = &td->elements[present];
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) _ASN_ENCODE_FAILED;
} else {
memb_ptr = (char *)sptr + elm->memb_offset;
......@@ -1010,10 +1010,10 @@ CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const void *)sptr + elm->memb_offset);
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
} else {
memb_ptr = (const void *)((const void *)sptr + elm->memb_offset);
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
}
/* Print member's name and stuff */
......@@ -1053,11 +1053,11 @@ CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)ptr + elm->memb_offset);
memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
if(memb_ptr)
ASN_STRUCT_FREE(*elm->type, memb_ptr);
} else {
memb_ptr = (void *)((void *)ptr + elm->memb_offset);
memb_ptr = (void *)((char *)ptr + elm->memb_offset);
ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
}
}
......@@ -1082,7 +1082,7 @@ _fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) {
const void *present_ptr;
int present;
present_ptr = ((const void *)struct_ptr) + pres_offset;
present_ptr = ((const char *)struct_ptr) + pres_offset;
switch(pres_size) {
case sizeof(int): present = *(const int *)present_ptr; break;
......@@ -1100,7 +1100,7 @@ _fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) {
static void
_set_present_idx(void *struct_ptr, int pres_offset, int pres_size, int present) {
void *present_ptr;
present_ptr = ((void *)struct_ptr) + pres_offset;
present_ptr = ((char *)struct_ptr) + pres_offset;
switch(pres_size) {
case sizeof(int): *(int *)present_ptr = present; break;
......
......@@ -34,7 +34,7 @@
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
ptr = ((const void *)ptr) + num;\
ptr = ((const char *)ptr) + num; \
size -= num; \
if(ctx->left >= 0) \
ctx->left -= num; \
......@@ -144,7 +144,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Start to parse where left previously
......@@ -366,7 +366,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ber_tlv_tag_string(tlv_tag), edx);
skip = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
(const void *)ptr + tag_len,
(const char *)ptr + tag_len,
LEFT - tag_len);
ASN_DEBUG("Skip length %d in %s",
(int)skip, td->name);
......@@ -397,13 +397,13 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
*/
if(elements[edx].flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st + elements[edx].memb_offset);
memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset);
} else {
/*
* A pointer to a pointer
* holding the start of the structure
*/
memb_ptr = (void *)st + elements[edx].memb_offset;
memb_ptr = (char *)st + elements[edx].memb_offset;
memb_ptr2 = &memb_ptr;
}
/*
......@@ -489,7 +489,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ll = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
(const void *)ptr + tl, LEFT - tl);
(const char *)ptr + tl, LEFT - tl);
switch(ll) {
case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
/* Fall through */
......@@ -528,14 +528,14 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
asn_TYPE_member_t *elm = &td->elements[edx];
void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional) continue;
/* Mandatory element is missing */
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
erval = elm->type->der_encoder(elm->type, memb_ptr,
elm->tag_mode, elm->tag,
......@@ -567,10 +567,10 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) continue;
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
tmperval = elm->type->der_encoder(elm->type, memb_ptr,
elm->tag_mode, elm->tag,
......@@ -595,7 +595,7 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
buf_ptr = ((const void *)buf_ptr) + num;\
buf_ptr = ((const char *)buf_ptr) + num;\
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -637,7 +637,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
......@@ -667,9 +667,9 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st + elm->memb_offset);
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
memb_ptr = (void *)st + elm->memb_offset;
memb_ptr = (char *)st + elm->memb_offset;
memb_ptr2 = &memb_ptr;
}
......@@ -869,7 +869,7 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
unsigned int mlen = strlen(mname);
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional)
continue;
......@@ -877,7 +877,7 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
......@@ -917,14 +917,14 @@ SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const void *)sptr + elm->memb_offset);
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional) continue;
/* Print <absent> line */
/* Fall through */
}
} else {
memb_ptr = (const void *)((const void *)sptr + elm->memb_offset);
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
}
/* Indentation */
......@@ -960,11 +960,11 @@ SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
asn_TYPE_member_t *elm = &td->elements[edx];
void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(memb_ptr)
ASN_STRUCT_FREE(*elm->type, memb_ptr);
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
}
}
......@@ -994,7 +994,7 @@ SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const void *)sptr + elm->memb_offset);
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional)
continue;
......@@ -1004,7 +1004,7 @@ SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
} else {
memb_ptr = (const void *)((const void *)sptr + elm->memb_offset);
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
}
if(elm->memb_constraints) {
......@@ -1088,9 +1088,9 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((void *)st + elm->memb_offset);
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
memb_ptr = (void *)st + elm->memb_offset;
memb_ptr = (char *)st + elm->memb_offset;
memb_ptr2 = &memb_ptr;
}
......@@ -1171,9 +1171,9 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((void *)st + elm->memb_offset);
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
memb_ptr = (void *)((void *)st + elm->memb_offset);
memb_ptr = (void *)((char *)st + elm->memb_offset);
memb_ptr2 = &memb_ptr;
}
......@@ -1221,7 +1221,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((void *)st
memb_ptr2 = (void **)((char *)st
+ elm->memb_offset);
if(*memb_ptr2) continue;
} else {
......@@ -1265,10 +1265,10 @@ SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((void *)sptr + elm->memb_offset);
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
present = (*memb_ptr2 != 0);
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
memb_ptr2 = &memb_ptr;
present = 1;
}
......@@ -1334,10 +1334,10 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((void *)sptr + elm->memb_offset);
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
present = (*memb_ptr2 != 0);
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
memb_ptr2 = &memb_ptr;
present = 1;
}
......@@ -1373,7 +1373,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((void *)sptr + elm->memb_offset);
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
if(!*memb_ptr2) {
ASN_DEBUG("Element %s %d not present",
elm->name, edx);
......@@ -1383,7 +1383,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
memb_ptr2 = &memb_ptr;
}
......
......@@ -36,7 +36,7 @@ static int _SET_is_populated(asn_TYPE_descriptor_t *td, void *st);
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
ptr = ((const void *)ptr) + num;\
ptr = ((const char *)ptr) + num;\
size -= num; \
if(ctx->left >= 0) \
ctx->left -= num; \
......@@ -132,7 +132,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Start to parse where left previously
......@@ -250,7 +250,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
skip = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
(const void *)ptr + tag_len, LEFT - tag_len);
(const char *)ptr + tag_len, LEFT - tag_len);
switch(skip) {
case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
......@@ -271,7 +271,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* Check for duplications: must not overwrite
* already decoded elements.
*/
if(ASN_SET_ISPRESENT2((void *)st + specs->pres_offset, edx)) {
if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset, edx)) {
ASN_DEBUG("SET %s: Duplicate element %s (%d)",
td->name, elements[edx].name, edx);
RETURN(RC_FAIL);
......@@ -284,13 +284,13 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
*/
if(elements[edx].flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st + elements[edx].memb_offset);
memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset);
} else {
/*
* A pointer to a pointer
* holding the start of the structure
*/
memb_ptr = (void *)st + elements[edx].memb_offset;
memb_ptr = (char *)st + elements[edx].memb_offset;
memb_ptr2 = &memb_ptr;
}
/*
......@@ -302,7 +302,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
elements[edx].tag_mode);
switch(rval.code) {
case RC_OK:
ASN_SET_MKPRESENT((void *)st + specs->pres_offset, edx);
ASN_SET_MKPRESENT((char *)st + specs->pres_offset, edx);
break;
case RC_WMORE: /* More data expected */
if(!SIZE_VIOLATION) {
......@@ -369,7 +369,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ll = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
(const void *)ptr + tl, LEFT - tl);
(const char *)ptr + tl, LEFT - tl);
switch(ll) {
case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
/* Fall through */
......@@ -404,7 +404,7 @@ _SET_is_populated(asn_TYPE_descriptor_t *td, void *st) {
unsigned int midx, pres, must;
midx = edx/(8 * sizeof(specs->_mandatory_elements[0]));
pres = ((unsigned int *)((void *)st+specs->pres_offset))[midx];
pres = ((unsigned int *)((char *)st + specs->pres_offset))[midx];
must = sys_ntohl(specs->_mandatory_elements[midx]);
if((pres & must) == must) {
......@@ -473,7 +473,7 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
* Compute the length of the encoding of this member.
*/
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(!elm->optional)
/* Mandatory elements missing */
......@@ -486,7 +486,7 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
continue;
}
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
tmper = elm->type->der_encoder(elm->type, memb_ptr,
elm->tag_mode, elm->tag,
......@@ -547,10 +547,10 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
elm = &td->elements[t2m[edx].el_no];
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) continue;
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
tmper = elm->type->der_encoder(elm->type, memb_ptr,
elm->tag_mode, elm->tag,
......@@ -573,7 +573,7 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
buf_ptr = ((const void *)buf_ptr) + num;\
buf_ptr = ((const char *)buf_ptr) + num;\
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -613,7 +613,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Phases of XER/XML processing:
......@@ -637,7 +637,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void *memb_ptr; /* Pointer to the member */
void **memb_ptr2; /* Pointer to that pointer */
if(ASN_SET_ISPRESENT2((void *)st + specs->pres_offset,
if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset,
edx)) {
ASN_DEBUG("SET %s: Duplicate element %s (%d)",
td->name, elements[edx].name, edx);
......@@ -648,10 +648,9 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((void *)st
+ elm->memb_offset);
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
memb_ptr = (void *)st + elm->memb_offset;
memb_ptr = (char *)st + elm->memb_offset;
memb_ptr2 = &memb_ptr;
}
......@@ -663,7 +662,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(tmprval.code != RC_OK)
RETURN(tmprval.code);
ctx->phase = 1; /* Back to body processing */
ASN_SET_MKPRESENT((void *)st + specs->pres_offset, edx);
ASN_SET_MKPRESENT((char *)st + specs->pres_offset, edx);
ASN_DEBUG("XER/SET phase => %d", ctx->phase);
/* Fall through */
}
......@@ -827,7 +826,7 @@ SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
mlen = strlen(elm->name);
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)sptr + elm->memb_offset);
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional)
continue;
......@@ -835,7 +834,7 @@ SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((void *)sptr + elm->memb_offset);
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
if(!xcan)
......@@ -877,14 +876,14 @@ SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const void *)sptr + elm->memb_offset);
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional) continue;
/* Print <absent> line */
/* Fall through */
}
} else {
memb_ptr = (const void *)((const void *)sptr + elm->memb_offset);
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
}
_i_INDENT(1);
......@@ -919,11 +918,11 @@ SET_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
asn_TYPE_member_t *elm = &td->elements[edx];
void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((void *)ptr + elm->memb_offset);
memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
if(memb_ptr)
ASN_STRUCT_FREE(*elm->type, memb_ptr);
} else {
memb_ptr = (void *)((void *)ptr + elm->memb_offset);
memb_ptr = (void *)((char *)ptr + elm->memb_offset);
ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
}
}
......@@ -953,7 +952,7 @@ SET_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const void *)sptr + elm->memb_offset);
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional)
continue;
......@@ -963,7 +962,7 @@ SET_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
} else {
memb_ptr = (const void *)((const void *)sptr + elm->memb_offset);
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
}
if(elm->memb_constraints) {
......
......@@ -34,7 +34,7 @@
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
ptr = ((const void *)ptr) + num;\
ptr = ((const char *)ptr) + num;\
size -= num; \
if(ctx->left >= 0) \
ctx->left -= num; \
......@@ -100,7 +100,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Start to parse where left previously
......@@ -457,7 +457,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
buf_ptr = ((const void *)buf_ptr) + num;\
buf_ptr = ((const char *)buf_ptr) + num;\
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -505,7 +505,7 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Restore parsing context.
*/
ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Phases of XER/XML processing:
......@@ -627,7 +627,7 @@ SET_OF_encode_xer_callback(const void *buffer, size_t size, void *key) {
t->buffer = p;
t->size = newsize;
}
memcpy((void *)t->buffer + t->offset, buffer, size);
memcpy((char *)t->buffer + t->offset, buffer, size);
t->offset += size;
return 0;
}
......@@ -809,7 +809,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
asn_set_empty(list); /* Remove (list->array) */
specs = (asn_SET_OF_specifics_t *)td->specifics;
ctx = (asn_struct_ctx_t *)((void *)ptr + specs->ctx_offset);
ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset);
if(ctx->ptr) {
ASN_STRUCT_FREE(*elm->type, ctx->ptr);
ctx->ptr = 0;
......
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