From 0cb64e86a5b2acf2013708fe36e6bc93b48f7765 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 29 Dec 2020 14:48:41 +0100 Subject: [PATCH] Avoid using reserved identifiers in the SUPL library (clang-tidy check: bugprone-reserved-identifier) --- src/core/libs/supl/asn-rrlp/BIT_STRING.c | 6 +-- src/core/libs/supl/asn-rrlp/OCTET_STRING.c | 42 +++++++++---------- src/core/libs/supl/asn-rrlp/constr_CHOICE.c | 32 +++++++------- src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c | 4 +- src/core/libs/supl/asn-rrlp/constr_SET_OF.c | 24 +++++------ src/core/libs/supl/asn-rrlp/constr_TYPE.c | 8 ++-- src/core/libs/supl/asn-rrlp/constraints.c | 4 +- src/core/libs/supl/asn-rrlp/per_encoder.c | 4 +- src/core/libs/supl/asn-supl/BIT_STRING.c | 6 +-- src/core/libs/supl/asn-supl/GeneralizedTime.c | 4 +- src/core/libs/supl/asn-supl/OCTET_STRING.c | 42 +++++++++---------- src/core/libs/supl/asn-supl/constr_CHOICE.c | 32 +++++++------- src/core/libs/supl/asn-supl/constr_SEQUENCE.c | 4 +- src/core/libs/supl/asn-supl/constr_SET_OF.c | 24 +++++------ src/core/libs/supl/asn-supl/constr_TYPE.c | 8 ++-- src/core/libs/supl/asn-supl/constraints.c | 4 +- src/core/libs/supl/asn-supl/per_encoder.c | 4 +- 17 files changed, 126 insertions(+), 126 deletions(-) diff --git a/src/core/libs/supl/asn-rrlp/BIT_STRING.c b/src/core/libs/supl/asn-rrlp/BIT_STRING.c index 5bb0c4ae7..a683caf02 100644 --- a/src/core/libs/supl/asn-rrlp/BIT_STRING.c +++ b/src/core/libs/supl/asn-rrlp/BIT_STRING.c @@ -63,7 +63,7 @@ int BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return 0; } -static char *_bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101", +static char *bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"}; @@ -107,8 +107,8 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, _i_ASN_TEXT_INDENT(1, ilevel); } } - memcpy(p + 0, _bit_pattern[v >> 4], 4); - memcpy(p + 4, _bit_pattern[v & 0x0f], 4); + memcpy(p + 0, bit_pattern[v >> 4], 4); + memcpy(p + 4, bit_pattern[v & 0x0f], 4); p += 8; } diff --git a/src/core/libs/supl/asn-rrlp/OCTET_STRING.c b/src/core/libs/supl/asn-rrlp/OCTET_STRING.c index 96120193c..b54db4624 100644 --- a/src/core/libs/supl/asn-rrlp/OCTET_STRING.c +++ b/src/core/libs/supl/asn-rrlp/OCTET_STRING.c @@ -121,7 +121,7 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { * necessity to demonstrate that acquired skill everywhere afterwards. * No, I am not going to explain what the following stuff is. */ -struct _stack_el +struct stack_el { ber_tlv_len_t left; /* What's left to read (or -1) */ ber_tlv_len_t got; /* What was actually processed */ @@ -129,18 +129,18 @@ struct _stack_el int want_nulls; /* Want null "end of content" octets? */ int bits_chopped; /* Flag in BIT STRING mode */ ber_tlv_tag_t tag; /* For debugging purposes */ - struct _stack_el *prev; - struct _stack_el *next; + struct stack_el *prev; + struct stack_el *next; }; -struct _stack +struct stack { - struct _stack_el *tail; - struct _stack_el *cur_ptr; + struct stack_el *tail; + struct stack_el *cur_ptr; }; -static struct _stack_el *OS__add_stack_el(struct _stack *st) +static struct stack_el *OS__add_stack_el(struct stack *st) { - struct _stack_el *nel; + struct stack_el *nel; /* * Reuse the old stack frame or allocate a new one. @@ -154,7 +154,7 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st) } else { - nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el)); + nel = (struct stack_el *)CALLOC(1, sizeof(struct stack_el)); if (nel == NULL) { return NULL; @@ -175,9 +175,9 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st) return nel; } -static struct _stack *_new_stack() +static struct stack *new_stack() { - return (struct _stack *)CALLOC(1, sizeof(struct _stack)); + return (struct stack *)CALLOC(1, sizeof(struct stack)); } /* @@ -195,8 +195,8 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_dec_rval_t rval; asn_struct_ctx_t *ctx; ssize_t consumed_myself = 0; - struct _stack *stck; /* Expectations stack structure */ - struct _stack_el *sel = 0; /* Stack element */ + struct stack *stck; /* Expectations stack structure */ + struct stack_el *sel = 0; /* Stack element */ int tlv_constr; enum asn_OS_Subvariant type_variant = specs->subvariant; @@ -238,10 +238,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* * Complex operation, requires stack of expectations. */ - ctx->ptr = _new_stack(); + ctx->ptr = new_stack(); if (ctx->ptr) { - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; } else { @@ -269,7 +269,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* * Fill the stack with expectations. */ - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; sel = stck->cur_ptr; do { @@ -292,7 +292,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { if (sel->prev) { - struct _stack_el *prev = sel->prev; + struct stack_el *prev = sel->prev; if (prev->left != -1) { if (prev->left < sel->got) @@ -500,7 +500,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, NEXT_PHASE(ctx); /* Fall through */ case 2: - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; sel = stck->cur_ptr; ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d", (long)sel->left, (long)size, (long)sel->got, @@ -2207,7 +2207,7 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) : &asn_DEF_OCTET_STRING_specs; asn_struct_ctx_t *ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); - struct _stack *stck; + struct stack *stck; if (!td || !st) { @@ -2225,12 +2225,12 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) /* * Remove decode-time stack. */ - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; if (stck) { while (stck->tail) { - struct _stack_el *sel = stck->tail; + struct stack_el *sel = stck->tail; stck->tail = sel->prev; FREEMEM(sel); } diff --git a/src/core/libs/supl/asn-rrlp/constr_CHOICE.c b/src/core/libs/supl/asn-rrlp/constr_CHOICE.c index 5b03745bf..4cc5d8a34 100644 --- a/src/core/libs/supl/asn-rrlp/constr_CHOICE.c +++ b/src/core/libs/supl/asn-rrlp/constr_CHOICE.c @@ -70,14 +70,14 @@ /* * See the definitions. */ -static int _fetch_present_idx(const void *struct_ptr, int pres_offset, +static int fetch_present_idx(const void *struct_ptr, int pres_offset, int size); -static void _set_present_idx(void *struct_ptr, int offset, int size, int pres); +static void set_present_idx(void *struct_ptr, int offset, int size, int pres); /* * Tags are canonically sorted in the tag to member table. */ -static int _search4tag(const void *ap, const void *bp) +static int search4tag(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; @@ -224,7 +224,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, key.el_tag = tlv_tag; t2m = (asn_TYPE_tag2member_t *)bsearch( &key, specs->tag2el, specs->tag2el_count, - sizeof(specs->tag2el[0]), _search4tag); + sizeof(specs->tag2el[0]), search4tag); if (t2m) { /* @@ -308,7 +308,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } /* Set presence to be able to free it properly at any * time */ - _set_present_idx(st, specs->pres_offset, + set_present_idx(st, specs->pres_offset, specs->pres_size, ctx->step + 1); /* * Invoke the member fetch routine according to member's @@ -448,7 +448,7 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name); - 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, it cannot be encoded: @@ -550,7 +550,7 @@ ber_tlv_tag_t CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); if (present > 0 || present <= td->elements_count) { @@ -593,7 +593,7 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); if (present > 0 && present <= td->elements_count) { asn_TYPE_member_t *elm = &td->elements[present - 1]; @@ -758,7 +758,7 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, assert(_fetch_present_idx(st, specs->pres_offset, specs->pres_size) == 0); /* Record what we've got */ - _set_present_idx(st, specs->pres_offset, specs->pres_size, + set_present_idx(st, specs->pres_offset, specs->pres_size, edx + 1); ctx->phase = 3; /* Fall through */ @@ -942,7 +942,7 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); if (present <= 0 || present > td->elements_count) { @@ -1095,7 +1095,7 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, } /* Set presence to be able to free it later */ - _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); + set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); elm = &td->elements[value]; if (elm->flags & ATF_POINTER) @@ -1159,7 +1159,7 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, 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: @@ -1268,7 +1268,7 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); /* * Print that element. @@ -1327,7 +1327,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); /* * Free that element. @@ -1367,7 +1367,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) * is guaranteed to be aligned properly. ASN.1 compiler itself does not * produce packed code. */ -static int _fetch_present_idx(const void *struct_ptr, int pres_offset, +static int fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) { const void *present_ptr; @@ -1395,7 +1395,7 @@ static int _fetch_present_idx(const void *struct_ptr, int pres_offset, return present; } -static void _set_present_idx(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; diff --git a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c index ec46d9778..59acb6e90 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c +++ b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c @@ -83,7 +83,7 @@ /* * Tags are canonically sorted in the tag2element map. */ -static int _t2e_cmp(const void *ap, const void *bp) +static int t2e_cmp(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; @@ -375,7 +375,7 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, key.el_no = edx; t2m = (asn_TYPE_tag2member_t *)bsearch( &key, specs->tag2el, specs->tag2el_count, - sizeof(specs->tag2el[0]), _t2e_cmp); + sizeof(specs->tag2el[0]), t2e_cmp); if (t2m) { asn_TYPE_tag2member_t *best = 0; diff --git a/src/core/libs/supl/asn-rrlp/constr_SET_OF.c b/src/core/libs/supl/asn-rrlp/constr_SET_OF.c index 1d55053cb..82f9354cb 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SET_OF.c +++ b/src/core/libs/supl/asn-rrlp/constr_SET_OF.c @@ -331,16 +331,16 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* * Internally visible buffer holding a single encoded element. */ -struct _el_buffer +struct el_buffer { uint8_t *buf; size_t length; size_t size; }; /* Append bytes to the above structure */ -static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) +static int el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { - struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; + struct el_buffer *el_buf = (struct el_buffer *)el_buf_ptr; if (el_buf->length + size > el_buf->size) { @@ -352,10 +352,10 @@ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) el_buf->length += size; return 0; } -static int _el_buf_cmp(const void *ap, const void *bp) +static int el_buf_cmp(const void *ap, const void *bp) { - const struct _el_buffer *a = (const struct _el_buffer *)ap; - const struct _el_buffer *b = (const struct _el_buffer *)bp; + const struct el_buffer *a = (const struct el_buffer *)ap; + const struct el_buffer *b = (const struct el_buffer *)bp; int ret; size_t common_len; @@ -397,7 +397,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); size_t computed_size = 0; ssize_t encoding_size = 0; - struct _el_buffer *encoded_els; + struct el_buffer *encoded_els; ssize_t eels_count = 0; size_t max_encoded_len = 1; asn_enc_rval_t erval; @@ -456,7 +456,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, * encoded elements. */ encoded_els = - (struct _el_buffer *)MALLOC(list->count * sizeof(encoded_els[0])); + (struct el_buffer *)MALLOC(list->count * sizeof(encoded_els[0])); if (encoded_els == NULL) { erval.encoded = -1; @@ -473,7 +473,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for (edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; - struct _el_buffer *encoded_el = &encoded_els[eels_count]; + struct el_buffer *encoded_el = &encoded_els[eels_count]; if (!memb_ptr) { @@ -505,7 +505,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, /* * Encode the member into the prepared space. */ - erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, _el_addbytes, + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, el_addbytes, encoded_el); if (erval.encoded == -1) { @@ -523,7 +523,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, /* * Sort the encoded elements according to their encoding. */ - qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); + qsort(encoded_els, eels_count, sizeof(encoded_els[0]), el_buf_cmp); /* * Report encoded elements to the application. @@ -532,7 +532,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, ret = 0; for (edx = 0; edx < eels_count; edx++) { - struct _el_buffer *encoded_el = &encoded_els[edx]; + struct el_buffer *encoded_el = &encoded_els[edx]; /* Report encoded chunks to the application */ if (ret == 0 && cb(encoded_el->buf, encoded_el->length, app_key) < 0) diff --git a/src/core/libs/supl/asn-rrlp/constr_TYPE.c b/src/core/libs/supl/asn-rrlp/constr_TYPE.c index 50f349ded..09aa6966d 100644 --- a/src/core/libs/supl/asn-rrlp/constr_TYPE.c +++ b/src/core/libs/supl/asn-rrlp/constr_TYPE.c @@ -11,7 +11,7 @@ */ int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; } -static asn_app_consume_bytes_f _print2fp; +static asn_app_consume_bytes_f print2fp; /* * Return the outmost tag of the type. @@ -49,13 +49,13 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) } /* Invoke type-specific printer */ - if (td->print_struct(td, struct_ptr, 1, _print2fp, stream)) + if (td->print_struct(td, struct_ptr, 1, print2fp, stream)) { return -1; } /* Terminate the output */ - if (_print2fp("\n", 1, stream)) + if (print2fp("\n", 1, stream)) { return -1; } @@ -64,7 +64,7 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) } /* Dump the data into the specified stdio stream */ -static int _print2fp(const void *buffer, size_t size, void *app_key) +static int print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; diff --git a/src/core/libs/supl/asn-rrlp/constraints.c b/src/core/libs/supl/asn-rrlp/constraints.c index bf278a66d..7de1cabfd 100644 --- a/src/core/libs/supl/asn-rrlp/constraints.c +++ b/src/core/libs/supl/asn-rrlp/constraints.c @@ -42,7 +42,7 @@ struct errbufDesc size_t errlen; }; -static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, +static void asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, const void *sptr, const char *fmt, ...) { struct errbufDesc *arg = key; @@ -98,7 +98,7 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor, arg.errlen = errlen ? *errlen : 0; ret = type_descriptor->check_constraints(type_descriptor, struct_ptr, - _asn_i_ctfailcb, &arg); + asn_i_ctfailcb, &arg); if (ret == -1 && errlen) { *errlen = arg.errlen; diff --git a/src/core/libs/supl/asn-rrlp/per_encoder.c b/src/core/libs/supl/asn-rrlp/per_encoder.c index 23d1dc8cc..d3e6de9ab 100644 --- a/src/core/libs/supl/asn-rrlp/per_encoder.c +++ b/src/core/libs/supl/asn-rrlp/per_encoder.c @@ -123,7 +123,7 @@ ssize_t uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, */ /* Flush partially filled buffer */ -static int _uper_encode_flush_outp(asn_per_outp_t *po) +static int uper_encode_flush_outp(asn_per_outp_t *po) { uint8_t *buf; @@ -177,7 +177,7 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, /* Set number of bits encoded to a firm value */ er.encoded = (po.flushed_bytes << 3) + bits_to_flush; - if (_uper_encode_flush_outp(&po)) + if (uper_encode_flush_outp(&po)) { _ASN_ENCODE_FAILED; } diff --git a/src/core/libs/supl/asn-supl/BIT_STRING.c b/src/core/libs/supl/asn-supl/BIT_STRING.c index 5bb0c4ae7..a683caf02 100644 --- a/src/core/libs/supl/asn-supl/BIT_STRING.c +++ b/src/core/libs/supl/asn-supl/BIT_STRING.c @@ -63,7 +63,7 @@ int BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return 0; } -static char *_bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101", +static char *bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"}; @@ -107,8 +107,8 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, _i_ASN_TEXT_INDENT(1, ilevel); } } - memcpy(p + 0, _bit_pattern[v >> 4], 4); - memcpy(p + 4, _bit_pattern[v & 0x0f], 4); + memcpy(p + 0, bit_pattern[v >> 4], 4); + memcpy(p + 4, bit_pattern[v & 0x0f], 4); p += 8; } diff --git a/src/core/libs/supl/asn-supl/GeneralizedTime.c b/src/core/libs/supl/asn-supl/GeneralizedTime.c index 4bc2f6e37..113de45ae 100644 --- a/src/core/libs/supl/asn-supl/GeneralizedTime.c +++ b/src/core/libs/supl/asn-supl/GeneralizedTime.c @@ -2,9 +2,9 @@ * SPDX-FileCopyrightText: (c) 2003, 2004 Lev Walkin . All rights reserved. * SPDX-License-Identifier: BSD-1-Clause */ -#define _POSIX_PTHREAD_SEMANTICS /* for Sun */ +#define POSIX_PTHREAD_SEMANTICS /* for Sun */ #ifndef _REENTRANT -#define _REENTRANT /* for Sun */ +#define REENTRANT /* for Sun */ #endif #include #include diff --git a/src/core/libs/supl/asn-supl/OCTET_STRING.c b/src/core/libs/supl/asn-supl/OCTET_STRING.c index 96120193c..b54db4624 100644 --- a/src/core/libs/supl/asn-supl/OCTET_STRING.c +++ b/src/core/libs/supl/asn-supl/OCTET_STRING.c @@ -121,7 +121,7 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { * necessity to demonstrate that acquired skill everywhere afterwards. * No, I am not going to explain what the following stuff is. */ -struct _stack_el +struct stack_el { ber_tlv_len_t left; /* What's left to read (or -1) */ ber_tlv_len_t got; /* What was actually processed */ @@ -129,18 +129,18 @@ struct _stack_el int want_nulls; /* Want null "end of content" octets? */ int bits_chopped; /* Flag in BIT STRING mode */ ber_tlv_tag_t tag; /* For debugging purposes */ - struct _stack_el *prev; - struct _stack_el *next; + struct stack_el *prev; + struct stack_el *next; }; -struct _stack +struct stack { - struct _stack_el *tail; - struct _stack_el *cur_ptr; + struct stack_el *tail; + struct stack_el *cur_ptr; }; -static struct _stack_el *OS__add_stack_el(struct _stack *st) +static struct stack_el *OS__add_stack_el(struct stack *st) { - struct _stack_el *nel; + struct stack_el *nel; /* * Reuse the old stack frame or allocate a new one. @@ -154,7 +154,7 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st) } else { - nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el)); + nel = (struct stack_el *)CALLOC(1, sizeof(struct stack_el)); if (nel == NULL) { return NULL; @@ -175,9 +175,9 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st) return nel; } -static struct _stack *_new_stack() +static struct stack *new_stack() { - return (struct _stack *)CALLOC(1, sizeof(struct _stack)); + return (struct stack *)CALLOC(1, sizeof(struct stack)); } /* @@ -195,8 +195,8 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_dec_rval_t rval; asn_struct_ctx_t *ctx; ssize_t consumed_myself = 0; - struct _stack *stck; /* Expectations stack structure */ - struct _stack_el *sel = 0; /* Stack element */ + struct stack *stck; /* Expectations stack structure */ + struct stack_el *sel = 0; /* Stack element */ int tlv_constr; enum asn_OS_Subvariant type_variant = specs->subvariant; @@ -238,10 +238,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* * Complex operation, requires stack of expectations. */ - ctx->ptr = _new_stack(); + ctx->ptr = new_stack(); if (ctx->ptr) { - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; } else { @@ -269,7 +269,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* * Fill the stack with expectations. */ - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; sel = stck->cur_ptr; do { @@ -292,7 +292,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { if (sel->prev) { - struct _stack_el *prev = sel->prev; + struct stack_el *prev = sel->prev; if (prev->left != -1) { if (prev->left < sel->got) @@ -500,7 +500,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, NEXT_PHASE(ctx); /* Fall through */ case 2: - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; sel = stck->cur_ptr; ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d", (long)sel->left, (long)size, (long)sel->got, @@ -2207,7 +2207,7 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) : &asn_DEF_OCTET_STRING_specs; asn_struct_ctx_t *ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); - struct _stack *stck; + struct stack *stck; if (!td || !st) { @@ -2225,12 +2225,12 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) /* * Remove decode-time stack. */ - stck = (struct _stack *)ctx->ptr; + stck = (struct stack *)ctx->ptr; if (stck) { while (stck->tail) { - struct _stack_el *sel = stck->tail; + struct stack_el *sel = stck->tail; stck->tail = sel->prev; FREEMEM(sel); } diff --git a/src/core/libs/supl/asn-supl/constr_CHOICE.c b/src/core/libs/supl/asn-supl/constr_CHOICE.c index 5b03745bf..4cc5d8a34 100644 --- a/src/core/libs/supl/asn-supl/constr_CHOICE.c +++ b/src/core/libs/supl/asn-supl/constr_CHOICE.c @@ -70,14 +70,14 @@ /* * See the definitions. */ -static int _fetch_present_idx(const void *struct_ptr, int pres_offset, +static int fetch_present_idx(const void *struct_ptr, int pres_offset, int size); -static void _set_present_idx(void *struct_ptr, int offset, int size, int pres); +static void set_present_idx(void *struct_ptr, int offset, int size, int pres); /* * Tags are canonically sorted in the tag to member table. */ -static int _search4tag(const void *ap, const void *bp) +static int search4tag(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; @@ -224,7 +224,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, key.el_tag = tlv_tag; t2m = (asn_TYPE_tag2member_t *)bsearch( &key, specs->tag2el, specs->tag2el_count, - sizeof(specs->tag2el[0]), _search4tag); + sizeof(specs->tag2el[0]), search4tag); if (t2m) { /* @@ -308,7 +308,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } /* Set presence to be able to free it properly at any * time */ - _set_present_idx(st, specs->pres_offset, + set_present_idx(st, specs->pres_offset, specs->pres_size, ctx->step + 1); /* * Invoke the member fetch routine according to member's @@ -448,7 +448,7 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name); - 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, it cannot be encoded: @@ -550,7 +550,7 @@ ber_tlv_tag_t CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); if (present > 0 || present <= td->elements_count) { @@ -593,7 +593,7 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); if (present > 0 && present <= td->elements_count) { asn_TYPE_member_t *elm = &td->elements[present - 1]; @@ -758,7 +758,7 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, assert(_fetch_present_idx(st, specs->pres_offset, specs->pres_size) == 0); /* Record what we've got */ - _set_present_idx(st, specs->pres_offset, specs->pres_size, + set_present_idx(st, specs->pres_offset, specs->pres_size, edx + 1); ctx->phase = 3; /* Fall through */ @@ -942,7 +942,7 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); if (present <= 0 || present > td->elements_count) { @@ -1095,7 +1095,7 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, } /* Set presence to be able to free it later */ - _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); + set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); elm = &td->elements[value]; if (elm->flags & ATF_POINTER) @@ -1159,7 +1159,7 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, 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: @@ -1268,7 +1268,7 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); /* * Print that element. @@ -1327,7 +1327,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) /* * Figure out which CHOICE element is encoded. */ - present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); + present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); /* * Free that element. @@ -1367,7 +1367,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) * is guaranteed to be aligned properly. ASN.1 compiler itself does not * produce packed code. */ -static int _fetch_present_idx(const void *struct_ptr, int pres_offset, +static int fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) { const void *present_ptr; @@ -1395,7 +1395,7 @@ static int _fetch_present_idx(const void *struct_ptr, int pres_offset, return present; } -static void _set_present_idx(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; diff --git a/src/core/libs/supl/asn-supl/constr_SEQUENCE.c b/src/core/libs/supl/asn-supl/constr_SEQUENCE.c index 691b51acb..4cd4ec093 100644 --- a/src/core/libs/supl/asn-supl/constr_SEQUENCE.c +++ b/src/core/libs/supl/asn-supl/constr_SEQUENCE.c @@ -83,7 +83,7 @@ /* * Tags are canonically sorted in the tag2element map. */ -static int _t2e_cmp(const void *ap, const void *bp) +static int t2e_cmp(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; @@ -375,7 +375,7 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, key.el_no = edx; t2m = (asn_TYPE_tag2member_t *)bsearch( &key, specs->tag2el, specs->tag2el_count, - sizeof(specs->tag2el[0]), _t2e_cmp); + sizeof(specs->tag2el[0]), t2e_cmp); if (t2m) { asn_TYPE_tag2member_t *best = 0; diff --git a/src/core/libs/supl/asn-supl/constr_SET_OF.c b/src/core/libs/supl/asn-supl/constr_SET_OF.c index 1d55053cb..82f9354cb 100644 --- a/src/core/libs/supl/asn-supl/constr_SET_OF.c +++ b/src/core/libs/supl/asn-supl/constr_SET_OF.c @@ -331,16 +331,16 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* * Internally visible buffer holding a single encoded element. */ -struct _el_buffer +struct el_buffer { uint8_t *buf; size_t length; size_t size; }; /* Append bytes to the above structure */ -static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) +static int el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { - struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; + struct el_buffer *el_buf = (struct el_buffer *)el_buf_ptr; if (el_buf->length + size > el_buf->size) { @@ -352,10 +352,10 @@ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) el_buf->length += size; return 0; } -static int _el_buf_cmp(const void *ap, const void *bp) +static int el_buf_cmp(const void *ap, const void *bp) { - const struct _el_buffer *a = (const struct _el_buffer *)ap; - const struct _el_buffer *b = (const struct _el_buffer *)bp; + const struct el_buffer *a = (const struct el_buffer *)ap; + const struct el_buffer *b = (const struct el_buffer *)bp; int ret; size_t common_len; @@ -397,7 +397,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); size_t computed_size = 0; ssize_t encoding_size = 0; - struct _el_buffer *encoded_els; + struct el_buffer *encoded_els; ssize_t eels_count = 0; size_t max_encoded_len = 1; asn_enc_rval_t erval; @@ -456,7 +456,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, * encoded elements. */ encoded_els = - (struct _el_buffer *)MALLOC(list->count * sizeof(encoded_els[0])); + (struct el_buffer *)MALLOC(list->count * sizeof(encoded_els[0])); if (encoded_els == NULL) { erval.encoded = -1; @@ -473,7 +473,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for (edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; - struct _el_buffer *encoded_el = &encoded_els[eels_count]; + struct el_buffer *encoded_el = &encoded_els[eels_count]; if (!memb_ptr) { @@ -505,7 +505,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, /* * Encode the member into the prepared space. */ - erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, _el_addbytes, + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, el_addbytes, encoded_el); if (erval.encoded == -1) { @@ -523,7 +523,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, /* * Sort the encoded elements according to their encoding. */ - qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); + qsort(encoded_els, eels_count, sizeof(encoded_els[0]), el_buf_cmp); /* * Report encoded elements to the application. @@ -532,7 +532,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, ret = 0; for (edx = 0; edx < eels_count; edx++) { - struct _el_buffer *encoded_el = &encoded_els[edx]; + struct el_buffer *encoded_el = &encoded_els[edx]; /* Report encoded chunks to the application */ if (ret == 0 && cb(encoded_el->buf, encoded_el->length, app_key) < 0) diff --git a/src/core/libs/supl/asn-supl/constr_TYPE.c b/src/core/libs/supl/asn-supl/constr_TYPE.c index 50f349ded..09aa6966d 100644 --- a/src/core/libs/supl/asn-supl/constr_TYPE.c +++ b/src/core/libs/supl/asn-supl/constr_TYPE.c @@ -11,7 +11,7 @@ */ int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; } -static asn_app_consume_bytes_f _print2fp; +static asn_app_consume_bytes_f print2fp; /* * Return the outmost tag of the type. @@ -49,13 +49,13 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) } /* Invoke type-specific printer */ - if (td->print_struct(td, struct_ptr, 1, _print2fp, stream)) + if (td->print_struct(td, struct_ptr, 1, print2fp, stream)) { return -1; } /* Terminate the output */ - if (_print2fp("\n", 1, stream)) + if (print2fp("\n", 1, stream)) { return -1; } @@ -64,7 +64,7 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) } /* Dump the data into the specified stdio stream */ -static int _print2fp(const void *buffer, size_t size, void *app_key) +static int print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; diff --git a/src/core/libs/supl/asn-supl/constraints.c b/src/core/libs/supl/asn-supl/constraints.c index d6d8cc5ec..40ee01d88 100644 --- a/src/core/libs/supl/asn-supl/constraints.c +++ b/src/core/libs/supl/asn-supl/constraints.c @@ -42,7 +42,7 @@ struct errbufDesc size_t errlen; }; -static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, +static void asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, const void *sptr, const char *fmt, ...) { struct errbufDesc *arg = key; @@ -98,7 +98,7 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor, arg.errlen = errlen ? *errlen : 0; ret = type_descriptor->check_constraints(type_descriptor, struct_ptr, - _asn_i_ctfailcb, &arg); + asn_i_ctfailcb, &arg); if (ret == -1 && errlen) { *errlen = arg.errlen; diff --git a/src/core/libs/supl/asn-supl/per_encoder.c b/src/core/libs/supl/asn-supl/per_encoder.c index 23d1dc8cc..d3e6de9ab 100644 --- a/src/core/libs/supl/asn-supl/per_encoder.c +++ b/src/core/libs/supl/asn-supl/per_encoder.c @@ -123,7 +123,7 @@ ssize_t uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, */ /* Flush partially filled buffer */ -static int _uper_encode_flush_outp(asn_per_outp_t *po) +static int uper_encode_flush_outp(asn_per_outp_t *po) { uint8_t *buf; @@ -177,7 +177,7 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, /* Set number of bits encoded to a firm value */ er.encoded = (po.flushed_bytes << 3) + bits_to_flush; - if (_uper_encode_flush_outp(&po)) + if (uper_encode_flush_outp(&po)) { _ASN_ENCODE_FAILED; }