diff --git a/.clang-tidy b/.clang-tidy index 717db7f24..7cd2194b3 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -99,6 +99,7 @@ Checks: '-*, performance-unnecessary-copy-initialization, performance-unnecessary-value-param, readability-avoid-const-params-in-decls, + readability-braces-around-statements, readability-container-size-empty, readability-identifier-naming, readability-inconsistent-declaration-parameter-name, @@ -194,8 +195,6 @@ CheckOptions: value: CamelCase - key: modernize-pass-by-value.IncludeStyle value: llvm - - key: modernize-pass-by-value.ValuesOnly - value: '0' - key: modernize-raw-string-literal.ReplaceShorterLiterals value: '0' - key: modernize-replace-auto-ptr.IncludeStyle @@ -248,6 +247,8 @@ CheckOptions: value: '' - key: performance-unnecessary-value-param.IncludeStyle value: llvm + - key: readability-braces-around-statements.ShortStatementLines + value: '0' - key: readability-identifier-naming.AbstractClassCase value: CamelCase - key: readability-identifier-naming.AbstractClassPrefix diff --git a/src/algorithms/PVT/libs/rtcm.cc b/src/algorithms/PVT/libs/rtcm.cc index f538792b4..e5287c4ca 100644 --- a/src/algorithms/PVT/libs/rtcm.cc +++ b/src/algorithms/PVT/libs/rtcm.cc @@ -3661,28 +3661,28 @@ uint32_t Rtcm::msm_lock_time_indicator(uint32_t lock_time_period_s) uint32_t Rtcm::msm_extended_lock_time_indicator(uint32_t lock_time_period_s) { // Table 3.5-75 - if( lock_time_period_s < 64 ) return ( lock_time_period_s ); - if( 64 <= lock_time_period_s && lock_time_period_s < 128 ) return ( 64 + (lock_time_period_s - 64 ) / 2 ); - if( 128 <= lock_time_period_s && lock_time_period_s < 256 ) return ( 96 + (lock_time_period_s - 128 ) / 4 ); - if( 256 <= lock_time_period_s && lock_time_period_s < 512 ) return (128 + (lock_time_period_s - 256 ) / 8 ); - if( 512 <= lock_time_period_s && lock_time_period_s < 1024 ) return (160 + (lock_time_period_s - 512 ) / 16 ); - if( 1024 <= lock_time_period_s && lock_time_period_s < 2048 ) return (192 + (lock_time_period_s - 1024 ) / 32 ); - if( 2048 <= lock_time_period_s && lock_time_period_s < 4096 ) return (224 + (lock_time_period_s - 2048 ) / 64 ); - if( 4096 <= lock_time_period_s && lock_time_period_s < 8192 ) return (256 + (lock_time_period_s - 4096 ) / 128 ); - if( 8192 <= lock_time_period_s && lock_time_period_s < 16384 ) return (288 + (lock_time_period_s - 8192 ) / 256 ); - if( 16384 <= lock_time_period_s && lock_time_period_s < 32768 ) return (320 + (lock_time_period_s - 16384 ) / 512 ); - if( 32768 <= lock_time_period_s && lock_time_period_s < 65536 ) return (352 + (lock_time_period_s - 32768 ) / 1024 ); - if( 65536 <= lock_time_period_s && lock_time_period_s < 131072 ) return (384 + (lock_time_period_s - 65536 ) / 2048 ); - if( 131072 <= lock_time_period_s && lock_time_period_s < 262144 ) return (416 + (lock_time_period_s - 131072 ) / 4096 ); - if( 262144 <= lock_time_period_s && lock_time_period_s < 524288 ) return (448 + (lock_time_period_s - 262144 ) / 8192 ); - if( 524288 <= lock_time_period_s && lock_time_period_s < 1048576 ) return (480 + (lock_time_period_s - 524288 ) / 16384 ); - if( 1048576 <= lock_time_period_s && lock_time_period_s < 2097152 ) return (512 + (lock_time_period_s - 1048576 ) / 32768 ); - if( 2097152 <= lock_time_period_s && lock_time_period_s < 4194304 ) return (544 + (lock_time_period_s - 2097152 ) / 65536 ); - if( 4194304 <= lock_time_period_s && lock_time_period_s < 8388608 ) return (576 + (lock_time_period_s - 4194304 ) / 131072 ); - if( 8388608 <= lock_time_period_s && lock_time_period_s < 16777216 ) return (608 + (lock_time_period_s - 8388608 ) / 262144 ); - if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 ); - if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576); - if( 67108864 <= lock_time_period_s ) return (704 ); + if( lock_time_period_s < 64 ) return ( lock_time_period_s ); // NOLINT + if( 64 <= lock_time_period_s && lock_time_period_s < 128 ) return ( 64 + (lock_time_period_s - 64 ) / 2 ); // NOLINT + if( 128 <= lock_time_period_s && lock_time_period_s < 256 ) return ( 96 + (lock_time_period_s - 128 ) / 4 ); // NOLINT + if( 256 <= lock_time_period_s && lock_time_period_s < 512 ) return (128 + (lock_time_period_s - 256 ) / 8 ); // NOLINT + if( 512 <= lock_time_period_s && lock_time_period_s < 1024 ) return (160 + (lock_time_period_s - 512 ) / 16 ); // NOLINT + if( 1024 <= lock_time_period_s && lock_time_period_s < 2048 ) return (192 + (lock_time_period_s - 1024 ) / 32 ); // NOLINT + if( 2048 <= lock_time_period_s && lock_time_period_s < 4096 ) return (224 + (lock_time_period_s - 2048 ) / 64 ); // NOLINT + if( 4096 <= lock_time_period_s && lock_time_period_s < 8192 ) return (256 + (lock_time_period_s - 4096 ) / 128 ); // NOLINT + if( 8192 <= lock_time_period_s && lock_time_period_s < 16384 ) return (288 + (lock_time_period_s - 8192 ) / 256 ); // NOLINT + if( 16384 <= lock_time_period_s && lock_time_period_s < 32768 ) return (320 + (lock_time_period_s - 16384 ) / 512 ); // NOLINT + if( 32768 <= lock_time_period_s && lock_time_period_s < 65536 ) return (352 + (lock_time_period_s - 32768 ) / 1024 ); // NOLINT + if( 65536 <= lock_time_period_s && lock_time_period_s < 131072 ) return (384 + (lock_time_period_s - 65536 ) / 2048 ); // NOLINT + if( 131072 <= lock_time_period_s && lock_time_period_s < 262144 ) return (416 + (lock_time_period_s - 131072 ) / 4096 ); // NOLINT + if( 262144 <= lock_time_period_s && lock_time_period_s < 524288 ) return (448 + (lock_time_period_s - 262144 ) / 8192 ); // NOLINT + if( 524288 <= lock_time_period_s && lock_time_period_s < 1048576 ) return (480 + (lock_time_period_s - 524288 ) / 16384 ); // NOLINT + if( 1048576 <= lock_time_period_s && lock_time_period_s < 2097152 ) return (512 + (lock_time_period_s - 1048576 ) / 32768 ); // NOLINT + if( 2097152 <= lock_time_period_s && lock_time_period_s < 4194304 ) return (544 + (lock_time_period_s - 2097152 ) / 65536 ); // NOLINT + if( 4194304 <= lock_time_period_s && lock_time_period_s < 8388608 ) return (576 + (lock_time_period_s - 4194304 ) / 131072 ); // NOLINT + if( 8388608 <= lock_time_period_s && lock_time_period_s < 16777216 ) return (608 + (lock_time_period_s - 8388608 ) / 262144 ); // NOLINT + if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 ); // NOLINT + if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576); // NOLINT + if( 67108864 <= lock_time_period_s ) return (704 ); // NOLINT return 1023; // will never happen } // clang-format on diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 23adf89d6..92055b5ac 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -72,7 +72,10 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( acq_parameters.fs_in = fs_in; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); // could be true in future versions diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 9f5ede948..f331d5d4e 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -69,7 +69,10 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf acq_parameters.fs_in = fs_in; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; acq_pilot_ = configuration_->property(role + ".acquire_pilot", false); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 44f19fae4..4530cb821 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -71,7 +71,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( acq_parameters.fs_in = fs_in; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index a4a01b27e..866bbc498 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -68,7 +68,10 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; unsigned int code_length = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_CPS / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 8b50c1caf..335ae1a66 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -73,7 +73,10 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( acq_parameters.fs_in = fs_in; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; // -- Find number of samples per spreading code ------------------------- diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc index 4e1a7508e..d2e024a30 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc @@ -68,10 +68,16 @@ GpsL2MDllPllTrackingFpga::GpsL2MDllPllTrackingFpga( bool dump_mat = configuration->property(role + ".dump_mat", true); trk_param_fpga.dump_mat = dump_mat; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 2.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param_fpga.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.75); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param_fpga.dll_bw_hz = dll_bw_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param_fpga.early_late_space_chips = early_late_space_chips; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index bbd67ecf5..0462c4eaf 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -1513,7 +1513,10 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { d_worker_is_done = false; boost::mutex::scoped_lock lock(d_mutex); - while (!d_worker_is_done) m_condition.wait(lock); + while (!d_worker_is_done) + { + m_condition.wait(lock); + } // Signal alignment (skip samples until the incoming signal is aligned with local replica) int64_t acq_trk_diff_samples; diff --git a/src/core/libs/supl/asn-rrlp/Accuracy.c b/src/core/libs/supl/asn-rrlp/Accuracy.c index 911b6047d..f60e683a7 100644 --- a/src/core/libs/supl/asn-rrlp/Accuracy.c +++ b/src/core/libs/supl/asn-rrlp/Accuracy.c @@ -48,7 +48,9 @@ static void Accuracy_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/AlertFlag.c b/src/core/libs/supl/asn-rrlp/AlertFlag.c index 66d59832f..a46faa19f 100644 --- a/src/core/libs/supl/asn-rrlp/AlertFlag.c +++ b/src/core/libs/supl/asn-rrlp/AlertFlag.c @@ -48,7 +48,9 @@ static void AlertFlag_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c b/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c index 13f6474ed..cda088880 100644 --- a/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c +++ b/src/core/libs/supl/asn-rrlp/AntiSpoofFlag.c @@ -49,7 +49,9 @@ static void AntiSpoofFlag_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/BCCHCarrier.c b/src/core/libs/supl/asn-rrlp/BCCHCarrier.c index f88d17619..b6b74f8b2 100644 --- a/src/core/libs/supl/asn-rrlp/BCCHCarrier.c +++ b/src/core/libs/supl/asn-rrlp/BCCHCarrier.c @@ -48,7 +48,9 @@ static void BCCHCarrier_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/BIT_STRING.c b/src/core/libs/supl/asn-rrlp/BIT_STRING.c index 6e958c1bf..8120db005 100644 --- a/src/core/libs/supl/asn-rrlp/BIT_STRING.c +++ b/src/core/libs/supl/asn-rrlp/BIT_STRING.c @@ -80,7 +80,10 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, uint8_t *buf; uint8_t *end; - if (!st || !st->buf) _ASN_ENCODE_FAILED; + if (!st || !st->buf) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -99,14 +102,20 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); p = scratch; - if (nline) _i_ASN_TEXT_INDENT(1, ilevel); + if (nline) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } } memcpy(p + 0, _bit_pattern[v >> 4], 4); memcpy(p + 4, _bit_pattern[v & 0x0f], 4); p += 8; } - if (!xcan && ((buf - st->buf) % 8) == 0) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan && ((buf - st->buf) % 8) == 0) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); p = scratch; @@ -116,12 +125,18 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int v = *buf; int ubits = st->bits_unused; int i; - for (i = 7; i >= ubits; i--) *p++ = (v & (1 << i)) ? 0x31 : 0x30; + for (i = 7; i >= ubits; i--) + { + *p++ = (v & (1 << i)) ? 0x31 : 0x30; + } er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -143,7 +158,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, (void)td; /* Unused argument */ - if (!st || !st->buf) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!st || !st->buf) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } ilevel++; buf = st->buf; @@ -158,7 +176,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, { _i_INDENT(1); /* Dump the string */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } p = scratch; } *p++ = h2c[*buf >> 4]; @@ -176,7 +197,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, } /* Dump the incomplete 16-bytes row */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } } return 0; diff --git a/src/core/libs/supl/asn-rrlp/BOOLEAN.c b/src/core/libs/supl/asn-rrlp/BOOLEAN.c index 57ae3ac29..cd7b62f2f 100644 --- a/src/core/libs/supl/asn-rrlp/BOOLEAN.c +++ b/src/core/libs/supl/asn-rrlp/BOOLEAN.c @@ -65,7 +65,10 @@ asn_dec_rval_t BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } ASN_DEBUG("Boolean length is %d bytes", (int)length); @@ -159,7 +162,9 @@ static enum xer_pbd_rval BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, case XCT_UNKNOWN_BO: if (xer_check_tag(chunk_buf, chunk_size, "true") != XCT_BOTH) - return XPBD_BROKEN_ENCODING; + { + return XPBD_BROKEN_ENCODING; + } /* "" */ *st = 1; /* Or 0xff as in DER?.. */ break; @@ -171,9 +176,13 @@ static enum xer_pbd_rval BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, else { if (xer_is_whitespace(chunk_buf, chunk_size)) - return XPBD_NOT_BODY_IGNORE; + { + return XPBD_NOT_BODY_IGNORE; + } else - return XPBD_BROKEN_ENCODING; + { + return XPBD_BROKEN_ENCODING; + } } } @@ -197,7 +206,10 @@ asn_enc_rval_t BOOLEAN_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, (void)ilevel; (void)flags; - if (!st) _ASN_ENCODE_FAILED; + if (!st) + { + _ASN_ENCODE_FAILED; + } if (*st) { @@ -269,7 +281,10 @@ asn_dec_rval_t BOOLEAN_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st))); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } /* @@ -304,7 +319,10 @@ asn_enc_rval_t BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td, (void)constraints; - if (!st) _ASN_ENCODE_FAILED; + if (!st) + { + _ASN_ENCODE_FAILED; + } per_put_few_bits(po, *st ? 1 : 0, 1); diff --git a/src/core/libs/supl/asn-rrlp/BSIC.c b/src/core/libs/supl/asn-rrlp/BSIC.c index 6d84f0c3f..0e084fd6f 100644 --- a/src/core/libs/supl/asn-rrlp/BSIC.c +++ b/src/core/libs/supl/asn-rrlp/BSIC.c @@ -48,7 +48,9 @@ static void BSIC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/BTSPosition.c b/src/core/libs/supl/asn-rrlp/BTSPosition.c index f7369ecde..5891bbd7c 100644 --- a/src/core/libs/supl/asn-rrlp/BTSPosition.c +++ b/src/core/libs/supl/asn-rrlp/BTSPosition.c @@ -50,8 +50,10 @@ static void BTSPosition_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_Ext_GeographicalInformation.uper_decoder; td->uper_encoder = asn_DEF_Ext_GeographicalInformation.uper_encoder; if (!td->per_constraints) - td->per_constraints = - asn_DEF_Ext_GeographicalInformation.per_constraints; + { + td->per_constraints = + asn_DEF_Ext_GeographicalInformation.per_constraints; + } td->elements = asn_DEF_Ext_GeographicalInformation.elements; td->elements_count = asn_DEF_Ext_GeographicalInformation.elements_count; td->specifics = asn_DEF_Ext_GeographicalInformation.specifics; diff --git a/src/core/libs/supl/asn-rrlp/BitNumber.c b/src/core/libs/supl/asn-rrlp/BitNumber.c index 10253e46b..42436e9e1 100644 --- a/src/core/libs/supl/asn-rrlp/BitNumber.c +++ b/src/core/libs/supl/asn-rrlp/BitNumber.c @@ -48,7 +48,9 @@ static void BitNumber_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/CellID.c b/src/core/libs/supl/asn-rrlp/CellID.c index b0e162e75..9971557e8 100644 --- a/src/core/libs/supl/asn-rrlp/CellID.c +++ b/src/core/libs/supl/asn-rrlp/CellID.c @@ -48,7 +48,9 @@ static void CellID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/ENUMERATED.c b/src/core/libs/supl/asn-rrlp/ENUMERATED.c index dd0d13d9b..9f6739534 100644 --- a/src/core/libs/supl/asn-rrlp/ENUMERATED.c +++ b/src/core/libs/supl/asn-rrlp/ENUMERATED.c @@ -49,13 +49,21 @@ asn_dec_rval_t ENUMERATED_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st))); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } rval = NativeEnumerated_decode_uper(opt_codec_ctx, td, constraints, &vptr, pd); if (rval.code == RC_OK) - if (asn_long2INTEGER(st, value)) rval.code = RC_FAIL; + { + if (asn_long2INTEGER(st, value)) + { + rval.code = RC_FAIL; + } + } return rval; } @@ -66,7 +74,10 @@ asn_enc_rval_t ENUMERATED_encode_uper(asn_TYPE_descriptor_t *td, ENUMERATED_t *st = (ENUMERATED_t *)sptr; int64_t value; - if (asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED; + if (asn_INTEGER2long(st, &value)) + { + _ASN_ENCODE_FAILED; + } return NativeEnumerated_encode_uper(td, constraints, &value, po); } diff --git a/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c b/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c index 092656bd2..7d08103e2 100644 --- a/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c +++ b/src/core/libs/supl/asn-rrlp/EnvironmentCharacter.c @@ -31,7 +31,9 @@ static void EnvironmentCharacter_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/ErrorCodes.c b/src/core/libs/supl/asn-rrlp/ErrorCodes.c index 5582fb4af..08628f62c 100644 --- a/src/core/libs/supl/asn-rrlp/ErrorCodes.c +++ b/src/core/libs/supl/asn-rrlp/ErrorCodes.c @@ -29,7 +29,9 @@ static void ErrorCodes_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c b/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c index 617450919..6ebc8ec7d 100644 --- a/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c +++ b/src/core/libs/supl/asn-rrlp/ExpOTDUncertainty.c @@ -50,7 +50,9 @@ static void ExpOTDUncertainty_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/ExpectedOTD.c b/src/core/libs/supl/asn-rrlp/ExpectedOTD.c index 152f976f2..74bb84a1e 100644 --- a/src/core/libs/supl/asn-rrlp/ExpectedOTD.c +++ b/src/core/libs/supl/asn-rrlp/ExpectedOTD.c @@ -48,7 +48,9 @@ static void ExpectedOTD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c b/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c index bb5c9c777..6434b3d7b 100644 --- a/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c +++ b/src/core/libs/supl/asn-rrlp/Ext-GeographicalInformation.c @@ -51,7 +51,9 @@ static void Ext_GeographicalInformation_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder; td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; + { + td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; + } td->elements = asn_DEF_OCTET_STRING.elements; td->elements_count = asn_DEF_OCTET_STRING.elements_count; td->specifics = asn_DEF_OCTET_STRING.specifics; diff --git a/src/core/libs/supl/asn-rrlp/ExtensionContainer.c b/src/core/libs/supl/asn-rrlp/ExtensionContainer.c index 5a58a53c1..24a7cdc96 100644 --- a/src/core/libs/supl/asn-rrlp/ExtensionContainer.c +++ b/src/core/libs/supl/asn-rrlp/ExtensionContainer.c @@ -31,7 +31,9 @@ static void ExtensionContainer_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; + { + td->per_constraints = asn_DEF_INTEGER.per_constraints; + } td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; diff --git a/src/core/libs/supl/asn-rrlp/FineRTD.c b/src/core/libs/supl/asn-rrlp/FineRTD.c index 59b17e338..e75b391cc 100644 --- a/src/core/libs/supl/asn-rrlp/FineRTD.c +++ b/src/core/libs/supl/asn-rrlp/FineRTD.c @@ -48,7 +48,9 @@ static void FineRTD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/FixType.c b/src/core/libs/supl/asn-rrlp/FixType.c index 224e42b5c..745796da8 100644 --- a/src/core/libs/supl/asn-rrlp/FixType.c +++ b/src/core/libs/supl/asn-rrlp/FixType.c @@ -48,7 +48,9 @@ static void FixType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/FrameDrift.c b/src/core/libs/supl/asn-rrlp/FrameDrift.c index 769fce79f..5865f222a 100644 --- a/src/core/libs/supl/asn-rrlp/FrameDrift.c +++ b/src/core/libs/supl/asn-rrlp/FrameDrift.c @@ -48,7 +48,9 @@ static void FrameDrift_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/FrameNumber.c b/src/core/libs/supl/asn-rrlp/FrameNumber.c index 607ac1561..52a70189d 100644 --- a/src/core/libs/supl/asn-rrlp/FrameNumber.c +++ b/src/core/libs/supl/asn-rrlp/FrameNumber.c @@ -48,7 +48,9 @@ static void FrameNumber_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c b/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c index 658e221f8..9dddc7fe8 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c +++ b/src/core/libs/supl/asn-rrlp/GANSSAssistanceData.c @@ -51,7 +51,9 @@ static void GANSSAssistanceData_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder; td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; + { + td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; + } td->elements = asn_DEF_OCTET_STRING.elements; td->elements_count = asn_DEF_OCTET_STRING.elements_count; td->specifics = asn_DEF_OCTET_STRING.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSDataBit.c b/src/core/libs/supl/asn-rrlp/GANSSDataBit.c index 4fc0e9ad6..aeff68299 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSDataBit.c +++ b/src/core/libs/supl/asn-rrlp/GANSSDataBit.c @@ -49,7 +49,9 @@ static void GANSSDataBit_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c b/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c index 61a957486..36ac9ad49 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c +++ b/src/core/libs/supl/asn-rrlp/GANSSPositioningMethod.c @@ -60,7 +60,9 @@ static void GANSSPositioningMethod_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSSignalID.c b/src/core/libs/supl/asn-rrlp/GANSSSignalID.c index a9510f718..3db69a92a 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSSignalID.c +++ b/src/core/libs/supl/asn-rrlp/GANSSSignalID.c @@ -49,7 +49,9 @@ static void GANSSSignalID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTOD.c b/src/core/libs/supl/asn-rrlp/GANSSTOD.c index b6a69783c..bae8a4ad0 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTOD.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTOD.c @@ -48,7 +48,9 @@ static void GANSSTOD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c b/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c index f8fe5902c..ae7e12471 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTODUncertainty.c @@ -50,7 +50,9 @@ static void GANSSTODUncertainty_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GANSSTODm.c b/src/core/libs/supl/asn-rrlp/GANSSTODm.c index 1cc425018..0020f72d1 100644 --- a/src/core/libs/supl/asn-rrlp/GANSSTODm.c +++ b/src/core/libs/supl/asn-rrlp/GANSSTODm.c @@ -48,7 +48,9 @@ static void GANSSTODm_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c b/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c index bc085b311..9d5e82ea3 100644 --- a/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c +++ b/src/core/libs/supl/asn-rrlp/GPSAssistanceData.c @@ -51,7 +51,9 @@ static void GPSAssistanceData_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder; td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; + { + td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; + } td->elements = asn_DEF_OCTET_STRING.elements; td->elements_count = asn_DEF_OCTET_STRING.elements_count; td->specifics = asn_DEF_OCTET_STRING.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c b/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c index 6eba8005f..0aa2ab1bb 100644 --- a/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c +++ b/src/core/libs/supl/asn-rrlp/GPSReferenceTimeUncertainty.c @@ -50,7 +50,9 @@ static void GPSReferenceTimeUncertainty_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GPSTOW23b.c b/src/core/libs/supl/asn-rrlp/GPSTOW23b.c index ba573ffa1..4cb4e02e5 100644 --- a/src/core/libs/supl/asn-rrlp/GPSTOW23b.c +++ b/src/core/libs/supl/asn-rrlp/GPSTOW23b.c @@ -48,7 +48,9 @@ static void GPSTOW23b_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GPSTOW24b.c b/src/core/libs/supl/asn-rrlp/GPSTOW24b.c index 28a1fe9f6..40d189e7f 100644 --- a/src/core/libs/supl/asn-rrlp/GPSTOW24b.c +++ b/src/core/libs/supl/asn-rrlp/GPSTOW24b.c @@ -48,7 +48,9 @@ static void GPSTOW24b_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/GPSWeek.c b/src/core/libs/supl/asn-rrlp/GPSWeek.c index 5247934d2..a0511f57f 100644 --- a/src/core/libs/supl/asn-rrlp/GPSWeek.c +++ b/src/core/libs/supl/asn-rrlp/GPSWeek.c @@ -48,7 +48,9 @@ static void GPSWeek_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/INTEGER.c b/src/core/libs/supl/asn-rrlp/INTEGER.c index a6ba53d1a..3e98024a9 100644 --- a/src/core/libs/supl/asn-rrlp/INTEGER.c +++ b/src/core/libs/supl/asn-rrlp/INTEGER.c @@ -72,10 +72,16 @@ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr, switch (*buf) { case 0x00: - if ((buf[1] & 0x80) == 0) continue; + if ((buf[1] & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((buf[1] & 0x80)) continue; + if ((buf[1] & 0x80)) + { + continue; + } break; } break; @@ -91,7 +97,10 @@ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr, st->size -= shift; /* New size, minus bad bytes */ end = nb + st->size; - for (; nb < end; nb++, buf++) *nb = *buf; + for (; nb < end; nb++, buf++) + { + *nb = *buf; + } } } /* if(1) */ @@ -130,10 +139,16 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, switch (*buf) { case 0x00: - if ((buf[1] & 0x80) == 0) continue; + if ((buf[1] & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((buf[1] & 0x80) != 0) continue; + if ((buf[1] & 0x80) != 0) + { + continue; + } break; } break; @@ -153,7 +168,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, else { accum = (*buf & 0x80) ? -1LL : 0LL; - for (; buf < buf_end; buf++) accum = (accum * 256) | *buf; + for (; buf < buf_end; buf++) + { + accum = (accum * 256) | *buf; + } } el = INTEGER_map_value2enum(specs, accum); @@ -162,10 +180,14 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, scrsize = el->enum_len + 32; scr = (char *)alloca(scrsize); if (plainOrXER == 0) - ret = snprintf(scr, scrsize, "%+" PRId64 "(%s)", accum, - el->enum_name); + { + ret = snprintf(scr, scrsize, "%+" PRId64 "(%s)", accum, + el->enum_name); + } else - ret = snprintf(scr, scrsize, "<%s/>", el->enum_name); + { + ret = snprintf(scr, scrsize, "<%s/>", el->enum_name); + } } else if (plainOrXER && specs && specs->strict_enumeration) { @@ -209,7 +231,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, if ((p - scratch) >= (ssize_t)(sizeof(scratch) - 4)) { /* Flush buffer */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } wrote += p - scratch; p = scratch; } @@ -217,7 +242,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, *p++ = h2c[*buf & 0x0F]; *p++ = 0x3a; /* ":" */ } - if (p != scratch) p--; /* Remove the last ":" */ + if (p != scratch) + { + p--; /* Remove the last ":" */ + } wrote += p - scratch; return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote; @@ -236,9 +264,13 @@ int INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, (void)ilevel; if (!st || !st->buf) - ret = cb("", 8, app_key); + { + ret = cb("", 8, app_key); + } else - ret = INTEGER__dump(td, st, cb, app_key, 0); + { + ret = INTEGER__dump(td, st, cb, app_key, 0); + } return (ret < 0) ? -1 : 0; } @@ -266,8 +298,10 @@ static int INTEGER__compar_enum2value(const void *kp, const void *am) ptr++, name++) { if (*ptr != *name) - return *(const unsigned char *)ptr - - *(const unsigned char *)name; + { + return *(const unsigned char *)ptr - + *(const unsigned char *)name; + } } return name[0] ? -1 : 0; } @@ -280,7 +314,10 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value( struct e2v_key key; const char *lp; - if (!count) return NULL; + if (!count) + { + return NULL; + } /* Guaranteed: assert(lstart < lstop); */ /* Figure out the tag name */ @@ -302,7 +339,10 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value( } break; } - if (lp == lstop) return NULL; /* No tag found */ + if (lp == lstop) + { + return NULL; /* No tag found */ + } lstop = lp; key.start = lstart; @@ -326,18 +366,27 @@ static int INTEGER__compar_value2enum(const void *kp, const void *am) const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am; int64_t b = el->nat_value; if (a < b) - return -1; + { + return -1; + } else if (a == b) - return 0; + { + return 0; + } else - return 1; + { + return 1; + } } const asn_INTEGER_enum_map_t *INTEGER_map_value2enum( asn_INTEGER_specifics_t *specs, int64_t value) { int count = specs ? specs->map_count : 0; - if (!count) return 0; + if (!count) + { + return 0; + } return (asn_INTEGER_enum_map_t *)bsearch(&value, specs->value2enum, count, sizeof(specs->value2enum[0]), INTEGER__compar_value2enum); @@ -387,8 +436,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, } state = ST_SKIPSPACE; if (chunk_size) - ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (int64_t)chunk_size, *lstart, - lstop[-1]); + { + ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (int64_t)chunk_size, *lstart, + lstop[-1]); + } /* * We may have received a tag here. It will be processed inline. @@ -468,8 +519,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, { int64_t new_value = value * 10; - if (new_value / 10 != value) /* Overflow */ - return XPBD_DECODER_LIMIT; + if (new_value / 10 != value) + { /* Overflow */ + return XPBD_DECODER_LIMIT; + } value = new_value + (lv - 0x30); /* Check for two's complement overflow */ @@ -524,7 +577,9 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, ASN_DEBUG("INTEGER re-evaluate as hex form"); if (INTEGER_st_prealloc(st, (chunk_size / 3) + 1)) - return XPBD_SYSTEM_FAILURE; + { + return XPBD_SYSTEM_FAILURE; + } state = ST_SKIPSPHEX; lp = lstart - 1; continue; @@ -568,7 +623,9 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, "INTEGER re-evaluate as hex form"); if (INTEGER_st_prealloc( st, (chunk_size / 3) + 1)) - return XPBD_SYSTEM_FAILURE; + { + return XPBD_SYSTEM_FAILURE; + } state = ST_SKIPSPHEX; lp = lstart - 1; continue; @@ -599,7 +656,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, default: if (xer_is_whitespace(lp, lstop - lp)) { - if (state != ST_EXTRASTUFF) return XPBD_NOT_BODY_IGNORE; + if (state != ST_EXTRASTUFF) + { + return XPBD_NOT_BODY_IGNORE; + } break; } else @@ -613,7 +673,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, value *= sign; /* Change sign, if needed */ - if (asn_long2INTEGER(st, value)) return XPBD_SYSTEM_FAILURE; + if (asn_long2INTEGER(st, value)) + { + return XPBD_SYSTEM_FAILURE; + } return XPBD_BODY_CONSUMED; } @@ -638,10 +701,16 @@ asn_enc_rval_t INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, (void)ilevel; (void)flags; - if (!st || !st->buf) _ASN_ENCODE_FAILED; + if (!st || !st->buf) + { + _ASN_ENCODE_FAILED; + } er.encoded = INTEGER__dump(td, st, cb, app_key, 1); - if (er.encoded < 0) _ASN_ENCODE_FAILED; + if (er.encoded < 0) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -662,17 +731,29 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st))); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } - if (!constraints) constraints = td->per_constraints; + if (!constraints) + { + constraints = td->per_constraints; + } ct = constraints ? &constraints->value : 0; if (ct && ct->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); - if (inext < 0) _ASN_DECODE_STARVED; - if (inext) ct = 0; + if (inext < 0) + { + _ASN_DECODE_STARVED; + } + if (inext) + { + ct = 0; + } } FREEMEM(st->buf); @@ -683,14 +764,20 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (ct->flags & APC_SEMI_CONSTRAINED) { st->buf = (uint8_t *)CALLOC(1, 2); - if (!st->buf) _ASN_DECODE_FAILED; + if (!st->buf) + { + _ASN_DECODE_FAILED; + } st->size = 1; } else if (ct->flags & APC_CONSTRAINED && ct->range_bits >= 0) { size_t size = (ct->range_bits + 7) >> 3; st->buf = (uint8_t *)MALLOC(1 + size + 1); - if (!st->buf) _ASN_DECODE_FAILED; + if (!st->buf) + { + _ASN_DECODE_FAILED; + } st->size = size; } } @@ -707,15 +794,24 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, { int64_t lhalf; value = per_get_few_bits(pd, 16); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } lhalf = per_get_few_bits(pd, 16); - if (lhalf < 0) _ASN_DECODE_STARVED; + if (lhalf < 0) + { + _ASN_DECODE_STARVED; + } value = (value << 16) | lhalf; } else { value = per_get_few_bits(pd, ct->range_bits); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } } ASN_DEBUG("Got value %ld + low %ld", value, ct->lower_bound); @@ -723,7 +819,9 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(st, value) : asn_long2INTEGER(st, value)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } return rval; } } @@ -741,14 +839,23 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, /* Get the PER length */ len = uper_get_length(pd, -1, &repeat); - if (len < 0) _ASN_DECODE_STARVED; + if (len < 0) + { + _ASN_DECODE_STARVED; + } p = REALLOC(st->buf, st->size + len + 1); - if (!p) _ASN_DECODE_FAILED; + if (!p) + { + _ASN_DECODE_FAILED; + } st->buf = (uint8_t *)p; ret = per_get_many_bits(pd, &st->buf[st->size], 0, 8 * len); - if (ret < 0) _ASN_DECODE_STARVED; + if (ret < 0) + { + _ASN_DECODE_STARVED; + } st->size += len; } while (repeat); @@ -761,9 +868,14 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, * TODO: replace by in-place arithmetics. */ int64_t value; - if (asn_INTEGER2long(st, &value)) _ASN_DECODE_FAILED; + if (asn_INTEGER2long(st, &value)) + { + _ASN_DECODE_FAILED; + } if (asn_long2INTEGER(st, value + ct->lower_bound)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } } return rval; @@ -781,9 +893,15 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraint_t *ct; int64_t value = 0; - if (!st || st->size == 0) _ASN_ENCODE_FAILED; + if (!st || st->size == 0) + { + _ASN_ENCODE_FAILED; + } - if (!constraints) constraints = td->per_constraints; + if (!constraints) + { + constraints = td->per_constraints; + } ct = constraints ? &constraints->value : 0; er.encoded = 0; @@ -794,17 +912,25 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, if (specs && specs->field_unsigned) { uint64_t uval; - if (asn_INTEGER2ulong(st, &uval)) _ASN_ENCODE_FAILED; + if (asn_INTEGER2ulong(st, &uval)) + { + _ASN_ENCODE_FAILED; + } /* Check proper range */ if (ct->flags & APC_SEMI_CONSTRAINED) { - if (uval < (uint64_t)ct->lower_bound) inext = 1; + if (uval < (uint64_t)ct->lower_bound) + { + inext = 1; + } } else if (ct->range_bits >= 0) { if (uval < (uint64_t)ct->lower_bound || uval > (uint64_t)ct->upper_bound) - inext = 1; + { + inext = 1; + } } ASN_DEBUG("Value %lu (%02x/%d) lb %lu ub %lu %s", uval, st->buf[0], st->size, ct->lower_bound, @@ -813,17 +939,25 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, } else { - if (asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED; + if (asn_INTEGER2long(st, &value)) + { + _ASN_ENCODE_FAILED; + } /* Check proper range */ if (ct->flags & APC_SEMI_CONSTRAINED) { - if (value < ct->lower_bound) inext = 1; + if (value < ct->lower_bound) + { + inext = 1; + } } else if (ct->range_bits >= 0) { if (value < ct->lower_bound || value > ct->upper_bound) - inext = 1; + { + inext = 1; + } } ASN_DEBUG("Value %ld (%02x/%d) lb %ld ub %ld %s", value, st->buf[0], st->size, ct->lower_bound, @@ -831,8 +965,14 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, } if (ct->flags & APC_EXTENSIBLE) { - if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; - if (inext) ct = 0; + if (per_put_few_bits(po, inext, 1)) + { + _ASN_ENCODE_FAILED; + } + if (inext) + { + ct = 0; + } } else if (inext) { @@ -851,13 +991,17 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, int64_t v = value - ct->lower_bound; if (per_put_few_bits(po, v >> 1, 31) || per_put_few_bits(po, v, 1)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } else { if (per_put_few_bits(po, value - ct->lower_bound, ct->range_bits)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } _ASN_ENCODED_OK(er); } @@ -872,8 +1016,14 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, for (buf = st->buf, end = st->buf + st->size; buf < end;) { ssize_t mayEncode = uper_put_length(po, end - buf); - if (mayEncode < 0) _ASN_ENCODE_FAILED; - if (per_put_many_bits(po, buf, 8 * mayEncode)) _ASN_ENCODE_FAILED; + if (mayEncode < 0) + { + _ASN_ENCODE_FAILED; + } + if (per_put_many_bits(po, buf, 8 * mayEncode)) + { + _ASN_ENCODE_FAILED; + } buf += mayEncode; } @@ -914,10 +1064,16 @@ int asn_INTEGER2long(const INTEGER_t *iptr, int64_t *lptr) switch (*b) { case 0x00: - if ((b[1] & 0x80) == 0) continue; + if ((b[1] & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((b[1] & 0x80) != 0) continue; + if ((b[1] & 0x80) != 0) + { + continue; + } break; } break; @@ -942,12 +1098,19 @@ int asn_INTEGER2long(const INTEGER_t *iptr, int64_t *lptr) /* Perform the sign initialization */ /* Actually l = -(*b >> 7); gains nothing, yet unreadable! */ if ((*b >> 7)) - l = -1; + { + l = -1; + } else - l = 0; + { + l = 0; + } /* Conversion engine */ - for (; b < end; b++) l = (l * 256) | *b; + for (; b < end; b++) + { + l = (l * 256) | *b; + } *lptr = l; return 0; @@ -982,7 +1145,10 @@ int asn_INTEGER2ulong(const INTEGER_t *iptr, uint64_t *lptr) } /* Conversion engine */ - for (l = 0; b < end; b++) l = (l << 8) | *b; + for (l = 0; b < end; b++) + { + l = (l << 8) | *b; + } *lptr = l; return 0; @@ -995,17 +1161,28 @@ int asn_ulong2INTEGER(INTEGER_t *st, uint64_t value) uint8_t *b; int shr; - if (value <= LONG_MAX) return asn_long2INTEGER(st, value); + if (value <= LONG_MAX) + { + return asn_long2INTEGER(st, value); + } buf = (uint8_t *)MALLOC(1 + sizeof(value)); - if (!buf) return -1; + if (!buf) + { + return -1; + } end = buf + (sizeof(value) + 1); buf[0] = 0; for (b = buf + 1, shr = (sizeof(int64_t) - 1) * 8; b < end; shr -= 8, b++) - *b = (uint8_t)(value >> shr); + { + *b = (uint8_t)(value >> shr); + } - if (st->buf) FREEMEM(st->buf); + if (st->buf) + { + FREEMEM(st->buf); + } st->buf = buf; st->size = 1 + sizeof(value); @@ -1029,7 +1206,10 @@ int asn_long2INTEGER(INTEGER_t *st, int64_t value) } buf = (uint8_t *)MALLOC(8); - if (!buf) return -1; + if (!buf) + { + return -1; + } if (*(char *)&littleEndian) { @@ -1055,18 +1235,30 @@ int asn_long2INTEGER(INTEGER_t *st, int64_t value) switch (*p) { case 0x00: - if ((*(p + add) & 0x80) == 0) continue; + if ((*(p + add) & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((*(p + add) & 0x80)) continue; + if ((*(p + add) & 0x80)) + { + continue; + } break; } break; } /* Copy the integer body */ - for (pstart = p, bp = buf, pend1 += add; p != pend1; p += add) *bp++ = *p; + for (pstart = p, bp = buf, pend1 += add; p != pend1; p += add) + { + *bp++ = *p; + } - if (st->buf) FREEMEM(st->buf); + if (st->buf) + { + FREEMEM(st->buf); + } st->buf = buf; st->size = bp - buf; diff --git a/src/core/libs/supl/asn-rrlp/LAC.c b/src/core/libs/supl/asn-rrlp/LAC.c index c72a1d4ce..ae2e084df 100644 --- a/src/core/libs/supl/asn-rrlp/LAC.c +++ b/src/core/libs/supl/asn-rrlp/LAC.c @@ -48,7 +48,9 @@ static void LAC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/LocErrorReason.c b/src/core/libs/supl/asn-rrlp/LocErrorReason.c index 88a257184..718a2616e 100644 --- a/src/core/libs/supl/asn-rrlp/LocErrorReason.c +++ b/src/core/libs/supl/asn-rrlp/LocErrorReason.c @@ -30,7 +30,9 @@ static void LocErrorReason_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c b/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c index 1baaf7db4..0c96f1753 100644 --- a/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c +++ b/src/core/libs/supl/asn-rrlp/MeasureResponseTime.c @@ -50,7 +50,9 @@ static void MeasureResponseTime_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c b/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c index feab85dd1..9d20bbf79 100644 --- a/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c +++ b/src/core/libs/supl/asn-rrlp/ModuloTimeSlot.c @@ -49,7 +49,9 @@ static void ModuloTimeSlot_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c b/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c index 30b1235c3..bbb09e49e 100644 --- a/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c +++ b/src/core/libs/supl/asn-rrlp/MoreAssDataToBeSent.c @@ -31,7 +31,9 @@ static void MoreAssDataToBeSent_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/MpathIndic.c b/src/core/libs/supl/asn-rrlp/MpathIndic.c index 73119ea00..dd7577031 100644 --- a/src/core/libs/supl/asn-rrlp/MpathIndic.c +++ b/src/core/libs/supl/asn-rrlp/MpathIndic.c @@ -29,7 +29,9 @@ static void MpathIndic_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c b/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c index 27c8d0362..7c5df0cab 100644 --- a/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c +++ b/src/core/libs/supl/asn-rrlp/MultiFrameOffset.c @@ -50,7 +50,9 @@ static void MultiFrameOffset_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/NULL.c b/src/core/libs/supl/asn-rrlp/NULL.c index 6842d0e8f..892094dd0 100644 --- a/src/core/libs/supl/asn-rrlp/NULL.c +++ b/src/core/libs/supl/asn-rrlp/NULL.c @@ -78,9 +78,13 @@ static enum xer_pbd_rval NULL__xer_body_decode(asn_TYPE_descriptor_t *td, (void)sptr; if (xer_is_whitespace(chunk_buf, chunk_size)) - return XPBD_BODY_CONSUMED; + { + return XPBD_BODY_CONSUMED; + } else - return XPBD_BROKEN_ENCODING; + { + return XPBD_BROKEN_ENCODING; + } } asn_dec_rval_t NULL_decode_xer(asn_codec_ctx_t *opt_codec_ctx, diff --git a/src/core/libs/supl/asn-rrlp/NativeEnumerated.c b/src/core/libs/supl/asn-rrlp/NativeEnumerated.c index 1f6394e52..a673a7858 100644 --- a/src/core/libs/supl/asn-rrlp/NativeEnumerated.c +++ b/src/core/libs/supl/asn-rrlp/NativeEnumerated.c @@ -56,7 +56,10 @@ asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, (void)ilevel; (void)flags; - if (!native) _ASN_ENCODE_FAILED; + if (!native) + { + _ASN_ENCODE_FAILED; + } el = INTEGER_map_value2enum(specs, *native); if (el) @@ -66,7 +69,10 @@ asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name); assert(er.encoded > 0 && (size_t)er.encoded < srcsize); - if (cb(src, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED; + if (cb(src, er.encoded, app_key) < 0) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } else @@ -92,17 +98,29 @@ asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx, (void)opt_codec_ctx; if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - _ASN_DECODE_FAILED; /* Mandatory! */ - if (!specs) _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; /* Mandatory! */ + } + if (!specs) + { + _ASN_DECODE_FAILED; + } if (!native) { native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if (!native) _ASN_DECODE_FAILED; + if (!native) + { + _ASN_DECODE_FAILED; + } } ASN_DEBUG("Decoding %s as NativeEnumerated", td->name); @@ -110,28 +128,48 @@ asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (ct->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); - if (inext < 0) _ASN_DECODE_STARVED; - if (inext) ct = 0; + if (inext < 0) + { + _ASN_DECODE_STARVED; + } + if (inext) + { + ct = 0; + } } if (ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } if (value >= (specs->extension ? specs->extension - 1 : specs->map_count)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } } else { - if (!specs->extension) _ASN_DECODE_FAILED; + if (!specs->extension) + { + _ASN_DECODE_FAILED; + } /* * X.691, #10.6: normally small non-negative whole number; */ value = uper_get_nsnnwn(pd); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } value += specs->extension - 1; - if (value >= specs->map_count) _ASN_DECODE_FAILED; + if (value >= specs->map_count) + { + _ASN_DECODE_FAILED; + } } *native = specs->value2enum[value].nat_value; @@ -144,8 +182,14 @@ static int NativeEnumerated__compar_value2enum(const void *ap, const void *bp) { const asn_INTEGER_enum_map_t *a = ap; const asn_INTEGER_enum_map_t *b = bp; - if (a->nat_value == b->nat_value) return 0; - if (a->nat_value < b->nat_value) return -1; + if (a->nat_value == b->nat_value) + { + return 0; + } + if (a->nat_value < b->nat_value) + { + return -1; + } return 1; } @@ -162,22 +206,37 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, asn_INTEGER_enum_map_t key; asn_INTEGER_enum_map_t *kf; - if (!sptr) _ASN_ENCODE_FAILED; - if (!specs) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } + if (!specs) + { + _ASN_ENCODE_FAILED; + } if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - _ASN_ENCODE_FAILED; /* Mandatory! */ + { + _ASN_ENCODE_FAILED; /* Mandatory! */ + } ASN_DEBUG("Encoding %s as NativeEnumerated", td->name); er.encoded = 0; native = *(long *)sptr; - if (native < 0) _ASN_ENCODE_FAILED; + if (native < 0) + { + _ASN_ENCODE_FAILED; + } key.nat_value = native; kf = bsearch(&key, specs->value2enum, specs->map_count, sizeof(key), @@ -193,12 +252,21 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, { int cmpWith = specs->extension ? specs->extension - 1 : specs->map_count; - if (value >= cmpWith) inext = 1; + if (value >= cmpWith) + { + inext = 1; + } } if (ct->flags & APC_EXTENSIBLE) { - if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; - if (inext) ct = 0; + if (per_put_few_bits(po, inext, 1)) + { + _ASN_ENCODE_FAILED; + } + if (inext) + { + ct = 0; + } } else if (inext) { @@ -207,11 +275,17 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, if (ct && ct->range_bits >= 0) { - if (per_put_few_bits(po, value, ct->range_bits)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, value, ct->range_bits)) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } - if (!specs->extension) _ASN_ENCODE_FAILED; + if (!specs->extension) + { + _ASN_ENCODE_FAILED; + } /* * X.691, #10.6: normally small non-negative whole number; @@ -220,7 +294,9 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, specs->extension, inext, value - (inext ? (specs->extension - 1) : 0)); if (uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0))) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } diff --git a/src/core/libs/supl/asn-rrlp/NativeInteger.c b/src/core/libs/supl/asn-rrlp/NativeInteger.c index 53895a7bb..4221884ca 100644 --- a/src/core/libs/supl/asn-rrlp/NativeInteger.c +++ b/src/core/libs/supl/asn-rrlp/NativeInteger.c @@ -75,7 +75,10 @@ asn_dec_rval_t NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } ASN_DEBUG("%s length is %d bytes", td->name, (int)length); @@ -153,7 +156,9 @@ asn_enc_rval_t NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, /* Prepare a fake INTEGER */ for (p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) - *p = (uint8_t)native; + { + *p = (uint8_t)native; + } tmp.buf = buf; tmp.size = sizeof(buf); @@ -186,7 +191,10 @@ asn_dec_rval_t NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (!native) { native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if (!native) _ASN_DECODE_FAILED; + if (!native) + { + _ASN_DECODE_FAILED; + } } memset(&st, 0, sizeof(st)); @@ -234,14 +242,19 @@ asn_enc_rval_t NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, (void)ilevel; (void)flags; - if (!native) _ASN_ENCODE_FAILED; + if (!native) + { + _ASN_ENCODE_FAILED; + } er.encoded = snprintf(scratch, sizeof(scratch), (specs && specs->field_unsigned) ? "%lu" : "%ld", *native); if (er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) || cb(scratch, er.encoded, app_key) < 0) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -263,7 +276,10 @@ asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!native) { native = (int64_t *)(*sptr = CALLOC(1, sizeof(*native))); - if (!native) _ASN_DECODE_FAILED; + if (!native) + { + _ASN_DECODE_FAILED; + } } memset(&tmpint, 0, sizeof tmpint); @@ -273,9 +289,13 @@ asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if ((specs && specs->field_unsigned) ? asn_INTEGER2ulong(&tmpint, (uint64_t *)native) : asn_INTEGER2long(&tmpint, native)) - rval.code = RC_FAIL; + { + rval.code = RC_FAIL; + } else - ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native); + { + ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native); + } } ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); @@ -291,7 +311,10 @@ asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, long native; INTEGER_t tmpint; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } native = *(long *)sptr; @@ -300,7 +323,9 @@ asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, memset(&tmpint, 0, sizeof(tmpint)); if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native) : asn_long2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } er = INTEGER_encode_uper(td, constraints, &tmpint, po); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); return er; @@ -336,7 +361,10 @@ int NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, void NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - if (!td || !ptr) return; + if (!td || !ptr) + { + return; + } ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", td->name, contents_only, ptr); diff --git a/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c b/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c index 442e3c843..8cc343a51 100644 --- a/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c +++ b/src/core/libs/supl/asn-rrlp/NumOfMeasurements.c @@ -50,7 +50,9 @@ static void NumOfMeasurements_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/OCTET_STRING.c b/src/core/libs/supl/asn-rrlp/OCTET_STRING.c index b092caadf..000c043a7 100644 --- a/src/core/libs/supl/asn-rrlp/OCTET_STRING.c +++ b/src/core/libs/supl/asn-rrlp/OCTET_STRING.c @@ -156,7 +156,10 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st) else { nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el)); - if (nel == NULL) return NULL; + if (nel == NULL) + { + return NULL; + } if (st->tail) { @@ -209,7 +212,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (st == NULL) { st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); - if (st == NULL) RETURN(RC_FAIL); + if (st == NULL) + { + RETURN(RC_FAIL); + } } /* Restore parsing context */ @@ -223,7 +229,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, ctx, buf_ptr, size, tag_mode, -1, &ctx->left, &tlv_constr); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } if (tlv_constr) { @@ -247,7 +256,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ _CH_PHASE(ctx, 3); if (type_variant == ASN_OSUBV_ANY && tag_mode != 1) - APPEND(buf_ptr, rval.consumed); + { + APPEND(buf_ptr, rval.consumed); + } ADVANCE(rval.consumed); goto phase3; } @@ -286,12 +297,17 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (prev->left != -1) { if (prev->left < sel->got) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } prev->left -= sel->got; } prev->got += sel->got; sel = stck->cur_ptr = prev; - if (!sel) break; + if (!sel) + { + break; + } tlv_constr = 1; continue; } @@ -344,7 +360,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (type_variant == ASN_OSUBV_ANY && (tag_mode != 1 || sel->cont_level)) - APPEND("\0\0", 2); + { + APPEND("\0\0", 2); + } ADVANCE(2); sel->got += 2; @@ -430,7 +448,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, * Append a new expectation. */ sel = OS__add_stack_el(stck); - if (!sel) RETURN(RC_FAIL); + if (!sel) + { + RETURN(RC_FAIL); + } sel->tag = tlv_tag; @@ -440,11 +461,17 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* Check that the parent frame is big enough */ if (sel->prev->left < tlvl + (tlv_len == -1 ? 0 : tlv_len)) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } if (tlv_len == -1) - sel->left = sel->prev->left - tlvl; + { + sel->left = sel->prev->left - tlvl; + } else - sel->left = tlv_len; + { + sel->left = tlv_len; + } } else { @@ -452,7 +479,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if (type_variant == ASN_OSUBV_ANY && (tag_mode != 1 || sel->cont_level)) - APPEND(buf_ptr, tlvl); + { + APPEND(buf_ptr, tlvl); + } sel->got += tlvl; ADVANCE(tlvl); @@ -526,7 +555,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (size < (size_t)ctx->left) { - if (!size) RETURN(RC_WMORE); + if (!size) + { + RETURN(RC_WMORE); + } if (type_variant == ASN_OSUBV_BIT && !ctx->context) { st->bits_unused = *(const uint8_t *)buf_ptr; @@ -638,7 +670,10 @@ asn_enc_rval_t OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr, if (type_variant == ASN_OSUBV_BIT) { uint8_t b = st->bits_unused & 0x07; - if (b && st->size) fix_last_byte = 1; + if (b && st->size) + { + fix_last_byte = 1; + } _ASN_CALLBACK(&b, 1); er.encoded++; } @@ -674,7 +709,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, uint8_t *end; size_t i; - if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; + if (!st || (!st->buf && st->size)) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -721,7 +759,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, p--; /* Remove the tail space */ _ASN_CALLBACK(scratch, p - scratch); /* Dump the rest */ er.encoded += p - scratch; - if (st->size > 16) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (st->size > 16) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } } } @@ -818,7 +859,9 @@ static int OS__check_escaped_control_char(const void *buf, int size) struct OCTET_STRING__xer_escape_table_s *el; el = &OCTET_STRING__xer_escape_table[i]; if (el->size == size && memcmp(buf, el->string, size) == 0) - return i; + { + return i; + } } return -1; } @@ -865,7 +908,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, (void)ilevel; /* Unused argument */ (void)flags; /* Unused argument */ - if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; + if (!st || (!st->buf && st->size)) + { + _ASN_ENCODE_FAILED; + } buf = st->buf; end = buf + st->size; @@ -884,14 +930,19 @@ asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, if (((buf - ss) && cb(ss, buf - ss, app_key) < 0) || cb(OCTET_STRING__xer_escape_table[ch].string, s_len, app_key) < 0) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } encoded_len += (buf - ss) + s_len; ss = buf + 1; } } encoded_len += (buf - ss); - if ((buf - ss) && cb(ss, buf - ss, app_key) < 0) _ASN_ENCODE_FAILED; + if ((buf - ss) && cb(ss, buf - ss, app_key) < 0) + { + _ASN_ENCODE_FAILED; + } er.encoded = encoded_len; _ASN_ENCODED_OK(er); @@ -916,7 +967,10 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, /* Reallocate buffer according to high cap estimation */ ssize_t _ns = st->size + (chunk_size + 1) / 2; void *nptr = REALLOC(st->buf, _ns + 1); - if (!nptr) return -1; + if (!nptr) + { + return -1; + } st->buf = (uint8_t *)nptr; buf = st->buf + st->size; @@ -1019,16 +1073,23 @@ static ssize_t OCTET_STRING__convert_binary(void *sptr, const void *chunk_buf, /* Reallocate buffer according to high cap estimation */ ssize_t _ns = st->size + (chunk_size + 7) / 8; void *nptr = REALLOC(st->buf, _ns + 1); - if (!nptr) return -1; + if (!nptr) + { + return -1; + } st->buf = (uint8_t *)nptr; buf = st->buf + st->size; (void)have_more; if (bits_unused == 0) - bits_unused = 8; + { + bits_unused = 8; + } else if (st->size) - buf--; + { + buf--; + } /* * Convert series of 0 and 1 into the octet string. @@ -1091,7 +1152,10 @@ static int OS__strtoent(int base, const char *buf, const char *end, int ch = *p; /* Strange huge value */ - if ((val * base + base) < 0) return -1; + if ((val * base + base) < 0) + { + return -1; + } switch (ch) { @@ -1149,7 +1213,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, /* Reallocate buffer */ ssize_t _ns = st->size + chunk_size; void *nptr = REALLOC(st->buf, _ns + 1); - if (!nptr) return -1; + if (!nptr) + { + return -1; + } st->buf = (uint8_t *)nptr; buf = st->buf + st->size; @@ -1171,18 +1238,28 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, * Process entity reference. */ len = chunk_size - (p - (const char *)chunk_buf); - if (len == 1 /* "&" */) goto want_more; + if (len == 1 /* "&" */) + { + goto want_more; + } if (p[1] == 0x23 /* '#' */) { const char *pval; /* Pointer to start of digits */ int32_t val = 0; /* Entity reference value */ int base; - if (len == 2 /* "&#" */) goto want_more; + if (len == 2 /* "&#" */) + { + goto want_more; + } if (p[2] == 0x78 /* 'x' */) - pval = p + 3, base = 16; + { + pval = p + 3, base = 16; + } else - pval = p + 2, base = 10; + { + pval = p + 2, base = 10; + } len = OS__strtoent(base, pval, p + len, &val); if (len == -1) { @@ -1190,7 +1267,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, *buf++ = ch; continue; } - if (!len || pval[len - 1] != 0x3b) goto want_more; + if (!len || pval[len - 1] != 0x3b) + { + goto want_more; + } assert(val > 0); p += (pval - p) + len - 1; /* Advance past entref */ @@ -1240,7 +1320,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, * Ugly, limited parsing of & > < */ char *sc = (char *)memchr(p, 0x3b, len > 5 ? 5 : len); - if (!sc) goto want_more; + if (!sc) + { + goto want_more; + } if ((sc - p) == 4 && p[1] == 0x61 /* 'a' */ && p[2] == 0x6d /* 'm' */ && p[3] == 0x70 /* 'p' */) @@ -1329,7 +1412,10 @@ static asn_dec_rval_t OCTET_STRING__decode_xer( { st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size); *sptr = (void *)st; - if (!st) goto sta_failed; + if (!st) + { + goto sta_failed; + } st_allocated = 1; } else @@ -1425,14 +1511,19 @@ static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf, else if (pc && pc->code2value) { if (unit_bits > 16) - return 1; /* FATAL: can't have constrained + { + return 1; + } /* FATAL: can't have constrained * UniversalString with more than * 16 million code points */ for (; buf < end; buf += bpc) { int value; int code = per_get_few_bits(po, unit_bits); - if (code < 0) return -1; /* WMORE */ + if (code < 0) + { + return -1; /* WMORE */ + } value = pc->code2value(code); if (value < 0) { @@ -1472,7 +1563,10 @@ static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf, { int code = per_get_few_bits(po, unit_bits); int ch = code + lb; - if (code < 0) return -1; /* WMORE */ + if (code < 0) + { + return -1; /* WMORE */ + } if (ch > ub) { ASN_DEBUG("Code %d is out of range (%ld..%ld)", ch, lb, ub); @@ -1546,7 +1640,10 @@ static int OCTET_STRING_per_put_characters(asn_per_outp_t *po, *buf, *buf, lb, ub); return -1; } - if (per_put_few_bits(po, code, unit_bits)) return -1; + if (per_put_few_bits(po, code, unit_bits)) + { + return -1; + } } } @@ -1584,7 +1681,10 @@ static int OCTET_STRING_per_put_characters(asn_per_outp_t *po, *buf, *buf, lb, ub + lb); return -1; } - if (per_put_few_bits(po, ch, unit_bits)) return -1; + if (per_put_few_bits(po, ch, unit_bits)) + { + return -1; + } } return 0; @@ -1640,17 +1740,26 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, break; case ASN_OSUBV_STR: canonical_unit_bits = unit_bits = 8; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_CHAR; break; case ASN_OSUBV_U16: canonical_unit_bits = unit_bits = 16; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U16; break; case ASN_OSUBV_U32: canonical_unit_bits = unit_bits = 32; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U32; break; } @@ -1661,7 +1770,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); - if (!st) RETURN(RC_FAIL); + if (!st) + { + RETURN(RC_FAIL); + } } ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d", @@ -1671,7 +1783,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (csiz->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); - if (inext < 0) RETURN(RC_WMORE); + if (inext < 0) + { + RETURN(RC_WMORE); + } if (inext) { csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; @@ -1712,7 +1827,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ret = OCTET_STRING_per_get_characters( pd, st->buf, csiz->upper_bound, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); - if (ret > 0) RETURN(RC_FAIL); + if (ret > 0) + { + RETURN(RC_FAIL); + } } else { @@ -1721,7 +1839,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ret = per_get_many_bits(pd, st->buf, 0, unit_bits * csiz->upper_bound); } - if (ret < 0) RETURN(RC_WMORE); + if (ret < 0) + { + RETURN(RC_WMORE); + } consumed_myself += unit_bits * csiz->upper_bound; st->buf[st->size] = 0; if (bpc == 0) @@ -1743,7 +1864,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, /* Get the PER length */ raw_len = uper_get_length(pd, csiz->effective_bits, &repeat); - if (raw_len < 0) RETURN(RC_WMORE); + if (raw_len < 0) + { + RETURN(RC_WMORE); + } raw_len += csiz->lower_bound; ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)", @@ -1758,11 +1882,17 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, { len_bits = raw_len; len_bytes = (len_bits + 7) >> 3; - if (len_bits & 0x7) st->bits_unused = 8 - (len_bits & 0x7); + if (len_bits & 0x7) + { + st->bits_unused = 8 - (len_bits & 0x7); + } /* len_bits be multiple of 16K if repeat is set */ } p = REALLOC(st->buf, st->size + len_bytes + 1); - if (!p) RETURN(RC_FAIL); + if (!p) + { + RETURN(RC_FAIL); + } st->buf = (uint8_t *)p; if (bpc) @@ -1770,14 +1900,20 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ret = OCTET_STRING_per_get_characters( pd, &st->buf[st->size], raw_len, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); - if (ret > 0) RETURN(RC_FAIL); + if (ret > 0) + { + RETURN(RC_FAIL); + } } else { ret = per_get_many_bits(pd, &st->buf[st->size], 0, len_bits); } - if (ret < 0) RETURN(RC_WMORE); + if (ret < 0) + { + RETURN(RC_WMORE); + } st->size += len_bytes; } while (repeat); @@ -1813,7 +1949,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, } bpc; /* Bytes per character */ int ct_extensible; - if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; + if (!st || (!st->buf && st->size)) + { + _ASN_ENCODE_FAILED; + } if (pc) { @@ -1841,19 +1980,28 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, break; case ASN_OSUBV_STR: canonical_unit_bits = unit_bits = 8; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_CHAR; sizeinunits = st->size; break; case ASN_OSUBV_U16: canonical_unit_bits = unit_bits = 16; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U16; sizeinunits = st->size / 2; break; case ASN_OSUBV_U32: canonical_unit_bits = unit_bits = 32; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U32; sizeinunits = st->size / 4; break; @@ -1880,7 +2028,9 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, inext = 1; } else - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } } else @@ -1891,7 +2041,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, if (ct_extensible) { /* Declare whether length is [not] within extension root */ - if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, inext, 1)) + { + _ASN_ENCODE_FAILED; + } } /* X.691, #16.5: zero-length encoding */ @@ -1903,7 +2056,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, sizeinunits - csiz->lower_bound, csiz->effective_bits); ret = per_put_few_bits(po, sizeinunits - csiz->lower_bound, csiz->effective_bits); - if (ret) _ASN_ENCODE_FAILED; + if (ret) + { + _ASN_ENCODE_FAILED; + } if (bpc) { ret = OCTET_STRING_per_put_characters( @@ -1915,7 +2071,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, ret = per_put_many_bits(po, st->buf, sizeinunits * unit_bits); } - if (ret) _ASN_ENCODE_FAILED; + if (ret) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -1923,7 +2082,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, if (sizeinunits == 0) { - if (uper_put_length(po, 0)) _ASN_ENCODE_FAILED; + if (uper_put_length(po, 0)) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -1931,7 +2093,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, while (sizeinunits) { ssize_t maySave = uper_put_length(po, sizeinunits); - if (maySave < 0) _ASN_ENCODE_FAILED; + if (maySave < 0) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Encoding %ld of %ld", (long)maySave, (long)sizeinunits); @@ -1945,12 +2110,19 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, { ret = per_put_many_bits(po, buf, maySave * unit_bits); } - if (ret) _ASN_ENCODE_FAILED; + if (ret) + { + _ASN_ENCODE_FAILED; + } if (bpc) - buf += maySave * bpc; + { + buf += maySave * bpc; + } else - buf += maySave >> 3; + { + buf += maySave >> 3; + } sizeinunits -= maySave; assert(!(maySave & 0x07) || !sizeinunits); } @@ -1972,7 +2144,9 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, (void)td; /* Unused argument */ if (!st || (!st->buf && st->size)) - return (cb("", 8, app_key) < 0) ? -1 : 0; + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* * Dump the contents of the buffer in hexadecimal. @@ -1983,7 +2157,10 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, { if (!(i % 16) && (i || st->size > 16)) { - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } _i_INDENT(1); p = scratch; } @@ -1995,7 +2172,10 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, if (p > scratch) { p--; /* Remove the tail space */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } } return 0; @@ -2030,7 +2210,10 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); struct _stack *stck; - if (!td || !st) return; + if (!td || !st) + { + return; + } ASN_DEBUG("Freeing %s as OCTET STRING", td->name); @@ -2086,11 +2269,17 @@ int OCTET_STRING_fromBuf(OCTET_STRING_t *st, const char *str, int len) } /* Determine the original string size, if not explicitly given */ - if (len < 0) len = strlen(str); + if (len < 0) + { + len = strlen(str); + } /* Allocate and fill the memory */ buf = MALLOC(len + 1); - if (buf == NULL) return -1; + if (buf == NULL) + { + return -1; + } memcpy(buf, str, len); ((uint8_t *)buf)[len] = '\0'; /* Couldn't use memcpy(len+1)! */ diff --git a/src/core/libs/supl/asn-rrlp/OTD-FirstSetMsrs.c b/src/core/libs/supl/asn-rrlp/OTD-FirstSetMsrs.c index 52ebde10b..5747250a8 100644 --- a/src/core/libs/supl/asn-rrlp/OTD-FirstSetMsrs.c +++ b/src/core/libs/supl/asn-rrlp/OTD-FirstSetMsrs.c @@ -31,7 +31,9 @@ static void OTD_FirstSetMsrs_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_OTD_MeasurementWithID.uper_decoder; td->uper_encoder = asn_DEF_OTD_MeasurementWithID.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_OTD_MeasurementWithID.per_constraints; + { + td->per_constraints = asn_DEF_OTD_MeasurementWithID.per_constraints; + } td->elements = asn_DEF_OTD_MeasurementWithID.elements; td->elements_count = asn_DEF_OTD_MeasurementWithID.elements_count; td->specifics = asn_DEF_OTD_MeasurementWithID.specifics; diff --git a/src/core/libs/supl/asn-rrlp/OTD-MeasureInfo-5-Ext.c b/src/core/libs/supl/asn-rrlp/OTD-MeasureInfo-5-Ext.c index fb5916a4e..448f6ca46 100644 --- a/src/core/libs/supl/asn-rrlp/OTD-MeasureInfo-5-Ext.c +++ b/src/core/libs/supl/asn-rrlp/OTD-MeasureInfo-5-Ext.c @@ -52,7 +52,9 @@ static void OTD_MeasureInfo_5_Ext_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_SeqOfOTD_MsrElementRest.uper_decoder; td->uper_encoder = asn_DEF_SeqOfOTD_MsrElementRest.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_SeqOfOTD_MsrElementRest.per_constraints; + { + td->per_constraints = asn_DEF_SeqOfOTD_MsrElementRest.per_constraints; + } td->elements = asn_DEF_SeqOfOTD_MsrElementRest.elements; td->elements_count = asn_DEF_SeqOfOTD_MsrElementRest.elements_count; td->specifics = asn_DEF_SeqOfOTD_MsrElementRest.specifics; diff --git a/src/core/libs/supl/asn-rrlp/OTDValue.c b/src/core/libs/supl/asn-rrlp/OTDValue.c index cfff75410..ecb9075db 100644 --- a/src/core/libs/supl/asn-rrlp/OTDValue.c +++ b/src/core/libs/supl/asn-rrlp/OTDValue.c @@ -48,7 +48,9 @@ static void OTDValue_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/PositionData.c b/src/core/libs/supl/asn-rrlp/PositionData.c index 2e238dc4f..ed6d09a3d 100644 --- a/src/core/libs/supl/asn-rrlp/PositionData.c +++ b/src/core/libs/supl/asn-rrlp/PositionData.c @@ -58,7 +58,9 @@ static void PositionData_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-rrlp/PositionMethod.c b/src/core/libs/supl/asn-rrlp/PositionMethod.c index 5bcd8629b..59e2a0f0b 100644 --- a/src/core/libs/supl/asn-rrlp/PositionMethod.c +++ b/src/core/libs/supl/asn-rrlp/PositionMethod.c @@ -30,7 +30,9 @@ static void PositionMethod_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/RefQuality.c b/src/core/libs/supl/asn-rrlp/RefQuality.c index 224d35f94..f13a458ee 100644 --- a/src/core/libs/supl/asn-rrlp/RefQuality.c +++ b/src/core/libs/supl/asn-rrlp/RefQuality.c @@ -48,7 +48,9 @@ static void RefQuality_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/ReferenceRelation.c b/src/core/libs/supl/asn-rrlp/ReferenceRelation.c index 811339594..0aae80701 100644 --- a/src/core/libs/supl/asn-rrlp/ReferenceRelation.c +++ b/src/core/libs/supl/asn-rrlp/ReferenceRelation.c @@ -31,7 +31,9 @@ static void ReferenceRelation_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/RelDistance.c b/src/core/libs/supl/asn-rrlp/RelDistance.c index 95a2ee2c2..670c2c273 100644 --- a/src/core/libs/supl/asn-rrlp/RelDistance.c +++ b/src/core/libs/supl/asn-rrlp/RelDistance.c @@ -48,7 +48,9 @@ static void RelDistance_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/RelativeAlt.c b/src/core/libs/supl/asn-rrlp/RelativeAlt.c index 2ee3b41b5..d657cc235 100644 --- a/src/core/libs/supl/asn-rrlp/RelativeAlt.c +++ b/src/core/libs/supl/asn-rrlp/RelativeAlt.c @@ -48,7 +48,9 @@ static void RelativeAlt_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/RequestIndex.c b/src/core/libs/supl/asn-rrlp/RequestIndex.c index d7258d484..7f11a37f8 100644 --- a/src/core/libs/supl/asn-rrlp/RequestIndex.c +++ b/src/core/libs/supl/asn-rrlp/RequestIndex.c @@ -49,7 +49,9 @@ static void RequestIndex_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c b/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c index 69f42a357..497b67846 100644 --- a/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c +++ b/src/core/libs/supl/asn-rrlp/RequiredResponseTime.c @@ -50,7 +50,9 @@ static void RequiredResponseTime_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/RoughRTD.c b/src/core/libs/supl/asn-rrlp/RoughRTD.c index f732d8122..a3e213df4 100644 --- a/src/core/libs/supl/asn-rrlp/RoughRTD.c +++ b/src/core/libs/supl/asn-rrlp/RoughRTD.c @@ -48,7 +48,9 @@ static void RoughRTD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/SVID.c b/src/core/libs/supl/asn-rrlp/SVID.c index 7641aa054..19eb6b1bf 100644 --- a/src/core/libs/supl/asn-rrlp/SVID.c +++ b/src/core/libs/supl/asn-rrlp/SVID.c @@ -48,7 +48,9 @@ static void SVID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/SVIDMASK.c b/src/core/libs/supl/asn-rrlp/SVIDMASK.c index 8ea8e2e77..479f986ba 100644 --- a/src/core/libs/supl/asn-rrlp/SVIDMASK.c +++ b/src/core/libs/supl/asn-rrlp/SVIDMASK.c @@ -57,7 +57,9 @@ static void SVIDMASK_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-rrlp/SatelliteID.c b/src/core/libs/supl/asn-rrlp/SatelliteID.c index f9724baed..05b9bffab 100644 --- a/src/core/libs/supl/asn-rrlp/SatelliteID.c +++ b/src/core/libs/supl/asn-rrlp/SatelliteID.c @@ -48,7 +48,9 @@ static void SatelliteID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/StdResolution.c b/src/core/libs/supl/asn-rrlp/StdResolution.c index 97b7aee51..15a4e9ed1 100644 --- a/src/core/libs/supl/asn-rrlp/StdResolution.c +++ b/src/core/libs/supl/asn-rrlp/StdResolution.c @@ -49,7 +49,9 @@ static void StdResolution_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c b/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c index 45781f7df..1c6d93c0a 100644 --- a/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c +++ b/src/core/libs/supl/asn-rrlp/SystemInfoIndex.c @@ -49,7 +49,9 @@ static void SystemInfoIndex_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TA0.c b/src/core/libs/supl/asn-rrlp/TA0.c index 8237d961c..a58d256a3 100644 --- a/src/core/libs/supl/asn-rrlp/TA0.c +++ b/src/core/libs/supl/asn-rrlp/TA0.c @@ -48,7 +48,9 @@ static void TA0_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TA1.c b/src/core/libs/supl/asn-rrlp/TA1.c index 3b79d5d62..56704a1c6 100644 --- a/src/core/libs/supl/asn-rrlp/TA1.c +++ b/src/core/libs/supl/asn-rrlp/TA1.c @@ -48,7 +48,9 @@ static void TA1_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TA2.c b/src/core/libs/supl/asn-rrlp/TA2.c index 8eb79b9c3..c0bad6ed4 100644 --- a/src/core/libs/supl/asn-rrlp/TA2.c +++ b/src/core/libs/supl/asn-rrlp/TA2.c @@ -48,7 +48,9 @@ static void TA2_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TLMReservedBits.c b/src/core/libs/supl/asn-rrlp/TLMReservedBits.c index 31c70e6aa..b23629047 100644 --- a/src/core/libs/supl/asn-rrlp/TLMReservedBits.c +++ b/src/core/libs/supl/asn-rrlp/TLMReservedBits.c @@ -49,7 +49,9 @@ static void TLMReservedBits_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TLMWord.c b/src/core/libs/supl/asn-rrlp/TLMWord.c index 99e621b23..b391a3603 100644 --- a/src/core/libs/supl/asn-rrlp/TLMWord.c +++ b/src/core/libs/supl/asn-rrlp/TLMWord.c @@ -48,7 +48,9 @@ static void TLMWord_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TimeSlot.c b/src/core/libs/supl/asn-rrlp/TimeSlot.c index 6aae7e251..958cbe658 100644 --- a/src/core/libs/supl/asn-rrlp/TimeSlot.c +++ b/src/core/libs/supl/asn-rrlp/TimeSlot.c @@ -48,7 +48,9 @@ static void TimeSlot_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c b/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c index 637b3ab16..e1f99bcef 100644 --- a/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c +++ b/src/core/libs/supl/asn-rrlp/TimeSlotScheme.c @@ -30,7 +30,9 @@ static void TimeSlotScheme_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c b/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c index e72f0f994..1eede7b31 100644 --- a/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c +++ b/src/core/libs/supl/asn-rrlp/UlPseudoSegInd.c @@ -30,7 +30,9 @@ static void UlPseudoSegInd_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c b/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c index 2dfb1fb8c..e3d4752fb 100644 --- a/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c +++ b/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c @@ -40,7 +40,9 @@ static void ephemE_17_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; /* td->specifics = asn_DEF_NativeInteger.specifics; // Defined @@ -159,7 +161,9 @@ static void ephemAPowerHalf_19_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; /* td->specifics = asn_DEF_NativeInteger.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/UseMultipleSets.c b/src/core/libs/supl/asn-rrlp/UseMultipleSets.c index 7b5713806..8d86a06b5 100644 --- a/src/core/libs/supl/asn-rrlp/UseMultipleSets.c +++ b/src/core/libs/supl/asn-rrlp/UseMultipleSets.c @@ -30,7 +30,9 @@ static void UseMultipleSets_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-rrlp/VelocityEstimate.c b/src/core/libs/supl/asn-rrlp/VelocityEstimate.c index f0d0a68af..bd4295e59 100644 --- a/src/core/libs/supl/asn-rrlp/VelocityEstimate.c +++ b/src/core/libs/supl/asn-rrlp/VelocityEstimate.c @@ -31,7 +31,9 @@ static void VelocityEstimate_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; + { + td->per_constraints = asn_DEF_INTEGER.per_constraints; + } td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; diff --git a/src/core/libs/supl/asn-rrlp/asn_SEQUENCE_OF.c b/src/core/libs/supl/asn-rrlp/asn_SEQUENCE_OF.c index 67981e72f..13bb362ba 100644 --- a/src/core/libs/supl/asn-rrlp/asn_SEQUENCE_OF.c +++ b/src/core/libs/supl/asn-rrlp/asn_SEQUENCE_OF.c @@ -17,7 +17,9 @@ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) int n; if (number < 0 || number >= as->count) - return; /* Nothing to delete */ + { + return; /* Nothing to delete */ + } if (_do_free && as->free) { @@ -33,12 +35,17 @@ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) */ --as->count; for (n = number; n < as->count; n++) - as->array[n] = as->array[n + 1]; + { + as->array[n] = as->array[n + 1]; + } /* * Invoke the third-party function only when the state * of the parent structure is consistent. */ - if (ptr) as->free(ptr); + if (ptr) + { + as->free(ptr); + } } } diff --git a/src/core/libs/supl/asn-rrlp/asn_SET_OF.c b/src/core/libs/supl/asn-rrlp/asn_SET_OF.c index 317ebea09..2b7577198 100644 --- a/src/core/libs/supl/asn-rrlp/asn_SET_OF.c +++ b/src/core/libs/supl/asn-rrlp/asn_SET_OF.c @@ -51,7 +51,10 @@ void asn_set_del(void *asn_set_of_x, int number, int _do_free) if (as) { void *ptr; - if (number < 0 || number >= as->count) return; + if (number < 0 || number >= as->count) + { + return; + } if (_do_free && as->free) { @@ -68,7 +71,10 @@ void asn_set_del(void *asn_set_of_x, int number, int _do_free) * Invoke the third-party function only when the state * of the parent structure is consistent. */ - if (ptr) as->free(ptr); + if (ptr) + { + as->free(ptr); + } } } @@ -85,7 +91,10 @@ void asn_set_empty(void *asn_set_of_x) { if (as->free) { - while (as->count--) as->free(as->array[as->count]); + while (as->count--) + { + as->free(as->array[as->count]); + } } FREEMEM(as->array); as->array = 0; diff --git a/src/core/libs/supl/asn-rrlp/asn_codecs_prim.c b/src/core/libs/supl/asn-rrlp/asn_codecs_prim.c index 75b51ad38..753b943e9 100644 --- a/src/core/libs/supl/asn-rrlp/asn_codecs_prim.c +++ b/src/core/libs/supl/asn-rrlp/asn_codecs_prim.c @@ -24,7 +24,10 @@ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, if (st == NULL) { st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st)); - if (st == NULL) _ASN_DECODE_FAILED; + if (st == NULL) + { + _ASN_DECODE_FAILED; + } *sptr = (void *)st; } @@ -35,7 +38,10 @@ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } ASN_DEBUG("%s length is %d bytes", td->name, (int)length); @@ -124,13 +130,22 @@ void ASN__PRIMITIVE_TYPE_free(asn_TYPE_descriptor_t *td, void *sptr, { ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr; - if (!td || !sptr) return; + if (!td || !sptr) + { + return; + } ASN_DEBUG("Freeing %s as a primitive type", td->name); - if (st->buf) FREEMEM(st->buf); + if (st->buf) + { + FREEMEM(st->buf); + } - if (!contents_only) FREEMEM(st); + if (!contents_only) + { + FREEMEM(st); + } } /* @@ -154,7 +169,9 @@ static int xer_decode__unexpected_tag(void *key, const void *chunk_buf, if (arg->decoded_something) { if (xer_is_whitespace(chunk_buf, chunk_size)) - return 0; /* Skip it. */ + { + return 0; /* Skip it. */ + } /* * Decoding was done once already. Prohibit doing it again. */ @@ -188,7 +205,10 @@ static ssize_t xer_decode__body(void *key, const void *chunk_buf, if (arg->decoded_something) { - if (xer_is_whitespace(chunk_buf, chunk_size)) return chunk_size; + if (xer_is_whitespace(chunk_buf, chunk_size)) + { + return chunk_size; + } /* * Decoding was done once already. Prohibit doing it again. */ @@ -244,7 +264,10 @@ asn_dec_rval_t xer_decode_primitive( if (!*sptr) { *sptr = CALLOC(1, struct_size); - if (!*sptr) _ASN_DECODE_FAILED; + if (!*sptr) + { + _ASN_DECODE_FAILED; + } } memset(&s_ctx, 0, sizeof(s_ctx)); @@ -291,9 +314,13 @@ asn_dec_rval_t xer_decode_primitive( case RC_FAIL: rc.consumed = 0; if (s_arg.want_more) - rc.code = RC_WMORE; + { + rc.code = RC_WMORE; + } else - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } break; } return rc; diff --git a/src/core/libs/supl/asn-rrlp/ber_decoder.c b/src/core/libs/supl/asn-rrlp/ber_decoder.c index c2dbabbfe..f59773a2e 100644 --- a/src/core/libs/supl/asn-rrlp/ber_decoder.c +++ b/src/core/libs/supl/asn-rrlp/ber_decoder.c @@ -92,7 +92,10 @@ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, /* * Make sure we didn't exceed the maximum stack size. */ - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) RETURN(RC_FAIL); + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + RETURN(RC_FAIL); + } /* * So what does all this implicit skip stuff mean? @@ -317,11 +320,18 @@ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, } } - if (opt_tlv_form) *opt_tlv_form = tlv_constr; + if (opt_tlv_form) + { + *opt_tlv_form = tlv_constr; + } if (expect_00_terminators) - *last_length = -expect_00_terminators; + { + *last_length = -expect_00_terminators; + } else - *last_length = tlv_len; + { + *last_length = tlv_len; + } RETURN(RC_OK); } diff --git a/src/core/libs/supl/asn-rrlp/ber_tlv_length.c b/src/core/libs/supl/asn-rrlp/ber_tlv_length.c index 4efe95b95..4967c570c 100644 --- a/src/core/libs/supl/asn-rrlp/ber_tlv_length.c +++ b/src/core/libs/supl/asn-rrlp/ber_tlv_length.c @@ -12,7 +12,10 @@ ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size, const uint8_t *buf = (const uint8_t *)bufptr; unsigned oct; - if (size == 0) return 0; /* Want more */ + if (size == 0) + { + return 0; /* Want more */ + } oct = *buf; if ((oct & 0x80) == 0) @@ -90,13 +93,19 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, /* * Make sure we didn't exceed the maximum stack size. */ - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) return -1; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + return -1; + } /* * Determine the size of L in TLV. */ ll = ber_fetch_length(_is_constructed, ptr, size, &vlen); - if (ll <= 0) return ll; + if (ll <= 0) + { + return ll; + } /* * Definite length. @@ -104,7 +113,10 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, if (vlen >= 0) { skip = ll + vlen; - if (skip > size) return 0; /* Want more */ + if (skip > size) + { + return 0; /* Want more */ + } return skip; } @@ -118,11 +130,17 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, /* Fetch the tag */ tl = ber_fetch_tag(ptr, size, &tag); - if (tl <= 0) return tl; + if (tl <= 0) + { + return tl; + } ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), ((const char *)ptr) + tl, size - tl); - if (ll <= 0) return ll; + if (ll <= 0) + { + return ll; + } skip += tl + ll; @@ -133,7 +151,9 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, */ if (((const uint8_t *)ptr)[0] == 0 && ((const uint8_t *)ptr)[1] == 0) - return skip; + { + return skip; + } ptr = ((const char *)ptr) + tl + ll; size -= tl + ll; @@ -152,7 +172,10 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) if (len <= 127) { /* Encoded in 1 octet */ - if (size) *buf = (uint8_t)len; + if (size) + { + *buf = (uint8_t)len; + } return 1; } @@ -162,12 +185,19 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) for (required_size = 1, i = 8; i < 8 * sizeof(len); i += 8) { if (len >> i) - required_size++; + { + required_size++; + } else - break; + { + break; + } } - if (size <= required_size) return required_size + 1; + if (size <= required_size) + { + return required_size + 1; + } *buf++ = (uint8_t)(0x80 | required_size); /* Length of the encoding */ @@ -175,7 +205,10 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) * Produce the len encoding, space permitting. */ end = buf + required_size; - for (i -= 8; buf < end; i -= 8, buf++) *buf = (uint8_t)(len >> i); + for (i -= 8; buf < end; i -= 8, buf++) + { + *buf = (uint8_t)(len >> i); + } return required_size + 1; } diff --git a/src/core/libs/supl/asn-rrlp/ber_tlv_tag.c b/src/core/libs/supl/asn-rrlp/ber_tlv_tag.c index 0bef65296..06defa3e6 100644 --- a/src/core/libs/supl/asn-rrlp/ber_tlv_tag.c +++ b/src/core/libs/supl/asn-rrlp/ber_tlv_tag.c @@ -12,7 +12,10 @@ ssize_t ber_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r) ber_tlv_tag_t tclass; size_t skipped; - if (size == 0) return 0; + if (size == 0) + { + return 0; + } val = *(const uint8_t *)ptr; tclass = (val >> 6); @@ -98,7 +101,10 @@ ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size) } ret = snprintf(buf, size, "[%s%u]", type, ((unsigned)tag) >> 2); - if (ret <= 0 && size) buf[0] = '\0'; /* against broken libc's */ + if (ret <= 0 && size) + { + buf[0] = '\0'; /* against broken libc's */ + } return ret; } @@ -124,7 +130,10 @@ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) if (tval <= 30) { /* Encoded in 1 octet */ - if (size) buf[0] = (tclass << 6) | tval; + if (size) + { + buf[0] = (tclass << 6) | tval; + } return 1; } else if (size) @@ -139,18 +148,28 @@ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) for (required_size = 1, i = 7; i < 8 * sizeof(tval); i += 7) { if (tval >> i) - required_size++; + { + required_size++; + } else - break; + { + break; + } } - if (size < required_size) return required_size + 1; + if (size < required_size) + { + return required_size + 1; + } /* * Fill in the buffer, space permitting. */ end = buf + required_size - 1; - for (i -= 7; buf < end; i -= 7, buf++) *buf = 0x80 | ((tval >> i) & 0x7F); + for (i -= 7; buf < end; i -= 7, buf++) + { + *buf = 0x80 | ((tval >> i) & 0x7F); + } *buf = (tval & 0x7F); /* Last octet without high bit */ return required_size + 1; diff --git a/src/core/libs/supl/asn-rrlp/constr_CHOICE.c b/src/core/libs/supl/asn-rrlp/constr_CHOICE.c index 7c0917700..cc0386625 100644 --- a/src/core/libs/supl/asn-rrlp/constr_CHOICE.c +++ b/src/core/libs/supl/asn-rrlp/constr_CHOICE.c @@ -92,11 +92,17 @@ static int _search4tag(const void *ap, const void *bp) ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); if (a_value == b_value) - return 0; + { + return 0; + } else if (a_value < b_value) - return -1; + { + return -1; + } else - return 1; + { + return 1; + } } else if (a_class < b_class) { @@ -202,7 +208,10 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tag_len) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -251,7 +260,9 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { case 0: if (!SIZE_VIOLATION) - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -366,7 +377,10 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tl) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -380,9 +394,13 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -424,7 +442,10 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, size_t computed_size = 0; int present; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name); @@ -483,12 +504,18 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, /* Encode member with its tag */ erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } /* Encode CHOICE with parent or my own tag */ ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag, cb, app_key); - if (ret == -1) _ASN_ENCODE_FAILED; + if (ret == -1) + { + _ASN_ENCODE_FAILED; + } computed_size += ret; } @@ -497,7 +524,10 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, */ erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", (long)erval.encoded, (long)computed_size); @@ -576,7 +606,10 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, elm->memb_offset); if (!memb_ptr) { - if (elm->optional) return 0; + if (elm->optional) + { + return 0; + } _ASN_CTFAIL(app_key, td, sptr, "%s: mandatory CHOICE element %s " "absent (%s:%d)", @@ -658,7 +691,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); - if (st == 0) RETURN(RC_FAIL); + if (st == 0) + { + RETURN(RC_FAIL); + } } /* @@ -666,7 +702,9 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, */ 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 */ + { + ctx->phase = 1; /* Skip the outer tag checking phase */ + } /* * Phases of XER/XML processing: @@ -714,7 +752,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, XER_ADVANCE(tmprval.consumed); ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d", elm->type->name, tmprval.code); - if (tmprval.code != RC_OK) RETURN(tmprval.code); + if (tmprval.code != RC_OK) + { + RETURN(tmprval.code); + } assert(_fetch_present_idx(st, specs->pres_offset, specs->pres_size) == 0); /* Record what we've got */ @@ -788,7 +829,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, case XCT_BOTH: break; /* No CHOICE? */ case XCT_CLOSING: - if (ctx->phase != 3) break; + if (ctx->phase != 3) + { + break; + } XER_ADVANCE(ch_size); ctx->phase = 5; /* Phase out */ RETURN(RC_OK); @@ -803,7 +847,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: - if (ctx->phase != 1) break; /* Really unexpected */ + if (ctx->phase != 1) + { + break; /* Really unexpected */ + } /* * Search which inner member corresponds to this tag. @@ -832,7 +879,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, } break; } - if (edx != td->elements_count) continue; + if (edx != td->elements_count) + { + continue; + } /* It is expected extension */ if (specs->ext_start != -1) @@ -885,7 +935,10 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, asn_enc_rval_t er; int present; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } /* * Figure out which CHOICE element is encoded. @@ -907,7 +960,10 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (!memb_ptr) _ASN_ENCODE_FAILED; + if (!memb_ptr) + { + _ASN_ENCODE_FAILED; + } } else { @@ -916,19 +972,28 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded = 0; - if (!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel); + if (!(flags & XER_F_CANONICAL)) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } - if (!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!(flags & XER_F_CANONICAL)) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -949,7 +1014,10 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, void *st = *sptr; int value; - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + _ASN_DECODE_FAILED; + } /* * Create the target structure if it is not present already. @@ -957,42 +1025,75 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = *sptr = CALLOC(1, specs->struct_size); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - ct = 0; + { + ct = 0; + } if (ct && ct->flags & APC_EXTENSIBLE) { value = per_get_few_bits(pd, 1); - if (value < 0) _ASN_DECODE_STARVED; - if (value) ct = 0; /* Not restricted */ + if (value < 0) + { + _ASN_DECODE_STARVED; + } + if (value) + { + ct = 0; /* Not restricted */ + } } if (ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } ASN_DEBUG("CHOICE %s got index %d in range %d", td->name, value, ct->range_bits); - if (value > ct->upper_bound) _ASN_DECODE_FAILED; + if (value > ct->upper_bound) + { + _ASN_DECODE_FAILED; + } } else { - if (specs->ext_start == -1) _ASN_DECODE_FAILED; + if (specs->ext_start == -1) + { + _ASN_DECODE_FAILED; + } value = uper_get_nsnnwn(pd); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } value += specs->ext_start; - if (value >= td->elements_count) _ASN_DECODE_FAILED; + if (value >= td->elements_count) + { + _ASN_DECODE_FAILED; + } } /* Adjust if canonical order is different from natural order */ - if (specs->canonical_order) value = specs->canonical_order[value]; + if (specs->canonical_order) + { + value = specs->canonical_order[value]; + } /* Set presence to be able to free it later */ _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); @@ -1022,8 +1123,10 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, } if (rv.code != RC_OK) - ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, - rv.code); + { + ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, + rv.code); + } return rv; } @@ -1037,16 +1140,25 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, void *memb_ptr; int present; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Encoding %s as CHOICE", td->name); if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - ct = 0; + { + ct = 0; + } present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); @@ -1055,12 +1167,19 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, * can't deduce what to encode in the choice type. */ if (present <= 0 || present > td->elements_count) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } else - present--; + { + present--; + } /* Adjust if canonical order is different from natural order */ - if (specs->canonical_order) present = specs->canonical_order[present]; + if (specs->canonical_order) + { + present = specs->canonical_order[present]; + } ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present); @@ -1070,7 +1189,10 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, { if (ct->flags & APC_EXTENSIBLE) { - if (per_put_few_bits(po, 1, 1)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, 1, 1)) + { + _ASN_ENCODE_FAILED; + } } else { @@ -1080,14 +1202,22 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, } } if (ct && ct->flags & APC_EXTENSIBLE) - if (per_put_few_bits(po, 0, 1)) _ASN_ENCODE_FAILED; + { + if (per_put_few_bits(po, 0, 1)) + { + _ASN_ENCODE_FAILED; + } + } elm = &td->elements[present]; if (elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (!memb_ptr) _ASN_ENCODE_FAILED; + if (!memb_ptr) + { + _ASN_ENCODE_FAILED; + } } else { @@ -1097,7 +1227,9 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, if (ct && ct->range_bits >= 0) { if (per_put_few_bits(po, present, ct->range_bits)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } return elm->type->uper_encoder(elm->type, elm->per_constraints, memb_ptr, po); @@ -1105,12 +1237,19 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, else { asn_enc_rval_t rval; - if (specs->ext_start == -1) _ASN_ENCODE_FAILED; + if (specs->ext_start == -1) + { + _ASN_ENCODE_FAILED; + } if (uper_put_nsnnwn(po, present - specs->ext_start)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } if (uper_open_type_put(elm->type, elm->per_constraints, memb_ptr, po)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } rval.encoded = 0; _ASN_ENCODED_OK(rval); } @@ -1122,7 +1261,10 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; - if (!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!sptr) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* * Figure out which CHOICE element is encoded. @@ -1142,7 +1284,9 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, memb_ptr = *(const void *const *)((const char *)sptr + elm->memb_offset); if (!memb_ptr) - return (cb("", 8, app_key) < 0) ? -1 : 0; + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } } else { @@ -1155,7 +1299,9 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, { if (cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) - return -1; + { + return -1; + } } return elm->type->print_struct(elm->type, memb_ptr, ilevel, cb, @@ -1172,7 +1318,10 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; - if (!td || !ptr) return; + if (!td || !ptr) + { + return; + } ASN_DEBUG("Freeing %s as CHOICE", td->name); @@ -1192,7 +1341,10 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)ptr + elm->memb_offset); - if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); + if (memb_ptr) + { + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } } else { diff --git a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c index fadc934f9..22f517f81 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c +++ b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE.c @@ -99,7 +99,10 @@ static int _t2e_cmp(const void *ap, const void *bp) if (a_value == b_value) { - if (a->el_no > b->el_no) return 1; + if (a->el_no > b->el_no) + { + return 1; + } /* * Important: we do not check * for a->el_no <= b->el_no! @@ -107,9 +110,13 @@ static int _t2e_cmp(const void *ap, const void *bp) return 0; } else if (a_value < b_value) - return -1; + { + return -1; + } else - return 1; + { + return 1; + } } else if (a_class < b_class) { @@ -187,7 +194,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if (ctx->left >= 0) - ctx->left += rval.consumed; /* ?Subtracted below! */ + { + ctx->left += rval.consumed; /* ?Subtracted below! */ + } ADVANCE(rval.consumed); NEXT_PHASE(ctx); @@ -217,7 +226,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, int use_bsearch; int n; - if (ctx->step & 1) goto microphase2; + if (ctx->step & 1) + { + goto microphase2; + } /* * MICROPHASE 1: Synchronize decoding. @@ -259,7 +271,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tag_len) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -270,9 +285,13 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -306,7 +325,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, use_bsearch = 0; opt_edx_end = edx + elements[edx].optional + 1; if (opt_edx_end > td->elements_count) - opt_edx_end = td->elements_count; /* Cap */ + { + opt_edx_end = td->elements_count; /* Cap */ + } else if (opt_edx_end - edx > 8) { /* Limit the scope of linear search... */ @@ -372,8 +393,14 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, t2m_l = t2m + t2m->toff_last; for (t2m = t2m_f; t2m <= t2m_l; t2m++) { - if (t2m->el_no > edx_max) break; - if (t2m->el_no < edx) continue; + if (t2m->el_no > edx_max) + { + break; + } + if (t2m->el_no < edx) + { + continue; + } best = t2m; } if (best) @@ -428,7 +455,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { case 0: if (!SIZE_VIOLATION) - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -524,7 +553,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tl) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -538,9 +570,13 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -571,7 +607,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (ll) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -612,7 +651,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } @@ -623,7 +665,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, } erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } computed_size += erval.encoded; ASN_DEBUG("Member %d %s estimated %ld bytes", edx, elm->name, (long)erval.encoded); @@ -634,10 +679,16 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, */ ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key); ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size); - if (ret == -1) _ASN_ENCODE_FAILED; + if (ret == -1) + { + _ASN_ENCODE_FAILED; + } erval.encoded = computed_size + ret; - if (!cb) _ASN_ENCODED_OK(erval); + if (!cb) + { + _ASN_ENCODED_OK(erval); + } /* * Encode all members. @@ -651,7 +702,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } } else { @@ -659,17 +713,22 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, } tmperval = elm->type->der_encoder( elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); - if (tmperval.encoded == -1) return tmperval; + if (tmperval.encoded == -1) + { + return tmperval; + } computed_size -= tmperval.encoded; ASN_DEBUG("Member %d %s of SEQUENCE %s encoded in %ld bytes", edx, elm->name, td->name, (long)tmperval.encoded); } if (computed_size != 0) - /* + { + /* * Encoded size is not equal to the computed size. */ - _ASN_ENCODE_FAILED; + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(erval); } @@ -717,7 +776,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); - if (st == 0) RETURN(RC_FAIL); + if (st == 0) + { + RETURN(RC_FAIL); + } } /* @@ -769,7 +831,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); - if (tmprval.code != RC_OK) RETURN(tmprval.code); + if (tmprval.code != RC_OK) + { + RETURN(tmprval.code); + } ctx->phase = 1; /* Back to body processing */ ctx->step = ++edx; ASN_DEBUG("XER/SEQUENCE phase => %d, step => %d", @@ -827,7 +892,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, switch (tcv) { case XCT_CLOSING: - if (ctx->phase == 0) break; + if (ctx->phase == 0) + { + break; + } ctx->phase = 0; /* Fall through */ case XCT_BOTH: @@ -879,7 +947,9 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, */ edx_end = edx + elements[edx].optional + 1; if (edx_end > td->elements_count) - edx_end = td->elements_count; + { + edx_end = td->elements_count; + } for (n = edx; n < edx_end; n++) { elm = &td->elements[n]; @@ -904,7 +974,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, } break; } - if (n != edx_end) continue; + if (n != edx_end) + { + continue; + } } else { @@ -965,7 +1038,10 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int xcan = (flags & XER_F_CANONICAL); int edx; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -982,7 +1058,10 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } @@ -992,19 +1071,28 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, memb_ptr = (void *)((char *)sptr + elm->memb_offset); } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); /* Print the member itself */ tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -1017,12 +1105,17 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, int edx; int ret; - if (!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!sptr) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* Dump preamble */ if (cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) - return -1; + { + return -1; + } for (edx = 0; edx < td->elements_count; edx++) { @@ -1035,7 +1128,10 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Print line */ /* Fall through */ } @@ -1052,12 +1148,17 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, /* Print the member's name and stuff */ if (cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) - return -1; + { + return -1; + } /* Print the member itself */ ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } ilevel--; @@ -1070,7 +1171,10 @@ void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { int edx; - if (!td || !sptr) return; + if (!td || !sptr) + { + return; + } ASN_DEBUG("Freeing %s as SEQUENCE", td->name); @@ -1081,7 +1185,10 @@ void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); + if (memb_ptr) + { + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } } else { @@ -1122,7 +1229,10 @@ int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } _ASN_CTFAIL( app_key, td, sptr, "%s: mandatory element %s absent (%s:%d)", @@ -1140,13 +1250,19 @@ int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, { int ret = elm->memb_constraints(elm->type, memb_ptr, ctfailcb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } else { int ret = elm->type->check_constraints(elm->type, memb_ptr, ctfailcb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } /* * Cannot inherit it earlier: * need to make sure we get the updated version. @@ -1173,12 +1289,18 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, (void)constraints; - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + _ASN_DECODE_FAILED; + } if (!st) { st = *sptr = CALLOC(1, specs->struct_size); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name); @@ -1187,7 +1309,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (specs->ext_before >= 0) { extpresent = per_get_few_bits(pd, 1); - if (extpresent < 0) _ASN_DECODE_STARVED; + if (extpresent < 0) + { + _ASN_DECODE_STARVED; + } } else { @@ -1199,7 +1324,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (specs->roms_count) { opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1); - if (!opres) _ASN_DECODE_FAILED; + if (!opres) + { + _ASN_DECODE_FAILED; + } /* Get the presence map */ if (per_get_many_bits(pd, opres, 0, specs->roms_count)) { @@ -1225,7 +1353,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ - if (IN_EXTENSION_GROUP(specs, edx)) continue; + if (IN_EXTENSION_GROUP(specs, edx)) + { + continue; + } /* Fetch the pointer to this member */ if (elm->flags & ATF_POINTER) @@ -1289,12 +1420,18 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_per_data_t epmd; bmlength = uper_get_nslength(pd); - if (bmlength < 0) _ASN_DECODE_STARVED; + if (bmlength < 0) + { + _ASN_DECODE_STARVED; + } ASN_DEBUG("Extensions %d present in %s", bmlength, td->name); epres = (uint8_t *)MALLOC((bmlength + 15) >> 3); - if (!epres) _ASN_DECODE_STARVED; + if (!epres) + { + _ASN_DECODE_STARVED; + } /* Get the extensions map */ if (per_get_many_bits(pd, epres, 0, bmlength)) @@ -1338,7 +1475,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, present = per_get_few_bits(&epmd, 1); if (present <= 0) { - if (present < 0) break; /* No more extensions */ + if (present < 0) + { + break; /* No more extensions */ + } continue; } @@ -1385,13 +1525,19 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_member_t *elm = &td->elements[edx]; void **memb_ptr2; /* Pointer to member pointer */ - if (!elm->default_value) continue; + if (!elm->default_value) + { + continue; + } /* Fetch the pointer to this member */ if (elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)st + elm->memb_offset); - if (*memb_ptr2) continue; + if (*memb_ptr2) + { + continue; + } } else { @@ -1418,7 +1564,10 @@ static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr, int exts_count = 0; int edx; - if (specs->ext_before < 0) return 0; + if (specs->ext_before < 0) + { + return 0; + } /* Find out which extensions are present */ for (edx = specs->ext_after + 1; edx < td->elements_count; edx++) @@ -1454,12 +1603,17 @@ static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr, exts_present += present; /* Encode as presence marker */ - if (po1 && per_put_few_bits(po1, present, 1)) return -1; + if (po1 && per_put_few_bits(po1, present, 1)) + { + return -1; + } /* Encode as open type field */ if (po2 && present && uper_open_type_put(elm->type, elm->per_constraints, *memb_ptr2, po2)) - return -1; + { + return -1; + } } return exts_present ? exts_count : 0; @@ -1477,7 +1631,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, (void)constraints; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -1524,13 +1681,18 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, /* Eliminate default values */ if (present && elm->default_value && elm->default_value(0, memb_ptr2) == 1) - present = 0; + { + present = 0; + } ASN_DEBUG("Element %s %s %s->%s is %s", elm->flags & ATF_POINTER ? "ptr" : "inline", elm->default_value ? "def" : "wtv", td->name, elm->name, present ? "present" : "absent"); - if (per_put_few_bits(po, present, 1)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, present, 1)) + { + _ASN_ENCODE_FAILED; + } } /* @@ -1546,7 +1708,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ - if (IN_EXTENSION_GROUP(specs, edx)) continue; + if (IN_EXTENSION_GROUP(specs, edx)) + { + continue; + } ASN_DEBUG("About to encode %s", elm->type->name); @@ -1558,7 +1723,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, { ASN_DEBUG("Element %s %d not present", elm->name, edx); - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } @@ -1571,31 +1739,46 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, /* Eliminate default values */ if (elm->default_value && elm->default_value(0, memb_ptr2) == 1) - continue; + { + continue; + } ASN_DEBUG("Encoding %s->%s", td->name, elm->name); er = elm->type->uper_encoder(elm->type, elm->per_constraints, *memb_ptr2, po); - if (er.encoded == -1) return er; + if (er.encoded == -1) + { + return er; + } } /* No extensions to encode */ - if (!n_extensions) _ASN_ENCODED_OK(er); + if (!n_extensions) + { + _ASN_ENCODED_OK(er); + } ASN_DEBUG("Length of %d bit-map", n_extensions); /* #18.8. Write down the presence bit-map length. */ - if (uper_put_nslength(po, n_extensions)) _ASN_ENCODE_FAILED; + if (uper_put_nslength(po, n_extensions)) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Bit-map of %d elements", n_extensions); /* #18.7. Encoding the extensions presence bit-map. */ /* TODO: act upon NOTE in #18.7 for canonical PER */ if (SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Writing %d extensions", n_extensions); /* #18.9. Encode extensions as open type fields. */ if (SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } diff --git a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE_OF.c b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE_OF.c index afdfa64a2..7dd683d73 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SEQUENCE_OF.c +++ b/src/core/libs/supl/asn-rrlp/constr_SEQUENCE_OF.c @@ -30,10 +30,16 @@ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for (edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } computed_size += erval.encoded; } @@ -65,10 +71,16 @@ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for (edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, cb, app_key); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } encoding_size += erval.encoded; } @@ -108,7 +120,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int xcan = (flags & XER_F_CANONICAL); int i; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -116,22 +131,34 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, { asn_enc_rval_t tmper; void *memb_ptr = list->array[i]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } if (mname) { - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); } tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } if (tmper.encoded == 0 && specs->as_XMLValueList) { const char *name = elm->type->xml_tag; size_t len = strlen(name); - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel + 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel + 1); + } _ASN_CALLBACK3("<", 1, name, len, "/>", 2); } @@ -144,7 +171,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded += (2 * mlen) + tmper.encoded; } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -161,7 +191,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, asn_TYPE_member_t *elm = td->elements; int seq; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } list = _A_SEQUENCE_FROM_VOID(sptr); er.encoded = 0; @@ -169,11 +202,17 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count); if (constraints) - ct = &constraints->size; + { + ct = &constraints->size; + } else if (td->per_constraints) - ct = &td->per_constraints->size; + { + ct = &td->per_constraints->size; + } else - ct = 0; + { + ct = 0; + } /* If extensible constraint, check if size is in root */ if (ct) @@ -186,11 +225,18 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, { /* Declare whether size is in extension root */ if (per_put_few_bits(po, not_in_root, 1)) - _ASN_ENCODE_FAILED; - if (not_in_root) ct = 0; + { + _ASN_ENCODE_FAILED; + } + if (not_in_root) + { + ct = 0; + } } else if (not_in_root && ct->effective_bits >= 0) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } if (ct && ct->effective_bits >= 0) @@ -198,13 +244,18 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, /* X.691, #19.5: No length determinant */ if (per_put_few_bits(po, list->count - ct->lower_bound, ct->effective_bits)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } for (seq = -1; seq < list->count;) { ssize_t mayEncode; - if (seq < 0) seq = 0; + if (seq < 0) + { + seq = 0; + } if (ct && ct->effective_bits >= 0) { mayEncode = list->count; @@ -212,16 +263,25 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, else { mayEncode = uper_put_length(po, list->count - seq); - if (mayEncode < 0) _ASN_ENCODE_FAILED; + if (mayEncode < 0) + { + _ASN_ENCODE_FAILED; + } } while (mayEncode--) { void *memb_ptr = list->array[seq++]; - if (!memb_ptr) _ASN_ENCODE_FAILED; + if (!memb_ptr) + { + _ASN_ENCODE_FAILED; + } er = elm->type->uper_encoder( elm->type, elm->per_constraints, memb_ptr, po); - if (er.encoded == -1) _ASN_ENCODE_FAILED; + if (er.encoded == -1) + { + _ASN_ENCODE_FAILED; + } } } 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 25638af5d..2be5881d6 100644 --- a/src/core/libs/supl/asn-rrlp/constr_SET_OF.c +++ b/src/core/libs/supl/asn-rrlp/constr_SET_OF.c @@ -140,7 +140,9 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if (ctx->left >= 0) - ctx->left += rval.consumed; /* ?Subtracted below! */ + { + ctx->left += rval.consumed; /* ?Subtracted below! */ + } ADVANCE(rval.consumed); ASN_DEBUG( @@ -160,7 +162,10 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { ssize_t tag_len; /* Length of TLV's T */ - if (ctx->step & 1) goto microphase2; + if (ctx->step & 1) + { + goto microphase2; + } /* * MICROPHASE 1: Synchronize decoding. @@ -184,7 +189,10 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tag_len) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -195,9 +203,13 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -255,9 +267,13 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); if (ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - ctx->ptr = 0; + { + ctx->ptr = 0; + } } break; case RC_WMORE: /* More data expected */ @@ -327,7 +343,10 @@ 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; - if (el_buf->length + size > el_buf->size) return -1; + if (el_buf->length + size > el_buf->size) + { + return -1; + } memcpy(el_buf->buf + el_buf->length, buffer, size); @@ -342,17 +361,25 @@ static int _el_buf_cmp(const void *ap, const void *bp) size_t common_len; if (a->length < b->length) - common_len = a->length; + { + common_len = a->length; + } else - common_len = b->length; + { + common_len = b->length; + } ret = memcmp(a->buf, b->buf, common_len); if (ret == 0) { if (a->length < b->length) - ret = -1; + { + ret = -1; + } else if (a->length > b->length) - ret = 1; + { + ret = 1; + } } return ret; @@ -386,14 +413,22 @@ 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]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } computed_size += erval.encoded; /* Compute maximum encoding's size */ if (max_encoded_len < (size_t)erval.encoded) - max_encoded_len = erval.encoded; + { + max_encoded_len = erval.encoded; + } } /* @@ -441,7 +476,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, void *memb_ptr = list->array[edx]; struct _el_buffer *encoded_el = &encoded_els[eels_count]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } /* * Prepare space for encoding. @@ -454,7 +492,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, } else { - for (edx--; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf); + for (edx--; edx >= 0; edx--) + { + FREEMEM(encoded_els[edx].buf); + } FREEMEM(encoded_els); erval.encoded = -1; erval.failed_type = td; @@ -469,7 +510,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, encoded_el); if (erval.encoded == -1) { - for (; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf); + for (; edx >= 0; edx--) + { + FREEMEM(encoded_els[edx].buf); + } FREEMEM(encoded_els); return erval; } @@ -493,7 +537,9 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, /* Report encoded chunks to the application */ if (ret == 0 && cb(encoded_el->buf, encoded_el->length, app_key) < 0) - ret = -1; + { + ret = -1; + } FREEMEM(encoded_el->buf); } FREEMEM(encoded_els); @@ -558,7 +604,10 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); - if (st == 0) RETURN(RC_FAIL); + if (st == 0) + { + RETURN(RC_FAIL); + } } /* Which tag is expected for the downstream */ @@ -604,7 +653,9 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, { asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); if (ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } ctx->ptr = 0; XER_ADVANCE(tmprval.consumed); } @@ -646,7 +697,10 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, switch (tcv) { case XCT_CLOSING: - if (ctx->phase == 0) break; + if (ctx->phase == 0) + { + break; + } ctx->phase = 0; /* Fall through */ case XCT_BOTH: @@ -705,7 +759,10 @@ static int SET_OF_encode_xer_callback(const void *buffer, size_t size, { size_t newsize = (t->size << 2) + size; void *p = REALLOC(t->buffer, newsize); - if (!p) return -1; + if (!p) + { + return -1; + } t->buffer = p; t->size = newsize; } @@ -719,12 +776,24 @@ static int SET_OF_xer_order(const void *aptr, const void *bptr) const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; size_t minlen = a->offset; int ret; - if (b->offset < minlen) minlen = b->offset; + if (b->offset < minlen) + { + minlen = b->offset; + } /* Well-formed UTF-8 has this nice lexicographical property... */ ret = memcmp(a->buffer, b->buffer, minlen); - if (ret != 0) return ret; - if (a->offset == b->offset) return 0; - if (a->offset == minlen) return -1; + if (ret != 0) + { + return ret; + } + if (a->offset == b->offset) + { + return 0; + } + if (a->offset == minlen) + { + return -1; + } return 1; } @@ -747,12 +816,18 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *original_cb = cb; int i; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } if (xcan) { encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); - if (!encs) _ASN_ENCODE_FAILED; + if (!encs) + { + _ASN_ENCODE_FAILED; + } cb = SET_OF_encode_xer_callback; } @@ -763,7 +838,10 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, asn_enc_rval_t tmper; void *memb_ptr = list->array[i]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } if (encs) { @@ -774,12 +852,17 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if (mname) { - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); } if (!xcan && specs->as_XMLValueList == 1) - _i_ASN_TEXT_INDENT(1, ilevel + 1); + { + _i_ASN_TEXT_INDENT(1, ilevel + 1); + } tmper = elm->type->xer_encoder( elm->type, memb_ptr, ilevel + (specs->as_XMLValueList != 2), flags, cb, app_key); @@ -805,7 +888,10 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded += (2 * mlen) + tmper.encoded; } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } if (encs) { @@ -838,7 +924,9 @@ cleanup: while (encs_count-- > 0) { if (encs[encs_count].buffer) - FREEMEM(encs[encs_count].buffer); + { + FREEMEM(encs[encs_count].buffer); + } } FREEMEM(encs); } @@ -853,23 +941,34 @@ int SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, int ret; int i; - if (!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!sptr) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* Dump preamble */ if (cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) - return -1; + { + return -1; + } for (i = 0; i < list->count; i++) { const void *memb_ptr = list->array[i]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } _i_INDENT(1); ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } ilevel--; @@ -895,7 +994,10 @@ void SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) for (i = 0; i < list->count; i++) { void *memb_ptr = list->array[i]; - if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); + if (memb_ptr) + { + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } } list->count = 0; /* No meaningful elements left */ @@ -932,7 +1034,10 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } constr = elm->memb_constraints; - if (!constr) constr = elm->type->check_constraints; + if (!constr) + { + constr = elm->type->check_constraints; + } /* * Iterate over the members of an array. @@ -943,10 +1048,16 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, const void *memb_ptr = list->array[i]; int ret; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } ret = constr(elm->type, memb_ptr, ctfailcb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } /* @@ -954,7 +1065,9 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, * need to make sure we get the updated version. */ if (!elm->memb_constraints) - elm->memb_constraints = elm->type->check_constraints; + { + elm->memb_constraints = elm->type->check_constraints; + } return 0; } @@ -973,7 +1086,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, int repeat = 0; ssize_t nelems; - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + _ASN_DECODE_FAILED; + } /* * Create the target structure if it is not present already. @@ -981,23 +1097,38 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = *sptr = CALLOC(1, specs->struct_size); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } list = _A_SET_FROM_VOID(st); /* Figure out which constraints to use */ if (constraints) - ct = &constraints->size; + { + ct = &constraints->size; + } else if (td->per_constraints) - ct = &td->per_constraints->size; + { + ct = &td->per_constraints->size; + } else - ct = 0; + { + ct = 0; + } if (ct && ct->flags & APC_EXTENSIBLE) { int value = per_get_few_bits(pd, 1); - if (value < 0) _ASN_DECODE_STARVED; - if (value) ct = 0; /* Not restricted! */ + if (value < 0) + { + _ASN_DECODE_STARVED; + } + if (value) + { + ct = 0; /* Not restricted! */ + } } if (ct && ct->effective_bits >= 0) @@ -1006,7 +1137,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, nelems = per_get_few_bits(pd, ct->effective_bits); ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s", (long)nelems, ct->lower_bound, td->name); - if (nelems < 0) _ASN_DECODE_STARVED; + if (nelems < 0) + { + _ASN_DECODE_STARVED; + } nelems += ct->lower_bound; } else @@ -1022,7 +1156,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, &repeat); ASN_DEBUG("Got to decode %d elements (eff %d)", (int)nelems, (long)ct ? ct->effective_bits : -1); - if (nelems < 0) _ASN_DECODE_STARVED; + if (nelems < 0) + { + _ASN_DECODE_STARVED; + } } for (ssize_t k = 0; k < nelems; k++) @@ -1036,7 +1173,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, elm->type->name, rv.code, ptr); if (rv.code == RC_OK) { - if (ASN_SET_ADD(list, ptr) == 0) continue; + if (ASN_SET_ADD(list, ptr) == 0) + { + continue; + } ASN_DEBUG("Failed to add element into %s", td->name); /* Fall through */ @@ -1047,7 +1187,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ASN_DEBUG("Failed decoding %s of %s (SET OF)", elm->type->name, td->name); } - if (ptr) ASN_STRUCT_FREE(*elm->type, ptr); + if (ptr) + { + ASN_STRUCT_FREE(*elm->type, ptr); + } return rv; } diff --git a/src/core/libs/supl/asn-rrlp/constr_TYPE.c b/src/core/libs/supl/asn-rrlp/constr_TYPE.c index 0e0cf4bda..193b42075 100644 --- a/src/core/libs/supl/asn-rrlp/constr_TYPE.c +++ b/src/core/libs/supl/asn-rrlp/constr_TYPE.c @@ -20,9 +20,15 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) { - if (tag_mode) return tag; + if (tag_mode) + { + return tag; + } - if (type_descriptor->tags_count) return type_descriptor->tags[0]; + if (type_descriptor->tags_count) + { + return type_descriptor->tags[0]; + } return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0); } @@ -32,7 +38,10 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor, */ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) { - if (!stream) stream = stdout; + if (!stream) + { + stream = stdout; + } if (!td || !struct_ptr) { errno = EINVAL; @@ -40,10 +49,16 @@ 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)) return -1; + if (td->print_struct(td, struct_ptr, 1, _print2fp, stream)) + { + return -1; + } /* Terminate the output */ - if (_print2fp("\n", 1, stream)) return -1; + if (_print2fp("\n", 1, stream)) + { + return -1; + } return fflush(stream); } @@ -53,7 +68,10 @@ static int _print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; - if (fwrite(buffer, 1, size, stream) != size) return -1; + if (fwrite(buffer, 1, size, stream) != size) + { + return -1; + } return 0; } diff --git a/src/core/libs/supl/asn-rrlp/constraints.c b/src/core/libs/supl/asn-rrlp/constraints.c index 3d96897ac..31dee7c77 100644 --- a/src/core/libs/supl/asn-rrlp/constraints.c +++ b/src/core/libs/supl/asn-rrlp/constraints.c @@ -49,7 +49,10 @@ static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, arg->failed_struct_ptr = sptr; maxlen = arg->errlen; - if (maxlen <= 0) return; + if (maxlen <= 0) + { + return; + } va_start(ap, fmt); vlen = vsnprintf(arg->errbuf, maxlen, fmt, ap); @@ -91,7 +94,10 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor, ret = type_descriptor->check_constraints(type_descriptor, struct_ptr, _asn_i_ctfailcb, &arg); - if (ret == -1 && errlen) *errlen = arg.errlen; + if (ret == -1 && errlen) + { + *errlen = arg.errlen; + } return ret; } diff --git a/src/core/libs/supl/asn-rrlp/converter-sample.c b/src/core/libs/supl/asn-rrlp/converter-sample.c index 7433cb18c..617f06b55 100644 --- a/src/core/libs/supl/asn-rrlp/converter-sample.c +++ b/src/core/libs/supl/asn-rrlp/converter-sample.c @@ -75,7 +75,10 @@ static void junk_bytes_with_probability(uint8_t *, size_t, double prob); static inline void DEBUG(const char *fmt, ...) { va_list ap; - if (!opt_debug) return; + if (!opt_debug) + { + return; + } fprintf(stderr, "AD: "); va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -92,210 +95,222 @@ int main(int ac, char *av[]) int ch; /* Figure out if Unaligned PER needs to be default */ - if (pduType->uper_decoder) iform = INP_PER; + if (pduType->uper_decoder) + { + iform = INP_PER; + } /* * Process the command-line arguments. */ - while ((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:" JUNKOPT)) != -1) switch (ch) - { - case 'i': - if (optarg[0] == 'b') - { - iform = INP_BER; - break; - } - if (optarg[0] == 'x') - { - iform = INP_XER; - break; - } - if (pduType->uper_decoder && optarg[0] == 'p') - { - iform = INP_PER; - break; - } - fprintf(stderr, - "-i: '%s': improper format selector\n", - optarg); - exit(EX_UNAVAILABLE); - case 'o': - if (optarg[0] == 'd') - { - oform = OUT_DER; - break; - } - if (pduType->uper_encoder && optarg[0] == 'p') - { - oform = OUT_PER; - break; - } - if (optarg[0] == 'x') - { - oform = OUT_XER; - break; - } - if (optarg[0] == 't') - { - oform = OUT_TEXT; - break; - } - if (optarg[0] == 'n') - { - oform = OUT_NULL; - break; - } - fprintf(stderr, - "-o: '%s': improper format selector\n", - optarg); - exit(EX_UNAVAILABLE); - case '1': - opt_onepdu = 1; - break; - case 'b': - suggested_bufsize = atoi(optarg); - if (suggested_bufsize < 1 || - suggested_bufsize > 16 * 1024 * 1024) - { - fprintf(stderr, - "-b %s: Improper buffer size (1..16M)\n", - optarg); - exit(EX_UNAVAILABLE); - } - break; - case 'c': - opt_check = 1; - break; - case 'd': - opt_debug++; /* Double -dd means ASN.1 debug */ - break; - case 'n': - number_of_iterations = atoi(optarg); - if (number_of_iterations < 1) - { - fprintf(stderr, - "-n %s: Improper iterations count\n", - optarg); - exit(EX_UNAVAILABLE); - } - break; - case 'p': - if (strcmp(optarg, "er-nopad") == 0) - { - opt_nopad = 1; - break; - } + while ((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:" JUNKOPT)) != -1) + { + switch (ch) + { + case 'i': + if (optarg[0] == 'b') + { + iform = INP_BER; + break; + } + if (optarg[0] == 'x') + { + iform = INP_XER; + break; + } + if (pduType->uper_decoder && optarg[0] == 'p') + { + iform = INP_PER; + break; + } + fprintf(stderr, + "-i: '%s': improper format selector\n", + optarg); + exit(EX_UNAVAILABLE); + case 'o': + if (optarg[0] == 'd') + { + oform = OUT_DER; + break; + } + if (pduType->uper_encoder && optarg[0] == 'p') + { + oform = OUT_PER; + break; + } + if (optarg[0] == 'x') + { + oform = OUT_XER; + break; + } + if (optarg[0] == 't') + { + oform = OUT_TEXT; + break; + } + if (optarg[0] == 'n') + { + oform = OUT_NULL; + break; + } + fprintf(stderr, + "-o: '%s': improper format selector\n", + optarg); + exit(EX_UNAVAILABLE); + case '1': + opt_onepdu = 1; + break; + case 'b': + suggested_bufsize = atoi(optarg); + if (suggested_bufsize < 1 || + suggested_bufsize > 16 * 1024 * 1024) + { + fprintf(stderr, + "-b %s: Improper buffer size (1..16M)\n", + optarg); + exit(EX_UNAVAILABLE); + } + break; + case 'c': + opt_check = 1; + break; + case 'd': + opt_debug++; /* Double -dd means ASN.1 debug */ + break; + case 'n': + number_of_iterations = atoi(optarg); + if (number_of_iterations < 1) + { + fprintf(stderr, + "-n %s: Improper iterations count\n", + optarg); + exit(EX_UNAVAILABLE); + } + break; + case 'p': + if (strcmp(optarg, "er-nopad") == 0) + { + opt_nopad = 1; + break; + } #ifdef ASN_PDU_COLLECTION - if (strcmp(optarg, "list") == 0) - { - asn_TYPE_descriptor_t **pdu = asn_pdu_collection; - fprintf(stderr, "Available PDU types:\n"); - for (; *pdu; pdu++) printf("%s\n", (*pdu)->name); - exit(0); - } - else if (optarg[0] >= 'A' && optarg[0] <= 'Z') - { - asn_TYPE_descriptor_t **pdu = asn_pdu_collection; - while (*pdu && strcmp((*pdu)->name, optarg)) pdu++; - if (*pdu) - { - pduType = *pdu; - break; - } - fprintf(stderr, "-p %s: Unrecognized PDU\n", - optarg); - } + if (strcmp(optarg, "list") == 0) + { + asn_TYPE_descriptor_t **pdu = asn_pdu_collection; + fprintf(stderr, "Available PDU types:\n"); + for (; *pdu; pdu++) printf("%s\n", (*pdu)->name); + exit(0); + } + else if (optarg[0] >= 'A' && optarg[0] <= 'Z') + { + asn_TYPE_descriptor_t **pdu = asn_pdu_collection; + while (*pdu && strcmp((*pdu)->name, optarg)) pdu++; + if (*pdu) + { + pduType = *pdu; + break; + } + fprintf(stderr, "-p %s: Unrecognized PDU\n", + optarg); + } #endif /* ASN_PDU_COLLECTION */ - fprintf(stderr, "-p %s: Unrecognized option\n", optarg); - exit(EX_UNAVAILABLE); - case 's': - opt_stack = atoi(optarg); - if (opt_stack < 0) - { - fprintf(stderr, - "-s %s: Non-negative value expected\n", - optarg); - exit(EX_UNAVAILABLE); - } - break; + fprintf(stderr, "-p %s: Unrecognized option\n", optarg); + exit(EX_UNAVAILABLE); + case 's': + opt_stack = atoi(optarg); + if (opt_stack < 0) + { + fprintf(stderr, + "-s %s: Non-negative value expected\n", + optarg); + exit(EX_UNAVAILABLE); + } + break; #ifdef JUNKTEST - case 'J': - opt_jprob = strtod(optarg, 0); - if (opt_jprob <= 0.0 || opt_jprob > 1.0) - { - fprintf(stderr, - "-J %s: Probability range 0..1 expected \n", - optarg); - exit(EX_UNAVAILABLE); - } - break; + case 'J': + opt_jprob = strtod(optarg, 0); + if (opt_jprob <= 0.0 || opt_jprob > 1.0) + { + fprintf(stderr, + "-J %s: Probability range 0..1 expected \n", + optarg); + exit(EX_UNAVAILABLE); + } + break; #endif /* JUNKTEST */ - case 'h': - default: + case 'h': + default: #ifdef ASN_CONVERTER_TITLE #define _AXS(x) #x #define _ASX(x) _AXS(x) - fprintf(stderr, "%s\n", _ASX(ASN_CONVERTER_TITLE)); + fprintf(stderr, "%s\n", _ASX(ASN_CONVERTER_TITLE)); #endif - fprintf(stderr, "Usage: %s [options] ...\n", - av[0]); - fprintf(stderr, "Where options are:\n"); - if (pduType->uper_decoder) - fprintf( - stderr, - " -iper Input is in Unaligned PER (Packed " - "Encoding Rules) (DEFAULT)\n"); - fprintf(stderr, - " -iber Input is in BER (Basic Encoding " - "Rules)%s\n", - iform == INP_PER ? "" : " (DEFAULT)"); - fprintf(stderr, - " -ixer Input is in XER (XML Encoding " - "Rules)\n"); - if (pduType->uper_encoder) - fprintf( - stderr, - " -oper Output in Unaligned PER (Packed " - "Encoding " - "Rules)\n"); - fprintf( - stderr, - " -oder Output in DER (Distinguished Encoding " - "Rules)\n" - " -oxer Output in XER (XML Encoding Rules) " - "(DEFAULT)\n" - " -otext Output in plain semi-structured text " - "(dump)\n" - " -onull Verify (decode) input, but do not " - "output\n"); - if (pduType->uper_decoder) + fprintf(stderr, "Usage: %s [options] ...\n", + av[0]); + fprintf(stderr, "Where options are:\n"); + if (pduType->uper_decoder) + { + fprintf( + stderr, + " -iper Input is in Unaligned PER (Packed " + "Encoding Rules) (DEFAULT)\n"); + } fprintf(stderr, - " -per-nopad Assume PER PDUs are not padded " - "(-iper)\n"); + " -iber Input is in BER (Basic Encoding " + "Rules)%s\n", + iform == INP_PER ? "" : " (DEFAULT)"); + fprintf(stderr, + " -ixer Input is in XER (XML Encoding " + "Rules)\n"); + if (pduType->uper_encoder) + { + fprintf( + stderr, + " -oper Output in Unaligned PER (Packed " + "Encoding " + "Rules)\n"); + } + fprintf( + stderr, + " -oder Output in DER (Distinguished Encoding " + "Rules)\n" + " -oxer Output in XER (XML Encoding Rules) " + "(DEFAULT)\n" + " -otext Output in plain semi-structured text " + "(dump)\n" + " -onull Verify (decode) input, but do not " + "output\n"); + if (pduType->uper_decoder) + { + fprintf(stderr, + " -per-nopad Assume PER PDUs are not padded " + "(-iper)\n"); + } #ifdef ASN_PDU_COLLECTION - fprintf(stderr, - " -p Specify PDU type to decode\n" - " -p list List available PDUs\n"); + fprintf(stderr, + " -p Specify PDU type to decode\n" + " -p list List available PDUs\n"); #endif /* ASN_PDU_COLLECTION */ - fprintf( - stderr, - " -1 Decode only the first PDU in file\n" - " -b Set the i/o buffer size (default is " - "%ld)\n" - " -c Check ASN.1 constraints after " - "decoding\n" - " -d Enable debugging (-dd is even better)\n" - " -n Process files times\n" - " -s Set the stack usage limit (default is " - "%d)\n" + fprintf( + stderr, + " -1 Decode only the first PDU in file\n" + " -b Set the i/o buffer size (default is " + "%ld)\n" + " -c Check ASN.1 constraints after " + "decoding\n" + " -d Enable debugging (-dd is even better)\n" + " -n Process files times\n" + " -s Set the stack usage limit (default is " + "%d)\n" #ifdef JUNKTEST - " -J Set random junk test bit garbaging " - "probability\n" + " -J Set random junk test bit garbaging " + "probability\n" #endif - , - (long)suggested_bufsize, _ASN_DEFAULT_STACK_MAX); - exit(EX_USAGE); - } + , + (long)suggested_bufsize, _ASN_DEFAULT_STACK_MAX); + exit(EX_USAGE); + } + } ac -= optind; av += optind; @@ -423,7 +438,10 @@ int main(int ac, char *av[]) ASN_STRUCT_FREE(*pduType, structure); } - if (file && file != stdin) fclose(file); + if (file && file != stdin) + { + fclose(file); + } } } @@ -453,7 +471,10 @@ static void buffer_dump() { uint8_t *p = DynamicBuffer.data + DynamicBuffer.offset; uint8_t *e = p + DynamicBuffer.length - (DynamicBuffer.unbits ? 1 : 0); - if (!opt_debug) return; + if (!opt_debug) + { + return; + } DEBUG("Buffer: { d=%p, o=%ld, l=%ld, u=%ld, a=%ld, s=%ld }", DynamicBuffer.data, (long)DynamicBuffer.offset, (long)DynamicBuffer.length, (long)DynamicBuffer.unbits, @@ -471,7 +492,9 @@ static void buffer_dump() unsigned int shift; fprintf(stderr, " "); for (shift = 7; shift >= DynamicBuffer.unbits; shift--) - fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0'); + { + fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0'); + } fprintf(stderr, " %ld:%ld\n", (long)DynamicBuffer.length - 1, (long)8 - DynamicBuffer.unbits); } @@ -491,7 +514,10 @@ static void buffer_shift_left(size_t offset, int bits) uint8_t *end = DynamicBuffer.data + DynamicBuffer.offset + DynamicBuffer.length - 1; - if (!bits) return; + if (!bits) + { + return; + } DEBUG("Shifting left %d bits off %ld (o=%ld, u=%ld, l=%ld)", bits, (long)offset, (long)DynamicBuffer.offset, (long)DynamicBuffer.unbits, @@ -576,7 +602,10 @@ static void buffer_shift_left(size_t offset, int bits) */ static void add_bytes_to_buffer(const void *data2add, size_t bytes) { - if (bytes == 0) return; + if (bytes == 0) + { + return; + } DEBUG("=> add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }", (long)bytes, (long)DynamicBuffer.offset, (long)DynamicBuffer.length, @@ -733,13 +762,17 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, break; case INP_PER: if (opt_nopad) - rval = uper_decode(opt_codec_ctx, pduType, - &structure, i_bptr, i_size, 0, - DynamicBuffer.unbits); + { + rval = uper_decode(opt_codec_ctx, pduType, + &structure, i_bptr, i_size, 0, + DynamicBuffer.unbits); + } else - rval = uper_decode_complete(opt_codec_ctx, pduType, - &structure, i_bptr, - i_size); + { + rval = uper_decode_complete(opt_codec_ctx, pduType, + &structure, i_bptr, + i_size); + } switch (rval.code) { case RC_OK: @@ -800,7 +833,10 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, switch (rval.code) { case RC_OK: - if (ecbits) buffer_shift_left(0, ecbits); + if (ecbits) + { + buffer_shift_left(0, ecbits); + } DEBUG("RC_OK, finishing up with %ld+%d", (long)rval.consumed, ecbits); return structure; @@ -813,7 +849,10 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, (long)DynamicBuffer.length, (long)DynamicBuffer.unbits, (long)DynamicBuffer.allocated); - if (!rd) tolerate_eof--; + if (!rd) + { + tolerate_eof--; + } continue; case RC_FAIL: break; @@ -889,9 +928,13 @@ static int argument_is_stdin(char *av[], int idx) { /* This might be , unless `./program -- -` */ if (strcmp(av[-1], "--") != 0) - return 1; + { + return 1; + } else - return 0; + { + return 0; + } } } diff --git a/src/core/libs/supl/asn-rrlp/der_encoder.c b/src/core/libs/supl/asn-rrlp/der_encoder.c index b65475a4d..76547e701 100644 --- a/src/core/libs/supl/asn-rrlp/der_encoder.c +++ b/src/core/libs/supl/asn-rrlp/der_encoder.c @@ -39,7 +39,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) enc_to_buf_arg *arg = (enc_to_buf_arg *)key; if (arg->left < size) - return -1; /* Data exceeds the available buffer size */ + { + return -1; /* Data exceeds the available buffer size */ + } memcpy(arg->buffer, buffer, size); arg->buffer = ((char *)arg->buffer) + size; @@ -114,7 +116,9 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, tags[0] = tag; stag_offset = -1 + ((tag_mode == -1) && sd->tags_count); for (i = 1; i < tags_count; i++) - tags[i] = sd->tags[i + stag_offset]; + { + tags[i] = sd->tags[i + stag_offset]; + } } else { @@ -123,7 +127,10 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, } /* No tags to write */ - if (tags_count == 0) return 0; + if (tags_count == 0) + { + return 0; + } lens = (ssize_t *)alloca(tags_count * sizeof(lens[0])); if (!lens) @@ -140,12 +147,18 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, for (i = tags_count - 1; i >= 0; --i) { lens[i] = der_write_TL(tags[i], overall_length, 0, 0, 0); - if (lens[i] == -1) return -1; + if (lens[i] == -1) + { + return -1; + } overall_length += lens[i]; lens[i] = overall_length - lens[i]; } - if (!cb) return overall_length - struct_length; + if (!cb) + { + return overall_length - struct_length; + } ASN_DEBUG("%s %s TL sequence (%d elements)", cb ? "Encoding" : "Estimating", sd->name, tags_count); @@ -162,7 +175,10 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, _constr = (last_tag_form || i < (tags_count - 1)); len = der_write_TL(tags[i], lens[i], cb, app_key, _constr); - if (len == -1) return -1; + if (len == -1) + { + return -1; + } } return overall_length - struct_length; @@ -179,24 +195,39 @@ static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len, /* Serialize tag (T from TLV) into possibly zero-length buffer */ tmp = ber_tlv_tag_serialize(tag, buf, buf_size); - if (tmp == -1 || tmp > (ssize_t)sizeof(buf)) return -1; + if (tmp == -1 || tmp > (ssize_t)sizeof(buf)) + { + return -1; + } size += tmp; /* Serialize length (L from TLV) into possibly zero-length buffer */ tmp = der_tlv_length_serialize(len, buf + size, buf_size ? buf_size - size : 0); - if (tmp == -1) return -1; + if (tmp == -1) + { + return -1; + } size += tmp; - if (size > sizeof(buf)) return -1; + if (size > sizeof(buf)) + { + return -1; + } /* * If callback is specified, invoke it, and check its return value. */ if (cb) { - if (constructed) *buf |= 0x20; - if (cb(buf, size, app_key) < 0) return -1; + if (constructed) + { + *buf |= 0x20; + } + if (cb(buf, size, app_key) < 0) + { + return -1; + } } return size; diff --git a/src/core/libs/supl/asn-rrlp/per_decoder.c b/src/core/libs/supl/asn-rrlp/per_decoder.c index cb9effce6..1374967f9 100644 --- a/src/core/libs/supl/asn-rrlp/per_decoder.c +++ b/src/core/libs/supl/asn-rrlp/per_decoder.c @@ -58,7 +58,9 @@ asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx, if (skip_bits < 0 || skip_bits > 7 || unused_bits < 0 || unused_bits > 7 || (unused_bits > 0 && !size)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } /* * Stack checker requires that the codec context @@ -85,12 +87,18 @@ asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx, pd.buffer = (const uint8_t *)buffer; pd.nboff = skip_bits; pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from */ - if (pd.nboff > pd.nbits) _ASN_DECODE_FAILED; + if (pd.nboff > pd.nbits) + { + _ASN_DECODE_FAILED; + } /* * Invoke type-specific decoder. */ - if (!td->uper_decoder) _ASN_DECODE_FAILED; /* PER is not compiled in */ + if (!td->uper_decoder) + { + _ASN_DECODE_FAILED; /* PER is not compiled in */ + } rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd); if (rval.code == RC_OK) { diff --git a/src/core/libs/supl/asn-rrlp/per_encoder.c b/src/core/libs/supl/asn-rrlp/per_encoder.c index b0013b1ff..bce368190 100644 --- a/src/core/libs/supl/asn-rrlp/per_encoder.c +++ b/src/core/libs/supl/asn-rrlp/per_encoder.c @@ -25,7 +25,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) enc_to_buf_arg *arg = (enc_to_buf_arg *)key; if (arg->left < size) - return -1; /* Data exceeds the available buffer size */ + { + return -1; /* Data exceeds the available buffer size */ + } memcpy(arg->buffer, buffer, size); arg->buffer = ((char *)arg->buffer) + size; @@ -42,7 +44,10 @@ asn_enc_rval_t uper_encode_to_buffer(asn_TYPE_descriptor_t *td, void *sptr, key.buffer = buffer; key.left = buffer_size; - if (td) ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name); + if (td) + { + ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name); + } return uper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key); } @@ -117,7 +122,10 @@ static int _uper_encode_flush_outp(asn_per_outp_t *po) { uint8_t *buf; - if (po->nboff == 0 && po->buffer == po->tmpspace) return 0; + if (po->nboff == 0 && po->buffer == po->tmpspace) + { + return 0; + } buf = po->buffer + (po->nboff >> 3); /* Make sure we account for the last, partially filled */ @@ -143,7 +151,9 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, * Invoke type-specific encoder. */ if (!td || !td->uper_encoder) - _ASN_ENCODE_FAILED; /* PER is not compiled in */ + { + _ASN_ENCODE_FAILED; /* PER is not compiled in */ + } po.buffer = po.tmpspace; po.nboff = 0; @@ -162,7 +172,10 @@ 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)) _ASN_ENCODE_FAILED; + if (_uper_encode_flush_outp(&po)) + { + _ASN_ENCODE_FAILED; + } } return er; diff --git a/src/core/libs/supl/asn-rrlp/per_opentype.c b/src/core/libs/supl/asn-rrlp/per_opentype.c index 5a91e77ae..b48fc82ec 100644 --- a/src/core/libs/supl/asn-rrlp/per_opentype.c +++ b/src/core/libs/supl/asn-rrlp/per_opentype.c @@ -40,19 +40,31 @@ int uper_open_type_put(asn_TYPE_descriptor_t *td, ASN_DEBUG("Open type put %s ...", td->name); size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); - if (size <= 0) return -1; + if (size <= 0) + { + return -1; + } for (bptr = buf, toGo = size; toGo;) { ssize_t maySave = uper_put_length(po, toGo); - if (maySave < 0) break; - if (per_put_many_bits(po, bptr, maySave * 8)) break; + if (maySave < 0) + { + break; + } + if (per_put_many_bits(po, bptr, maySave * 8)) + { + break; + } bptr = (char *)bptr + maySave; toGo -= maySave; } FREEMEM(buf); - if (toGo) return -1; + if (toGo) + { + return -1; + } ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", td->name, size); @@ -241,7 +253,10 @@ static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex( UPDRESTOREPD; /* Skip data not consumed by the decoder */ - if (arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); + if (arg.unclaimed) + { + ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); + } if (arg.unclaimed) { switch (per_skip_bits(pd, arg.unclaimed)) @@ -288,9 +303,13 @@ int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); if (rv.code != RC_OK) - return -1; + { + return -1; + } else - return 0; + { + return 0; + } } /* @@ -310,7 +329,9 @@ static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *ctx, (void)sptr; while (per_get_few_bits(pd, 24) >= 0) - ; + { + ; + } rv.code = RC_OK; rv.consumed = pd->moved; @@ -340,7 +361,10 @@ static int uper_ugot_refill(asn_per_data_t *pd) if (arg->unclaimed) { /* Refill the container */ - if (per_get_few_bits(oldpd, 1)) return -1; + if (per_get_few_bits(oldpd, 1)) + { + return -1; + } if (oldpd->nboff == 0) { assert(0); @@ -362,7 +386,10 @@ static int uper_ugot_refill(asn_per_data_t *pd) next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", next_chunk_bytes, oldpd->moved, arg->repeat); - if (next_chunk_bytes < 0) return -1; + if (next_chunk_bytes < 0) + { + return -1; + } if (next_chunk_bytes == 0) { pd->refill = 0; /* No more refills, naturally */ @@ -399,9 +426,13 @@ static int per_skip_bits(asn_per_data_t *pd, int skip_nbits) { int skip = 0; if (skip_nbits < skip) - skip = skip_nbits; + { + skip = skip_nbits; + } else - skip = 24; + { + skip = 24; + } skip_nbits -= skip; switch (per_get_few_bits(pd, skip)) diff --git a/src/core/libs/supl/asn-rrlp/per_support.c b/src/core/libs/supl/asn-rrlp/per_support.c index 9fdc23629..c37a01cb4 100644 --- a/src/core/libs/supl/asn-rrlp/per_support.c +++ b/src/core/libs/supl/asn-rrlp/per_support.c @@ -41,20 +41,32 @@ int32_t per_get_few_bits(asn_per_data_t *pd, int nbits) uint32_t accum; const uint8_t *buf; - if (nbits < 0) return -1; + if (nbits < 0) + { + return -1; + } nleft = pd->nbits - pd->nboff; if (nbits > nleft) { int32_t tailv; int32_t vhead; - if (!pd->refill || nbits > 31) return -1; + if (!pd->refill || nbits > 31) + { + return -1; + } /* Accumulate unused bytes before refill */ ASN_DEBUG("Obtain the rest %d bits (want %d)", (int)nleft, nbits); tailv = per_get_few_bits(pd, nleft); - if (tailv < 0) return -1; + if (tailv < 0) + { + return -1; + } /* Refill (replace pd contents with new data) */ - if (pd->refill(pd)) return -1; + if (pd->refill(pd)) + { + return -1; + } nbits -= nleft; vhead = per_get_few_bits(pd, nbits); /* Combine the rest of previous pd with the head of new one */ @@ -80,14 +92,22 @@ int32_t per_get_few_bits(asn_per_data_t *pd, int nbits) * Extract specified number of bits. */ if (off <= 8) - accum = nbits ? (buf[0]) >> (8 - off) : 0; + { + accum = nbits ? (buf[0]) >> (8 - off) : 0; + } else if (off <= 16) - accum = ((buf[0] << 8) + buf[1]) >> (16 - off); + { + accum = ((buf[0] << 8) + buf[1]) >> (16 - off); + } else if (off <= 24) - accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off); + { + accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off); + } else if (off <= 31) - accum = ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3])) >> - (32 - off); + { + accum = ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3])) >> + (32 - off); + } else if (nbits <= 31) { asn_per_data_t tpd = *pd; @@ -129,7 +149,10 @@ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) { /* Perform right alignment of a first few bits */ value = per_get_few_bits(pd, nbits & 0x07); - if (value < 0) return -1; + if (value < 0) + { + return -1; + } *dst++ = value; /* value is already right-aligned */ nbits &= ~7; } @@ -139,7 +162,10 @@ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) if (nbits >= 24) { value = per_get_few_bits(pd, 24); - if (value < 0) return -1; + if (value < 0) + { + return -1; + } *(dst++) = value >> 16; *(dst++) = value >> 8; *(dst++) = value; @@ -148,14 +174,26 @@ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) else { value = per_get_few_bits(pd, nbits); - if (value < 0) return -1; + if (value < 0) + { + return -1; + } if (nbits & 7) { /* implies left alignment */ value <<= 8 - (nbits & 7), nbits += 8 - (nbits & 7); - if (nbits > 24) *dst++ = value >> 24; + if (nbits > 24) + { + *dst++ = value >> 24; + } + } + if (nbits > 16) + { + *dst++ = value >> 16; + } + if (nbits > 8) + { + *dst++ = value >> 8; } - if (nbits > 16) *dst++ = value >> 16; - if (nbits > 8) *dst++ = value >> 8; *dst++ = value; break; } @@ -219,7 +257,10 @@ ssize_t uper_get_nslength(asn_per_data_t *pd) if (per_get_few_bits(pd, 1) == 0) { length = per_get_few_bits(pd, 6) + 1; - if (length <= 0) return -1; + if (length <= 0) + { + return -1; + } ASN_DEBUG("l=%d", (int)length); return length; } @@ -227,7 +268,10 @@ ssize_t uper_get_nslength(asn_per_data_t *pd) { int repeat; length = uper_get_length(pd, -1, &repeat); - if (length >= 0 && !repeat) return length; + if (length >= 0 && !repeat) + { + return length; + } return -1; /* Error, or do not support >16K extensions */ } } @@ -246,10 +290,18 @@ ssize_t uper_get_nsnnwn(asn_per_data_t *pd) value &= 63; value <<= 2; value |= per_get_few_bits(pd, 2); - if (value & 128) /* implicit (value < 0) */ - return -1; - if (value == 0) return 0; - if (value >= 3) return -1; + if (value & 128) + { /* implicit (value < 0) */ + return -1; + } + if (value == 0) + { + return 0; + } + if (value >= 3) + { + return -1; + } value = per_get_few_bits(pd, 8 * value); return value; } @@ -267,18 +319,32 @@ int uper_put_nsnnwn(asn_per_outp_t *po, int n) if (n <= 63) { - if (n < 0) return -1; + if (n < 0) + { + return -1; + } return per_put_few_bits(po, n, 7); } if (n < 256) - bytes = 1; + { + bytes = 1; + } else if (n < 65536) - bytes = 2; + { + bytes = 2; + } else if (n < 256 * 65536) - bytes = 3; + { + bytes = 3; + } else - return -1; /* This is not a "normally small" value */ - if (per_put_few_bits(po, bytes, 8)) return -1; + { + return -1; /* This is not a "normally small" value */ + } + if (per_put_few_bits(po, bytes, 8)) + { + return -1; + } return per_put_few_bits(po, n, 8 * bytes); } @@ -293,17 +359,29 @@ int uper_get_constrained_whole_number(asn_per_data_t *pd, if (nbits <= 31) { half = per_get_few_bits(pd, nbits); - if (half < 0) return -1; + if (half < 0) + { + return -1; + } *out_value = half; return 0; } - if ((size_t)nbits > 8 * sizeof(*out_value)) return -1; /* RANGE */ + if ((size_t)nbits > 8 * sizeof(*out_value)) + { + return -1; /* RANGE */ + } half = per_get_few_bits(pd, 31); - if (half < 0) return -1; + if (half < 0) + { + return -1; + } - if (uper_get_constrained_whole_number(pd, &lhalf, nbits - 31)) return -1; + if (uper_get_constrained_whole_number(pd, &lhalf, nbits - 31)) + { + return -1; + } *out_value = ((unsigned long)half << (nbits - 31)) | lhalf; return 0; @@ -336,7 +414,9 @@ int uper_put_constrained_whole_number_u(asn_per_outp_t *po, unsigned long v, { /* Put higher portion first, followed by lower 31-bit */ if (uper_put_constrained_whole_number_u(po, v >> 31, nbits - 31)) - return -1; + { + return -1; + } return per_put_few_bits(po, v, 31); } } @@ -375,7 +455,10 @@ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) size_t omsk; /* Existing last byte meaningful bits mask */ uint8_t *buf; - if (obits <= 0 || obits >= 32) return obits ? -1 : 0; + if (obits <= 0 || obits >= 32) + { + return obits ? -1 : 0; + } ASN_DEBUG("[PER put %d bits %x to %p+%d bits]", obits, (int)bits, po->buffer, (int)po->nboff); @@ -396,13 +479,21 @@ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) if (po->nboff + obits > po->nbits) { size_t complete_bytes; - if (!po->buffer) po->buffer = po->tmpspace; + if (!po->buffer) + { + po->buffer = po->tmpspace; + } complete_bytes = (po->buffer - po->tmpspace); ASN_DEBUG("[PER output %ld complete + %ld]", (long)complete_bytes, (long)po->flushed_bytes); if (po->outper(po->tmpspace, complete_bytes, po->op_key) < 0) - return -1; - if (po->nboff) po->tmpspace[0] = po->buffer[0]; + { + return -1; + } + if (po->nboff) + { + po->tmpspace[0] = po->buffer[0]; + } po->buffer = po->tmpspace; po->nbits = 8 * sizeof(po->tmpspace); po->flushed_bytes += complete_bytes; @@ -422,27 +513,40 @@ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) (int)bits, (int)po->nboff, (int)off, buf[0], (int)(omsk & 0xff), (int)(buf[0] & omsk)); - if (off <= 8) /* Completely within 1 byte */ - po->nboff = off, bits <<= (8 - off), buf[0] = (buf[0] & omsk) | bits; + if (off <= 8) + { /* Completely within 1 byte */ + po->nboff = off, bits <<= (8 - off), buf[0] = (buf[0] & omsk) | bits; + } else if (off <= 16) - po->nboff = off, bits <<= (16 - off), - buf[0] = (buf[0] & omsk) | (bits >> 8), buf[1] = bits; + { + po->nboff = off, bits <<= (16 - off), + buf[0] = (buf[0] & omsk) | (bits >> 8), buf[1] = bits; + } else if (off <= 24) - po->nboff = off, bits <<= (24 - off), - buf[0] = (buf[0] & omsk) | (bits >> 16), buf[1] = bits >> 8, - buf[2] = bits; + { + po->nboff = off, bits <<= (24 - off), + buf[0] = (buf[0] & omsk) | (bits >> 16), buf[1] = bits >> 8, + buf[2] = bits; + } else if (off <= 31) - po->nboff = off, bits <<= (32 - off), - buf[0] = (buf[0] & omsk) | (bits >> 24), buf[1] = bits >> 16, - buf[2] = bits >> 8, buf[3] = bits; + { + po->nboff = off, bits <<= (32 - off), + buf[0] = (buf[0] & omsk) | (bits >> 24), buf[1] = bits >> 16, + buf[2] = bits >> 8, buf[3] = bits; + } else { if ((obits - 24) > 0) { if (per_put_few_bits(po, bits >> (obits - 24), 24)) - return -1; + { + return -1; + } + } + if (per_put_few_bits(po, bits, obits - 24)) + { + return -1; } - if (per_put_few_bits(po, bits, obits - 24)) return -1; } ASN_DEBUG("[PER out %u/%x => %02x buf+%ld]", (int)bits, (int)bits, buf[0], @@ -465,15 +569,30 @@ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int nbits) value = (src[0] << 16) | (src[1] << 8) | src[2]; src += 3; nbits -= 24; - if (per_put_few_bits(po, value, 24)) return -1; + if (per_put_few_bits(po, value, 24)) + { + return -1; + } } else { value = src[0]; - if (nbits > 8) value = (value << 8) | src[1]; - if (nbits > 16) value = (value << 8) | src[2]; - if (nbits & 0x07) value >>= (8 - (nbits & 0x07)); - if (per_put_few_bits(po, value, nbits)) return -1; + if (nbits > 8) + { + value = (value << 8) | src[1]; + } + if (nbits > 16) + { + value = (value << 8) | src[2]; + } + if (nbits & 0x07) + { + value >>= (8 - (nbits & 0x07)); + } + if (per_put_few_bits(po, value, nbits)) + { + return -1; + } break; } } @@ -486,13 +605,20 @@ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int nbits) */ ssize_t uper_put_length(asn_per_outp_t *po, size_t length) { - if (length <= 127) /* #10.9.3.6 */ - return per_put_few_bits(po, length, 8) ? -1 : (ssize_t)length; - else if (length < 16384) /* #10.9.3.7 */ - return per_put_few_bits(po, length | 0x8000, 16) ? -1 : (ssize_t)length; + if (length <= 127) + { /* #10.9.3.6 */ + return per_put_few_bits(po, length, 8) ? -1 : (ssize_t)length; + } + else if (length < 16384) + { /* #10.9.3.7 */ + return per_put_few_bits(po, length | 0x8000, 16) ? -1 : (ssize_t)length; + } length >>= 14; - if (length > 4) length = 4; + if (length > 4) + { + length = 4; + } return per_put_few_bits(po, 0xC0 | length, 8) ? -1 : (ssize_t)(length << 14); @@ -508,7 +634,10 @@ int uper_put_nslength(asn_per_outp_t *po, size_t length) if (length <= 64) { /* #10.9.3.4 */ - if (length == 0) return -1; + if (length == 0) + { + return -1; + } return per_put_few_bits(po, length - 1, 7) ? -1 : 0; } else diff --git a/src/core/libs/supl/asn-rrlp/xer_decoder.c b/src/core/libs/supl/asn-rrlp/xer_decoder.c index a027b0d11..4d1e28a1f 100644 --- a/src/core/libs/supl/asn-rrlp/xer_decoder.c +++ b/src/core/libs/supl/asn-rrlp/xer_decoder.c @@ -72,7 +72,10 @@ ssize_t xer_next_token(int *stateContext, const void *buffer, size_t size, arg.callback_not_invoked = 1; ret = pxml_parse(&new_stateContext, buffer, size, xer__token_cb, &arg); - if (ret < 0) return -1; + if (ret < 0) + { + return -1; + } if (arg.callback_not_invoked) { assert(ret == 0); /* No data was consumed */ @@ -121,7 +124,9 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, if (size < 2 || buf[0] != LANGLE || buf[size - 1] != RANGLE) { if (size >= 2) - ASN_DEBUG("Broken XML tag: \"%c...%c\"", buf[0], buf[size - 1]); + { + ASN_DEBUG("Broken XML tag: \"%c...%c\"", buf[0], buf[size - 1]); + } return XCT_BROKEN; } @@ -134,7 +139,9 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, size -= 3; /* strip "" */ ct = XCT_CLOSING; if (size > 0 && buf[size - 1] == CSLASH) - return XCT_BROKEN; /* */ + { + return XCT_BROKEN; /* */ + } } else { @@ -148,7 +155,10 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, } /* Sometimes we don't care about the tag */ - if (!need_tag || !*need_tag) return (xer_check_tag_e)(XCT__UNK__MASK | ct); + if (!need_tag || !*need_tag) + { + return (xer_check_tag_e)(XCT__UNK__MASK | ct); + } /* * Determine the tag name. @@ -174,9 +184,15 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, } return (xer_check_tag_e)(XCT__UNK__MASK | ct); } - if (b == 0) return XCT_BROKEN; /* Embedded 0 in buf?! */ + if (b == 0) + { + return XCT_BROKEN; /* Embedded 0 in buf?! */ + } + } + if (*need_tag) + { + return (xer_check_tag_e)(XCT__UNK__MASK | ct); } - if (*need_tag) return (xer_check_tag_e)(XCT__UNK__MASK | ct); return ct; } @@ -246,7 +262,10 @@ asn_dec_rval_t xer_decode_general( * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. */ - if (ctx->phase > 1) RETURN(RC_FAIL); + if (ctx->phase > 1) + { + RETURN(RC_FAIL); + } for (;;) { pxer_chunk_type_e ch_type; /* XER chunk type */ @@ -305,19 +324,28 @@ asn_dec_rval_t xer_decode_general( switch (tcv) { case XCT_BOTH: - if (ctx->phase) break; + if (ctx->phase) + { + break; + } /* Finished decoding of an empty element */ XER_GOT_EMPTY(); ADVANCE(ch_size); ctx->phase = 2; /* Phase out */ RETURN(RC_OK); case XCT_OPENING: - if (ctx->phase) break; + if (ctx->phase) + { + break; + } ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; case XCT_CLOSING: - if (!ctx->phase) break; + if (!ctx->phase) + { + break; + } ADVANCE(ch_size); ctx->phase = 2; /* Phase out */ RETURN(RC_OK); @@ -397,7 +425,10 @@ int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth) return 0; case XCT_CLOSING: case XCT_UNKNOWN_CL: - if (--(*depth) == 0) return (tcv == XCT_CLOSING) ? 2 : 1; + if (--(*depth) == 0) + { + return (tcv == XCT_CLOSING) ? 2 : 1; + } return 0; default: return -1; diff --git a/src/core/libs/supl/asn-rrlp/xer_encoder.c b/src/core/libs/supl/asn-rrlp/xer_encoder.c index 584fbac1a..c04fd2dd7 100644 --- a/src/core/libs/supl/asn-rrlp/xer_encoder.c +++ b/src/core/libs/supl/asn-rrlp/xer_encoder.c @@ -19,7 +19,10 @@ asn_enc_rval_t xer_encode(asn_TYPE_descriptor_t *td, void *sptr, size_t mlen; int xcan = (xer_flags & XER_F_CANONICAL) ? 1 : 2; - if (!td || !sptr) goto cb_failed; + if (!td || !sptr) + { + goto cb_failed; + } mname = td->xml_tag; mlen = strlen(mname); @@ -27,7 +30,10 @@ asn_enc_rval_t xer_encode(asn_TYPE_descriptor_t *td, void *sptr, _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } _ASN_CALLBACK3("\n", xcan); @@ -46,7 +52,10 @@ static int xer__print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; - if (fwrite(buffer, 1, size, stream) != size) return -1; + if (fwrite(buffer, 1, size, stream) != size) + { + return -1; + } return 0; } @@ -55,11 +64,20 @@ int xer_fprint(FILE *stream, asn_TYPE_descriptor_t *td, void *sptr) { asn_enc_rval_t er; - if (!stream) stream = stdout; - if (!td || !sptr) return -1; + if (!stream) + { + stream = stdout; + } + if (!td || !sptr) + { + return -1; + } er = xer_encode(td, sptr, XER_F_BASIC, xer__print2fp, stream); - if (er.encoded == -1) return -1; + if (er.encoded == -1) + { + return -1; + } return fflush(stream); } diff --git a/src/core/libs/supl/asn-rrlp/xer_support.c b/src/core/libs/supl/asn-rrlp/xer_support.c index 1edf24f11..0ba225655 100644 --- a/src/core/libs/supl/asn-rrlp/xer_support.c +++ b/src/core/libs/supl/asn-rrlp/xer_support.c @@ -106,20 +106,28 @@ ssize_t pxml_parse(int *stateContext, const void *xmlbuf, size_t size, * Initial state: we're in the middle of some text, * or just have started. */ - if (C == LANGLE) /* We're now in the tag, probably */ - TOKEN_CB(PXML_TEXT, ST_TAG_START, 0); + if (C == LANGLE) + { /* We're now in the tag, probably */ + TOKEN_CB(PXML_TEXT, ST_TAG_START, 0); + } break; case ST_TAG_START: if (ALPHA(C) || (C == CSLASH)) - state = ST_TAG_BODY; + { + state = ST_TAG_BODY; + } else if (C == EXCLAM) - state = ST_COMMENT_WAIT_DASH1; + { + state = ST_COMMENT_WAIT_DASH1; + } else - /* + { + /* * Not characters and not whitespace. * Must be something like "3 < 4". */ - TOKEN_CB(PXML_TEXT, ST_TEXT, 1); /* Flush as data */ + TOKEN_CB(PXML_TEXT, ST_TEXT, 1); /* Flush as data */ + } break; case ST_TAG_BODY: switch (C) @@ -156,8 +164,10 @@ ssize_t pxml_parse(int *stateContext, const void *xmlbuf, size_t size, break; default: if (!WHITESPACE( - C)) /* Unquoted string value */ - state = ST_TAG_UNQUOTED_STRING; + C)) + { /* Unquoted string value */ + state = ST_TAG_UNQUOTED_STRING; + } } break; case ST_TAG_QUOTED_STRING: diff --git a/src/core/libs/supl/asn-supl/AltitudeInfo.c b/src/core/libs/supl/asn-supl/AltitudeInfo.c index ea1c7a15c..d64424115 100644 --- a/src/core/libs/supl/asn-supl/AltitudeInfo.c +++ b/src/core/libs/supl/asn-supl/AltitudeInfo.c @@ -32,7 +32,9 @@ static void altitudeDirection_2_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/BIT_STRING.c b/src/core/libs/supl/asn-supl/BIT_STRING.c index 6e958c1bf..8120db005 100644 --- a/src/core/libs/supl/asn-supl/BIT_STRING.c +++ b/src/core/libs/supl/asn-supl/BIT_STRING.c @@ -80,7 +80,10 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, uint8_t *buf; uint8_t *end; - if (!st || !st->buf) _ASN_ENCODE_FAILED; + if (!st || !st->buf) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -99,14 +102,20 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); p = scratch; - if (nline) _i_ASN_TEXT_INDENT(1, ilevel); + if (nline) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } } memcpy(p + 0, _bit_pattern[v >> 4], 4); memcpy(p + 4, _bit_pattern[v & 0x0f], 4); p += 8; } - if (!xcan && ((buf - st->buf) % 8) == 0) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan && ((buf - st->buf) % 8) == 0) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); p = scratch; @@ -116,12 +125,18 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int v = *buf; int ubits = st->bits_unused; int i; - for (i = 7; i >= ubits; i--) *p++ = (v & (1 << i)) ? 0x31 : 0x30; + for (i = 7; i >= ubits; i--) + { + *p++ = (v & (1 << i)) ? 0x31 : 0x30; + } er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -143,7 +158,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, (void)td; /* Unused argument */ - if (!st || !st->buf) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!st || !st->buf) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } ilevel++; buf = st->buf; @@ -158,7 +176,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, { _i_INDENT(1); /* Dump the string */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } p = scratch; } *p++ = h2c[*buf >> 4]; @@ -176,7 +197,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, } /* Dump the incomplete 16-bytes row */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } } return 0; diff --git a/src/core/libs/supl/asn-supl/BOOLEAN.c b/src/core/libs/supl/asn-supl/BOOLEAN.c index 57ae3ac29..cd7b62f2f 100644 --- a/src/core/libs/supl/asn-supl/BOOLEAN.c +++ b/src/core/libs/supl/asn-supl/BOOLEAN.c @@ -65,7 +65,10 @@ asn_dec_rval_t BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } ASN_DEBUG("Boolean length is %d bytes", (int)length); @@ -159,7 +162,9 @@ static enum xer_pbd_rval BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, case XCT_UNKNOWN_BO: if (xer_check_tag(chunk_buf, chunk_size, "true") != XCT_BOTH) - return XPBD_BROKEN_ENCODING; + { + return XPBD_BROKEN_ENCODING; + } /* "" */ *st = 1; /* Or 0xff as in DER?.. */ break; @@ -171,9 +176,13 @@ static enum xer_pbd_rval BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, else { if (xer_is_whitespace(chunk_buf, chunk_size)) - return XPBD_NOT_BODY_IGNORE; + { + return XPBD_NOT_BODY_IGNORE; + } else - return XPBD_BROKEN_ENCODING; + { + return XPBD_BROKEN_ENCODING; + } } } @@ -197,7 +206,10 @@ asn_enc_rval_t BOOLEAN_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, (void)ilevel; (void)flags; - if (!st) _ASN_ENCODE_FAILED; + if (!st) + { + _ASN_ENCODE_FAILED; + } if (*st) { @@ -269,7 +281,10 @@ asn_dec_rval_t BOOLEAN_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st))); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } /* @@ -304,7 +319,10 @@ asn_enc_rval_t BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td, (void)constraints; - if (!st) _ASN_ENCODE_FAILED; + if (!st) + { + _ASN_ENCODE_FAILED; + } per_put_few_bits(po, *st ? 1 : 0, 1); diff --git a/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c b/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c index e121f18f7..a36458612 100644 --- a/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c +++ b/src/core/libs/supl/asn-supl/CPICH-Ec-N0.c @@ -48,7 +48,9 @@ static void CPICH_Ec_N0_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/CPICH-RSCP.c b/src/core/libs/supl/asn-supl/CPICH-RSCP.c index 20dfe6ab8..585d563bc 100644 --- a/src/core/libs/supl/asn-supl/CPICH-RSCP.c +++ b/src/core/libs/supl/asn-supl/CPICH-RSCP.c @@ -48,7 +48,9 @@ static void CPICH_RSCP_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/CellParametersID.c b/src/core/libs/supl/asn-supl/CellParametersID.c index ff3d291d7..8123603fd 100644 --- a/src/core/libs/supl/asn-supl/CellParametersID.c +++ b/src/core/libs/supl/asn-supl/CellParametersID.c @@ -50,7 +50,9 @@ static void CellParametersID_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/DUMMY.c b/src/core/libs/supl/asn-supl/DUMMY.c index 313c5ed82..5c384ee87 100644 --- a/src/core/libs/supl/asn-supl/DUMMY.c +++ b/src/core/libs/supl/asn-supl/DUMMY.c @@ -29,7 +29,9 @@ static void DUMMY_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; + { + td->per_constraints = asn_DEF_INTEGER.per_constraints; + } td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; diff --git a/src/core/libs/supl/asn-supl/ENUMERATED.c b/src/core/libs/supl/asn-supl/ENUMERATED.c index dd0d13d9b..9f6739534 100644 --- a/src/core/libs/supl/asn-supl/ENUMERATED.c +++ b/src/core/libs/supl/asn-supl/ENUMERATED.c @@ -49,13 +49,21 @@ asn_dec_rval_t ENUMERATED_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st))); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } rval = NativeEnumerated_decode_uper(opt_codec_ctx, td, constraints, &vptr, pd); if (rval.code == RC_OK) - if (asn_long2INTEGER(st, value)) rval.code = RC_FAIL; + { + if (asn_long2INTEGER(st, value)) + { + rval.code = RC_FAIL; + } + } return rval; } @@ -66,7 +74,10 @@ asn_enc_rval_t ENUMERATED_encode_uper(asn_TYPE_descriptor_t *td, ENUMERATED_t *st = (ENUMERATED_t *)sptr; int64_t value; - if (asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED; + if (asn_INTEGER2long(st, &value)) + { + _ASN_ENCODE_FAILED; + } return NativeEnumerated_encode_uper(td, constraints, &value, po); } diff --git a/src/core/libs/supl/asn-supl/EncodingType.c b/src/core/libs/supl/asn-supl/EncodingType.c index 1ab40a547..d3988e383 100644 --- a/src/core/libs/supl/asn-supl/EncodingType.c +++ b/src/core/libs/supl/asn-supl/EncodingType.c @@ -30,7 +30,9 @@ static void EncodingType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/FQDN.c b/src/core/libs/supl/asn-supl/FQDN.c index ff18a4dfd..236560db7 100644 --- a/src/core/libs/supl/asn-supl/FQDN.c +++ b/src/core/libs/supl/asn-supl/FQDN.c @@ -102,7 +102,10 @@ static int check_permitted_alphabet_1(const void *sptr) for (; ch < end; ch++) { uint8_t cv = *ch; - if (!table[cv]) return -1; + if (!table[cv]) + { + return -1; + } } return 0; } @@ -139,14 +142,18 @@ static int asn_PER_MAP_FQDN_1_v2c(unsigned int value) { if (value >= sizeof(permitted_alphabet_table_1) / sizeof(permitted_alphabet_table_1[0])) - return -1; + { + return -1; + } return permitted_alphabet_table_1[value] - 1; } static int asn_PER_MAP_FQDN_1_c2v(unsigned int code) { if (code >= sizeof(permitted_alphabet_code2value_1) / sizeof(permitted_alphabet_code2value_1[0])) - return -1; + { + return -1; + } return permitted_alphabet_code2value_1[code]; } /* @@ -164,7 +171,9 @@ static void FQDN_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_VisibleString.uper_decoder; td->uper_encoder = asn_DEF_VisibleString.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_VisibleString.per_constraints; + { + td->per_constraints = asn_DEF_VisibleString.per_constraints; + } td->elements = asn_DEF_VisibleString.elements; td->elements_count = asn_DEF_VisibleString.elements_count; td->specifics = asn_DEF_VisibleString.specifics; diff --git a/src/core/libs/supl/asn-supl/FormatIndicator.c b/src/core/libs/supl/asn-supl/FormatIndicator.c index 276be3210..87e93a202 100644 --- a/src/core/libs/supl/asn-supl/FormatIndicator.c +++ b/src/core/libs/supl/asn-supl/FormatIndicator.c @@ -30,7 +30,9 @@ static void FormatIndicator_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/GeneralizedTime.c b/src/core/libs/supl/asn-supl/GeneralizedTime.c index 60f36b6e0..bd271f336 100644 --- a/src/core/libs/supl/asn-supl/GeneralizedTime.c +++ b/src/core/libs/supl/asn-supl/GeneralizedTime.c @@ -246,11 +246,16 @@ asn_enc_rval_t GeneralizedTime_encode_der(asn_TYPE_descriptor_t *td, void *sptr, errno = EPERM; tloc = asn_GT2time_frac(st, &fv, &fd, &tm, 1); /* Recognize time */ if (tloc == -1 && errno != EPERM) - /* Failed to recognize time. Fail completely. */ - _ASN_ENCODE_FAILED; + { + /* Failed to recognize time. Fail completely. */ + _ASN_ENCODE_FAILED; + } st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */ - if (!st) _ASN_ENCODE_FAILED; /* Memory allocation failure. */ + if (!st) + { + _ASN_ENCODE_FAILED; /* Memory allocation failure. */ + } erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key); @@ -280,10 +285,15 @@ asn_enc_rval_t GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if (asn_GT2time_frac((GeneralizedTime_t *)sptr, &fv, &fd, &tm, 1) == -1 && errno != EPERM) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } gt = asn_time2GT_frac(0, &tm, fv, fd, 1); - if (!gt) _ASN_ENCODE_FAILED; + if (!gt) + { + _ASN_ENCODE_FAILED; + } rv = OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags, cb, app_key); @@ -316,7 +326,9 @@ int GeneralizedTime_print(asn_TYPE_descriptor_t *td, const void *sptr, errno = EPERM; if (asn_GT2time(st, &tm, 1) == -1 && errno != EPERM) - return (cb("", 11, app_key) < 0) ? -1 : 0; + { + return (cb("", 11, app_key) < 0) ? -1 : 0; + } ret = snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d (GMT)", @@ -344,16 +356,23 @@ time_t asn_GT2time_prec(const GeneralizedTime_t *st, int *frac_value, int fd = 0; if (frac_value) - tloc = asn_GT2time_frac(st, &fv, &fd, ret_tm, as_gmt); + { + tloc = asn_GT2time_frac(st, &fv, &fd, ret_tm, as_gmt); + } else - return asn_GT2time_frac(st, 0, 0, ret_tm, as_gmt); + { + return asn_GT2time_frac(st, 0, 0, ret_tm, as_gmt); + } if (fd == 0 || frac_digits <= 0) { *frac_value = 0; } else { - while (fd > frac_digits) fv /= 10, fd--; + while (fd > frac_digits) + { + fv /= 10, fd--; + } while (fd < frac_digits) { int new_fv = fv * 10; @@ -438,7 +457,10 @@ time_t asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, B2T(tm_hour); /* 9: h */ B2T(tm_hour); /* 0: h */ - if (buf == end) goto local_finish; + if (buf == end) + { + goto local_finish; + } /* * Parse [mm[ss[(.|,)ffff]]] @@ -474,7 +496,10 @@ time_t asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, return -1; } - if (buf == end) goto local_finish; + if (buf == end) + { + goto local_finish; + } /* * Parse [mm[ss[(.|,)ffff]]] @@ -510,7 +535,10 @@ time_t asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, return -1; } - if (buf == end) goto local_finish; + if (buf == end) + { + goto local_finish; + } /* * Parse [mm[ss[(.|,)ffff]]] @@ -557,7 +585,10 @@ time_t asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, } } - if (buf == end) goto local_finish; + if (buf == end) + { + goto local_finish; + } switch (*buf) { @@ -581,10 +612,14 @@ offset: buf++; B2F(gmtoff_h); B2F(gmtoff_h); - if (buf[-3] == 0x2D) /* Negative */ - gmtoff = -1; + if (buf[-3] == 0x2D) + { /* Negative */ + gmtoff = -1; + } else - gmtoff = 1; + { + gmtoff = 1; + } if ((end - buf) == 2) { @@ -674,8 +709,14 @@ local_finish: } /* Fractions of seconds */ - if (frac_value) *frac_value = fvalue; - if (frac_digits) *frac_digits = fdigits; + if (frac_value) + { + *frac_value = fvalue; + } + if (frac_digits) + { + *frac_digits = fdigits; + } return tloc; } @@ -711,7 +752,10 @@ GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *opt_gt, /* Pre-allocate a buffer of sufficient yet small length */ buf = (char *)MALLOC(buf_size); - if (!buf) return 0; + if (!buf) + { + return 0; + } gmtoff = GMTOFF(*tm); @@ -752,10 +796,16 @@ GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *opt_gt, *z++ = '.'; /* Place bounds on precision */ - while (frac_digits-- > 6) frac_value /= 10; + while (frac_digits-- > 6) + { + frac_value /= 10; + } /* emulate fbase = pow(10, frac_digits) */ - for (fbase = 1; frac_digits--;) fbase *= 10; + for (fbase = 1; frac_digits--;) + { + fbase *= 10; + } do { @@ -773,7 +823,9 @@ GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *opt_gt, if (z) { for (--z; *z == 0x30; --z) - ; /* Strip zeroes */ + { + ; /* Strip zeroes */ + } p = z + (*z != '.'); size = p - buf; } @@ -802,7 +854,10 @@ GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *opt_gt, if (opt_gt) { - if (opt_gt->buf) FREEMEM(opt_gt->buf); + if (opt_gt->buf) + { + FREEMEM(opt_gt->buf); + } } else { diff --git a/src/core/libs/supl/asn-supl/INTEGER.c b/src/core/libs/supl/asn-supl/INTEGER.c index 65878c16c..7c1b25b6b 100644 --- a/src/core/libs/supl/asn-supl/INTEGER.c +++ b/src/core/libs/supl/asn-supl/INTEGER.c @@ -72,10 +72,16 @@ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr, switch (*buf) { case 0x00: - if ((buf[1] & 0x80) == 0) continue; + if ((buf[1] & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((buf[1] & 0x80)) continue; + if ((buf[1] & 0x80)) + { + continue; + } break; } break; @@ -91,7 +97,10 @@ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr, st->size -= shift; /* New size, minus bad bytes */ end = nb + st->size; - for (; nb < end; nb++, buf++) *nb = *buf; + for (; nb < end; nb++, buf++) + { + *nb = *buf; + } } } /* if(1) */ @@ -130,10 +139,16 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, switch (*buf) { case 0x00: - if ((buf[1] & 0x80) == 0) continue; + if ((buf[1] & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((buf[1] & 0x80) != 0) continue; + if ((buf[1] & 0x80) != 0) + { + continue; + } break; } break; @@ -153,7 +168,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, else { accum = (*buf & 0x80) ? -1LL : 0LL; - for (; buf < buf_end; buf++) accum = (accum * 256) | *buf; + for (; buf < buf_end; buf++) + { + accum = (accum * 256) | *buf; + } } el = INTEGER_map_value2enum(specs, accum); @@ -162,10 +180,14 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, scrsize = el->enum_len + 32; scr = (char *)alloca(scrsize); if (plainOrXER == 0) - ret = snprintf(scr, scrsize, "%+" PRId64 "(%s)", accum, - el->enum_name); + { + ret = snprintf(scr, scrsize, "%+" PRId64 "(%s)", accum, + el->enum_name); + } else - ret = snprintf(scr, scrsize, "<%s/>", el->enum_name); + { + ret = snprintf(scr, scrsize, "<%s/>", el->enum_name); + } } else if (plainOrXER && specs && specs->strict_enumeration) { @@ -209,7 +231,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, if ((p - scratch) >= (ssize_t)(sizeof(scratch) - 4)) { /* Flush buffer */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } wrote += p - scratch; p = scratch; } @@ -217,7 +242,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, *p++ = h2c[*buf & 0x0F]; *p++ = 0x3a; /* ":" */ } - if (p != scratch) p--; /* Remove the last ":" */ + if (p != scratch) + { + p--; /* Remove the last ":" */ + } wrote += p - scratch; return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote; @@ -236,9 +264,13 @@ int INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, (void)ilevel; if (!st || !st->buf) - ret = cb("", 8, app_key); + { + ret = cb("", 8, app_key); + } else - ret = INTEGER__dump(td, st, cb, app_key, 0); + { + ret = INTEGER__dump(td, st, cb, app_key, 0); + } return (ret < 0) ? -1 : 0; } @@ -266,8 +298,10 @@ static int INTEGER__compar_enum2value(const void *kp, const void *am) ptr++, name++) { if (*ptr != *name) - return *(const unsigned char *)ptr - - *(const unsigned char *)name; + { + return *(const unsigned char *)ptr - + *(const unsigned char *)name; + } } return name[0] ? -1 : 0; } @@ -280,7 +314,10 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value( struct e2v_key key; const char *lp; - if (!count) return NULL; + if (!count) + { + return NULL; + } /* Guaranteed: assert(lstart < lstop); */ /* Figure out the tag name */ @@ -302,7 +339,10 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value( } break; } - if (lp == lstop) return NULL; /* No tag found */ + if (lp == lstop) + { + return NULL; /* No tag found */ + } lstop = lp; key.start = lstart; @@ -326,18 +366,27 @@ static int INTEGER__compar_value2enum(const void *kp, const void *am) const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am; int64_t b = el->nat_value; if (a < b) - return -1; + { + return -1; + } else if (a == b) - return 0; + { + return 0; + } else - return 1; + { + return 1; + } } const asn_INTEGER_enum_map_t *INTEGER_map_value2enum( asn_INTEGER_specifics_t *specs, int64_t value) { int count = specs ? specs->map_count : 0; - if (!count) return 0; + if (!count) + { + return 0; + } return (asn_INTEGER_enum_map_t *)bsearch(&value, specs->value2enum, count, sizeof(specs->value2enum[0]), INTEGER__compar_value2enum); @@ -387,8 +436,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, } state = ST_SKIPSPACE; if (chunk_size) - ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (int64_t)chunk_size, *lstart, - lstop[-1]); + { + ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (int64_t)chunk_size, *lstart, + lstop[-1]); + } /* * We may have received a tag here. It will be processed inline. @@ -468,8 +519,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, { int64_t new_value = value * 10; - if (new_value / 10 != value) /* Overflow */ - return XPBD_DECODER_LIMIT; + if (new_value / 10 != value) + { /* Overflow */ + return XPBD_DECODER_LIMIT; + } value = new_value + (lv - 0x30); /* Check for two's complement overflow */ @@ -524,7 +577,9 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, ASN_DEBUG("INTEGER re-evaluate as hex form"); if (INTEGER_st_prealloc(st, (chunk_size / 3) + 1)) - return XPBD_SYSTEM_FAILURE; + { + return XPBD_SYSTEM_FAILURE; + } state = ST_SKIPSPHEX; lp = lstart - 1; continue; @@ -568,7 +623,9 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, "INTEGER re-evaluate as hex form"); if (INTEGER_st_prealloc( st, (chunk_size / 3) + 1)) - return XPBD_SYSTEM_FAILURE; + { + return XPBD_SYSTEM_FAILURE; + } state = ST_SKIPSPHEX; lp = lstart - 1; continue; @@ -599,7 +656,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, default: if (xer_is_whitespace(lp, lstop - lp)) { - if (state != ST_EXTRASTUFF) return XPBD_NOT_BODY_IGNORE; + if (state != ST_EXTRASTUFF) + { + return XPBD_NOT_BODY_IGNORE; + } break; } else @@ -613,7 +673,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, value *= sign; /* Change sign, if needed */ - if (asn_long2INTEGER(st, value)) return XPBD_SYSTEM_FAILURE; + if (asn_long2INTEGER(st, value)) + { + return XPBD_SYSTEM_FAILURE; + } return XPBD_BODY_CONSUMED; } @@ -638,10 +701,16 @@ asn_enc_rval_t INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, (void)ilevel; (void)flags; - if (!st || !st->buf) _ASN_ENCODE_FAILED; + if (!st || !st->buf) + { + _ASN_ENCODE_FAILED; + } er.encoded = INTEGER__dump(td, st, cb, app_key, 1); - if (er.encoded < 0) _ASN_ENCODE_FAILED; + if (er.encoded < 0) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -662,17 +731,29 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st))); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } - if (!constraints) constraints = td->per_constraints; + if (!constraints) + { + constraints = td->per_constraints; + } ct = constraints ? &constraints->value : 0; if (ct && ct->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); - if (inext < 0) _ASN_DECODE_STARVED; - if (inext) ct = 0; + if (inext < 0) + { + _ASN_DECODE_STARVED; + } + if (inext) + { + ct = 0; + } } FREEMEM(st->buf); @@ -683,14 +764,20 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (ct->flags & APC_SEMI_CONSTRAINED) { st->buf = (uint8_t *)CALLOC(1, 2); - if (!st->buf) _ASN_DECODE_FAILED; + if (!st->buf) + { + _ASN_DECODE_FAILED; + } st->size = 1; } else if (ct->flags & APC_CONSTRAINED && ct->range_bits >= 0) { size_t size = (ct->range_bits + 7) >> 3; st->buf = (uint8_t *)MALLOC(1 + size + 1); - if (!st->buf) _ASN_DECODE_FAILED; + if (!st->buf) + { + _ASN_DECODE_FAILED; + } st->size = size; } } @@ -707,15 +794,24 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, { int64_t lhalf; value = per_get_few_bits(pd, 16); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } lhalf = per_get_few_bits(pd, 16); - if (lhalf < 0) _ASN_DECODE_STARVED; + if (lhalf < 0) + { + _ASN_DECODE_STARVED; + } value = (value << 16) | lhalf; } else { value = per_get_few_bits(pd, ct->range_bits); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } } ASN_DEBUG("Got value %ld + low %ld", value, ct->lower_bound); @@ -723,7 +819,9 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(st, value) : asn_long2INTEGER(st, value)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } return rval; } } @@ -741,14 +839,23 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, /* Get the PER length */ len = uper_get_length(pd, -1, &repeat); - if (len < 0) _ASN_DECODE_STARVED; + if (len < 0) + { + _ASN_DECODE_STARVED; + } p = REALLOC(st->buf, st->size + len + 1); - if (!p) _ASN_DECODE_FAILED; + if (!p) + { + _ASN_DECODE_FAILED; + } st->buf = (uint8_t *)p; ret = per_get_many_bits(pd, &st->buf[st->size], 0, 8 * len); - if (ret < 0) _ASN_DECODE_STARVED; + if (ret < 0) + { + _ASN_DECODE_STARVED; + } st->size += len; } while (repeat); @@ -761,9 +868,14 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, * TODO: replace by in-place arithmetics. */ int64_t value; - if (asn_INTEGER2long(st, &value)) _ASN_DECODE_FAILED; + if (asn_INTEGER2long(st, &value)) + { + _ASN_DECODE_FAILED; + } if (asn_long2INTEGER(st, value + ct->lower_bound)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } } return rval; @@ -781,9 +893,15 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraint_t *ct; int64_t value = 0; - if (!st || st->size == 0) _ASN_ENCODE_FAILED; + if (!st || st->size == 0) + { + _ASN_ENCODE_FAILED; + } - if (!constraints) constraints = td->per_constraints; + if (!constraints) + { + constraints = td->per_constraints; + } ct = constraints ? &constraints->value : 0; er.encoded = 0; @@ -794,17 +912,25 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, if (specs && specs->field_unsigned) { uint64_t uval; - if (asn_INTEGER2ulong(st, &uval)) _ASN_ENCODE_FAILED; + if (asn_INTEGER2ulong(st, &uval)) + { + _ASN_ENCODE_FAILED; + } /* Check proper range */ if (ct->flags & APC_SEMI_CONSTRAINED) { - if (uval < (uint64_t)ct->lower_bound) inext = 1; + if (uval < (uint64_t)ct->lower_bound) + { + inext = 1; + } } else if (ct->range_bits >= 0) { if (uval < (uint64_t)ct->lower_bound || uval > (uint64_t)ct->upper_bound) - inext = 1; + { + inext = 1; + } } ASN_DEBUG("Value %lu (%02x/%d) lb %lu ub %lu %s", uval, st->buf[0], st->size, ct->lower_bound, @@ -813,17 +939,25 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, } else { - if (asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED; + if (asn_INTEGER2long(st, &value)) + { + _ASN_ENCODE_FAILED; + } /* Check proper range */ if (ct->flags & APC_SEMI_CONSTRAINED) { - if (value < ct->lower_bound) inext = 1; + if (value < ct->lower_bound) + { + inext = 1; + } } else if (ct->range_bits >= 0) { if (value < ct->lower_bound || value > ct->upper_bound) - inext = 1; + { + inext = 1; + } } ASN_DEBUG("Value %ld (%02x/%d) lb %ld ub %ld %s", value, st->buf[0], st->size, ct->lower_bound, @@ -831,8 +965,14 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, } if (ct->flags & APC_EXTENSIBLE) { - if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; - if (inext) ct = 0; + if (per_put_few_bits(po, inext, 1)) + { + _ASN_ENCODE_FAILED; + } + if (inext) + { + ct = 0; + } } else if (inext) { @@ -851,13 +991,17 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, int64_t v = value - ct->lower_bound; if (per_put_few_bits(po, v >> 1, 31) || per_put_few_bits(po, v, 1)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } else { if (per_put_few_bits(po, value - ct->lower_bound, ct->range_bits)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } _ASN_ENCODED_OK(er); } @@ -872,8 +1016,14 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, for (buf = st->buf, end = st->buf + st->size; buf < end;) { ssize_t mayEncode = uper_put_length(po, end - buf); - if (mayEncode < 0) _ASN_ENCODE_FAILED; - if (per_put_many_bits(po, buf, 8 * mayEncode)) _ASN_ENCODE_FAILED; + if (mayEncode < 0) + { + _ASN_ENCODE_FAILED; + } + if (per_put_many_bits(po, buf, 8 * mayEncode)) + { + _ASN_ENCODE_FAILED; + } buf += mayEncode; } @@ -914,10 +1064,16 @@ int asn_INTEGER2long(const INTEGER_t *iptr, int64_t *lptr) switch (*b) { case 0x00: - if ((b[1] & 0x80) == 0) continue; + if ((b[1] & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((b[1] & 0x80) != 0) continue; + if ((b[1] & 0x80) != 0) + { + continue; + } break; } break; @@ -942,12 +1098,19 @@ int asn_INTEGER2long(const INTEGER_t *iptr, int64_t *lptr) /* Perform the sign initialization */ /* Actually l = -(*b >> 7); gains nothing, yet unreadable! */ if ((*b >> 7)) - l = -1; + { + l = -1; + } else - l = 0; + { + l = 0; + } /* Conversion engine */ - for (; b < end; b++) l = (l * 256) | *b; + for (; b < end; b++) + { + l = (l * 256) | *b; + } *lptr = l; return 0; @@ -982,7 +1145,10 @@ int asn_INTEGER2ulong(const INTEGER_t *iptr, uint64_t *lptr) } /* Conversion engine */ - for (l = 0; b < end; b++) l = (l << 8) | *b; + for (l = 0; b < end; b++) + { + l = (l << 8) | *b; + } *lptr = l; return 0; @@ -995,17 +1161,28 @@ int asn_ulong2INTEGER(INTEGER_t *st, uint64_t value) uint8_t *b; int shr; - if (value <= LONG_MAX) return asn_long2INTEGER(st, value); + if (value <= LONG_MAX) + { + return asn_long2INTEGER(st, value); + } buf = (uint8_t *)MALLOC(1 + sizeof(value)); - if (!buf) return -1; + if (!buf) + { + return -1; + } end = buf + (sizeof(value) + 1); buf[0] = 0; for (b = buf + 1, shr = (sizeof(int64_t) - 1) * 8; b < end; shr -= 8, b++) - *b = (uint8_t)(value >> shr); + { + *b = (uint8_t)(value >> shr); + } - if (st->buf) FREEMEM(st->buf); + if (st->buf) + { + FREEMEM(st->buf); + } st->buf = buf; st->size = 1 + sizeof(value); @@ -1029,7 +1206,10 @@ int asn_long2INTEGER(INTEGER_t *st, int64_t value) } buf = (uint8_t *)MALLOC(8); - if (!buf) return -1; + if (!buf) + { + return -1; + } if (*(char *)&littleEndian) { @@ -1055,18 +1235,30 @@ int asn_long2INTEGER(INTEGER_t *st, int64_t value) switch (*p) { case 0x00: - if ((*(p + add) & 0x80) == 0) continue; + if ((*(p + add) & 0x80) == 0) + { + continue; + } break; case 0xff: - if ((*(p + add) & 0x80)) continue; + if ((*(p + add) & 0x80)) + { + continue; + } break; } break; } /* Copy the integer body */ - for (pstart = p, bp = buf, pend1 += add; p != pend1; p += add) *bp++ = *p; + for (pstart = p, bp = buf, pend1 += add; p != pend1; p += add) + { + *bp++ = *p; + } - if (st->buf) FREEMEM(st->buf); + if (st->buf) + { + FREEMEM(st->buf); + } st->buf = buf; st->size = bp - buf; diff --git a/src/core/libs/supl/asn-supl/KeyIdentity.c b/src/core/libs/supl/asn-supl/KeyIdentity.c index 344696cf1..2ca1a1d29 100644 --- a/src/core/libs/supl/asn-supl/KeyIdentity.c +++ b/src/core/libs/supl/asn-supl/KeyIdentity.c @@ -57,7 +57,9 @@ static void KeyIdentity_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-supl/KeyIdentity4.c b/src/core/libs/supl/asn-supl/KeyIdentity4.c index 9c4533021..116adabf0 100644 --- a/src/core/libs/supl/asn-supl/KeyIdentity4.c +++ b/src/core/libs/supl/asn-supl/KeyIdentity4.c @@ -58,7 +58,9 @@ static void KeyIdentity4_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-supl/MAC.c b/src/core/libs/supl/asn-supl/MAC.c index 2de0aaf7d..0ba1cf81e 100644 --- a/src/core/libs/supl/asn-supl/MAC.c +++ b/src/core/libs/supl/asn-supl/MAC.c @@ -57,7 +57,9 @@ static void MAC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-supl/NativeEnumerated.c b/src/core/libs/supl/asn-supl/NativeEnumerated.c index 1f6394e52..a673a7858 100644 --- a/src/core/libs/supl/asn-supl/NativeEnumerated.c +++ b/src/core/libs/supl/asn-supl/NativeEnumerated.c @@ -56,7 +56,10 @@ asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, (void)ilevel; (void)flags; - if (!native) _ASN_ENCODE_FAILED; + if (!native) + { + _ASN_ENCODE_FAILED; + } el = INTEGER_map_value2enum(specs, *native); if (el) @@ -66,7 +69,10 @@ asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name); assert(er.encoded > 0 && (size_t)er.encoded < srcsize); - if (cb(src, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED; + if (cb(src, er.encoded, app_key) < 0) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } else @@ -92,17 +98,29 @@ asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx, (void)opt_codec_ctx; if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - _ASN_DECODE_FAILED; /* Mandatory! */ - if (!specs) _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; /* Mandatory! */ + } + if (!specs) + { + _ASN_DECODE_FAILED; + } if (!native) { native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if (!native) _ASN_DECODE_FAILED; + if (!native) + { + _ASN_DECODE_FAILED; + } } ASN_DEBUG("Decoding %s as NativeEnumerated", td->name); @@ -110,28 +128,48 @@ asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (ct->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); - if (inext < 0) _ASN_DECODE_STARVED; - if (inext) ct = 0; + if (inext < 0) + { + _ASN_DECODE_STARVED; + } + if (inext) + { + ct = 0; + } } if (ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } if (value >= (specs->extension ? specs->extension - 1 : specs->map_count)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } } else { - if (!specs->extension) _ASN_DECODE_FAILED; + if (!specs->extension) + { + _ASN_DECODE_FAILED; + } /* * X.691, #10.6: normally small non-negative whole number; */ value = uper_get_nsnnwn(pd); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } value += specs->extension - 1; - if (value >= specs->map_count) _ASN_DECODE_FAILED; + if (value >= specs->map_count) + { + _ASN_DECODE_FAILED; + } } *native = specs->value2enum[value].nat_value; @@ -144,8 +182,14 @@ static int NativeEnumerated__compar_value2enum(const void *ap, const void *bp) { const asn_INTEGER_enum_map_t *a = ap; const asn_INTEGER_enum_map_t *b = bp; - if (a->nat_value == b->nat_value) return 0; - if (a->nat_value < b->nat_value) return -1; + if (a->nat_value == b->nat_value) + { + return 0; + } + if (a->nat_value < b->nat_value) + { + return -1; + } return 1; } @@ -162,22 +206,37 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, asn_INTEGER_enum_map_t key; asn_INTEGER_enum_map_t *kf; - if (!sptr) _ASN_ENCODE_FAILED; - if (!specs) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } + if (!specs) + { + _ASN_ENCODE_FAILED; + } if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - _ASN_ENCODE_FAILED; /* Mandatory! */ + { + _ASN_ENCODE_FAILED; /* Mandatory! */ + } ASN_DEBUG("Encoding %s as NativeEnumerated", td->name); er.encoded = 0; native = *(long *)sptr; - if (native < 0) _ASN_ENCODE_FAILED; + if (native < 0) + { + _ASN_ENCODE_FAILED; + } key.nat_value = native; kf = bsearch(&key, specs->value2enum, specs->map_count, sizeof(key), @@ -193,12 +252,21 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, { int cmpWith = specs->extension ? specs->extension - 1 : specs->map_count; - if (value >= cmpWith) inext = 1; + if (value >= cmpWith) + { + inext = 1; + } } if (ct->flags & APC_EXTENSIBLE) { - if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; - if (inext) ct = 0; + if (per_put_few_bits(po, inext, 1)) + { + _ASN_ENCODE_FAILED; + } + if (inext) + { + ct = 0; + } } else if (inext) { @@ -207,11 +275,17 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, if (ct && ct->range_bits >= 0) { - if (per_put_few_bits(po, value, ct->range_bits)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, value, ct->range_bits)) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } - if (!specs->extension) _ASN_ENCODE_FAILED; + if (!specs->extension) + { + _ASN_ENCODE_FAILED; + } /* * X.691, #10.6: normally small non-negative whole number; @@ -220,7 +294,9 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, specs->extension, inext, value - (inext ? (specs->extension - 1) : 0)); if (uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0))) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } diff --git a/src/core/libs/supl/asn-supl/NativeInteger.c b/src/core/libs/supl/asn-supl/NativeInteger.c index 8d6b14b27..cf2ba8e8e 100644 --- a/src/core/libs/supl/asn-supl/NativeInteger.c +++ b/src/core/libs/supl/asn-supl/NativeInteger.c @@ -75,7 +75,10 @@ asn_dec_rval_t NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } ASN_DEBUG("%s length is %d bytes", td->name, (int)length); @@ -153,7 +156,9 @@ asn_enc_rval_t NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, /* Prepare a fake INTEGER */ for (p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) - *p = (uint8_t)native; + { + *p = (uint8_t)native; + } tmp.buf = buf; tmp.size = sizeof(buf); @@ -186,7 +191,10 @@ asn_dec_rval_t NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (!native) { native = (int64_t *)(*sptr = CALLOC(1, sizeof(*native))); - if (!native) _ASN_DECODE_FAILED; + if (!native) + { + _ASN_DECODE_FAILED; + } } memset(&st, 0, sizeof(st)); @@ -234,14 +242,19 @@ asn_enc_rval_t NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, (void)ilevel; (void)flags; - if (!native) _ASN_ENCODE_FAILED; + if (!native) + { + _ASN_ENCODE_FAILED; + } er.encoded = snprintf(scratch, sizeof(scratch), (specs && specs->field_unsigned) ? "%lu" : "%ld", *native); if (er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) || cb(scratch, er.encoded, app_key) < 0) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -263,7 +276,10 @@ asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!native) { native = (int64_t *)(*sptr = CALLOC(1, sizeof(*native))); - if (!native) _ASN_DECODE_FAILED; + if (!native) + { + _ASN_DECODE_FAILED; + } } memset(&tmpint, 0, sizeof tmpint); @@ -273,9 +289,13 @@ asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if ((specs && specs->field_unsigned) ? asn_INTEGER2ulong(&tmpint, (uint64_t *)native) : asn_INTEGER2long(&tmpint, native)) - rval.code = RC_FAIL; + { + rval.code = RC_FAIL; + } else - ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native); + { + ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native); + } } ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); @@ -291,7 +311,10 @@ asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, long native; INTEGER_t tmpint; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } native = *(long *)sptr; @@ -300,7 +323,9 @@ asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, memset(&tmpint, 0, sizeof(tmpint)); if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native) : asn_long2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } er = INTEGER_encode_uper(td, constraints, &tmpint, po); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); return er; @@ -336,7 +361,10 @@ int NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, void NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - if (!td || !ptr) return; + if (!td || !ptr) + { + return; + } ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", td->name, contents_only, ptr); diff --git a/src/core/libs/supl/asn-supl/NotificationType.c b/src/core/libs/supl/asn-supl/NotificationType.c index 5681ee170..ffcb4578b 100644 --- a/src/core/libs/supl/asn-supl/NotificationType.c +++ b/src/core/libs/supl/asn-supl/NotificationType.c @@ -31,7 +31,9 @@ static void NotificationType_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/OCTET_STRING.c b/src/core/libs/supl/asn-supl/OCTET_STRING.c index b092caadf..000c043a7 100644 --- a/src/core/libs/supl/asn-supl/OCTET_STRING.c +++ b/src/core/libs/supl/asn-supl/OCTET_STRING.c @@ -156,7 +156,10 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st) else { nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el)); - if (nel == NULL) return NULL; + if (nel == NULL) + { + return NULL; + } if (st->tail) { @@ -209,7 +212,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (st == NULL) { st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); - if (st == NULL) RETURN(RC_FAIL); + if (st == NULL) + { + RETURN(RC_FAIL); + } } /* Restore parsing context */ @@ -223,7 +229,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, ctx, buf_ptr, size, tag_mode, -1, &ctx->left, &tlv_constr); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } if (tlv_constr) { @@ -247,7 +256,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, */ _CH_PHASE(ctx, 3); if (type_variant == ASN_OSUBV_ANY && tag_mode != 1) - APPEND(buf_ptr, rval.consumed); + { + APPEND(buf_ptr, rval.consumed); + } ADVANCE(rval.consumed); goto phase3; } @@ -286,12 +297,17 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (prev->left != -1) { if (prev->left < sel->got) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } prev->left -= sel->got; } prev->got += sel->got; sel = stck->cur_ptr = prev; - if (!sel) break; + if (!sel) + { + break; + } tlv_constr = 1; continue; } @@ -344,7 +360,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (type_variant == ASN_OSUBV_ANY && (tag_mode != 1 || sel->cont_level)) - APPEND("\0\0", 2); + { + APPEND("\0\0", 2); + } ADVANCE(2); sel->got += 2; @@ -430,7 +448,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, * Append a new expectation. */ sel = OS__add_stack_el(stck); - if (!sel) RETURN(RC_FAIL); + if (!sel) + { + RETURN(RC_FAIL); + } sel->tag = tlv_tag; @@ -440,11 +461,17 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, /* Check that the parent frame is big enough */ if (sel->prev->left < tlvl + (tlv_len == -1 ? 0 : tlv_len)) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } if (tlv_len == -1) - sel->left = sel->prev->left - tlvl; + { + sel->left = sel->prev->left - tlvl; + } else - sel->left = tlv_len; + { + sel->left = tlv_len; + } } else { @@ -452,7 +479,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if (type_variant == ASN_OSUBV_ANY && (tag_mode != 1 || sel->cont_level)) - APPEND(buf_ptr, tlvl); + { + APPEND(buf_ptr, tlvl); + } sel->got += tlvl; ADVANCE(tlvl); @@ -526,7 +555,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (size < (size_t)ctx->left) { - if (!size) RETURN(RC_WMORE); + if (!size) + { + RETURN(RC_WMORE); + } if (type_variant == ASN_OSUBV_BIT && !ctx->context) { st->bits_unused = *(const uint8_t *)buf_ptr; @@ -638,7 +670,10 @@ asn_enc_rval_t OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr, if (type_variant == ASN_OSUBV_BIT) { uint8_t b = st->bits_unused & 0x07; - if (b && st->size) fix_last_byte = 1; + if (b && st->size) + { + fix_last_byte = 1; + } _ASN_CALLBACK(&b, 1); er.encoded++; } @@ -674,7 +709,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, uint8_t *end; size_t i; - if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; + if (!st || (!st->buf && st->size)) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -721,7 +759,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, p--; /* Remove the tail space */ _ASN_CALLBACK(scratch, p - scratch); /* Dump the rest */ er.encoded += p - scratch; - if (st->size > 16) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (st->size > 16) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } } } @@ -818,7 +859,9 @@ static int OS__check_escaped_control_char(const void *buf, int size) struct OCTET_STRING__xer_escape_table_s *el; el = &OCTET_STRING__xer_escape_table[i]; if (el->size == size && memcmp(buf, el->string, size) == 0) - return i; + { + return i; + } } return -1; } @@ -865,7 +908,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, (void)ilevel; /* Unused argument */ (void)flags; /* Unused argument */ - if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; + if (!st || (!st->buf && st->size)) + { + _ASN_ENCODE_FAILED; + } buf = st->buf; end = buf + st->size; @@ -884,14 +930,19 @@ asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, if (((buf - ss) && cb(ss, buf - ss, app_key) < 0) || cb(OCTET_STRING__xer_escape_table[ch].string, s_len, app_key) < 0) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } encoded_len += (buf - ss) + s_len; ss = buf + 1; } } encoded_len += (buf - ss); - if ((buf - ss) && cb(ss, buf - ss, app_key) < 0) _ASN_ENCODE_FAILED; + if ((buf - ss) && cb(ss, buf - ss, app_key) < 0) + { + _ASN_ENCODE_FAILED; + } er.encoded = encoded_len; _ASN_ENCODED_OK(er); @@ -916,7 +967,10 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, /* Reallocate buffer according to high cap estimation */ ssize_t _ns = st->size + (chunk_size + 1) / 2; void *nptr = REALLOC(st->buf, _ns + 1); - if (!nptr) return -1; + if (!nptr) + { + return -1; + } st->buf = (uint8_t *)nptr; buf = st->buf + st->size; @@ -1019,16 +1073,23 @@ static ssize_t OCTET_STRING__convert_binary(void *sptr, const void *chunk_buf, /* Reallocate buffer according to high cap estimation */ ssize_t _ns = st->size + (chunk_size + 7) / 8; void *nptr = REALLOC(st->buf, _ns + 1); - if (!nptr) return -1; + if (!nptr) + { + return -1; + } st->buf = (uint8_t *)nptr; buf = st->buf + st->size; (void)have_more; if (bits_unused == 0) - bits_unused = 8; + { + bits_unused = 8; + } else if (st->size) - buf--; + { + buf--; + } /* * Convert series of 0 and 1 into the octet string. @@ -1091,7 +1152,10 @@ static int OS__strtoent(int base, const char *buf, const char *end, int ch = *p; /* Strange huge value */ - if ((val * base + base) < 0) return -1; + if ((val * base + base) < 0) + { + return -1; + } switch (ch) { @@ -1149,7 +1213,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, /* Reallocate buffer */ ssize_t _ns = st->size + chunk_size; void *nptr = REALLOC(st->buf, _ns + 1); - if (!nptr) return -1; + if (!nptr) + { + return -1; + } st->buf = (uint8_t *)nptr; buf = st->buf + st->size; @@ -1171,18 +1238,28 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, * Process entity reference. */ len = chunk_size - (p - (const char *)chunk_buf); - if (len == 1 /* "&" */) goto want_more; + if (len == 1 /* "&" */) + { + goto want_more; + } if (p[1] == 0x23 /* '#' */) { const char *pval; /* Pointer to start of digits */ int32_t val = 0; /* Entity reference value */ int base; - if (len == 2 /* "&#" */) goto want_more; + if (len == 2 /* "&#" */) + { + goto want_more; + } if (p[2] == 0x78 /* 'x' */) - pval = p + 3, base = 16; + { + pval = p + 3, base = 16; + } else - pval = p + 2, base = 10; + { + pval = p + 2, base = 10; + } len = OS__strtoent(base, pval, p + len, &val); if (len == -1) { @@ -1190,7 +1267,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, *buf++ = ch; continue; } - if (!len || pval[len - 1] != 0x3b) goto want_more; + if (!len || pval[len - 1] != 0x3b) + { + goto want_more; + } assert(val > 0); p += (pval - p) + len - 1; /* Advance past entref */ @@ -1240,7 +1320,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, * Ugly, limited parsing of & > < */ char *sc = (char *)memchr(p, 0x3b, len > 5 ? 5 : len); - if (!sc) goto want_more; + if (!sc) + { + goto want_more; + } if ((sc - p) == 4 && p[1] == 0x61 /* 'a' */ && p[2] == 0x6d /* 'm' */ && p[3] == 0x70 /* 'p' */) @@ -1329,7 +1412,10 @@ static asn_dec_rval_t OCTET_STRING__decode_xer( { st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size); *sptr = (void *)st; - if (!st) goto sta_failed; + if (!st) + { + goto sta_failed; + } st_allocated = 1; } else @@ -1425,14 +1511,19 @@ static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf, else if (pc && pc->code2value) { if (unit_bits > 16) - return 1; /* FATAL: can't have constrained + { + return 1; + } /* FATAL: can't have constrained * UniversalString with more than * 16 million code points */ for (; buf < end; buf += bpc) { int value; int code = per_get_few_bits(po, unit_bits); - if (code < 0) return -1; /* WMORE */ + if (code < 0) + { + return -1; /* WMORE */ + } value = pc->code2value(code); if (value < 0) { @@ -1472,7 +1563,10 @@ static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf, { int code = per_get_few_bits(po, unit_bits); int ch = code + lb; - if (code < 0) return -1; /* WMORE */ + if (code < 0) + { + return -1; /* WMORE */ + } if (ch > ub) { ASN_DEBUG("Code %d is out of range (%ld..%ld)", ch, lb, ub); @@ -1546,7 +1640,10 @@ static int OCTET_STRING_per_put_characters(asn_per_outp_t *po, *buf, *buf, lb, ub); return -1; } - if (per_put_few_bits(po, code, unit_bits)) return -1; + if (per_put_few_bits(po, code, unit_bits)) + { + return -1; + } } } @@ -1584,7 +1681,10 @@ static int OCTET_STRING_per_put_characters(asn_per_outp_t *po, *buf, *buf, lb, ub + lb); return -1; } - if (per_put_few_bits(po, ch, unit_bits)) return -1; + if (per_put_few_bits(po, ch, unit_bits)) + { + return -1; + } } return 0; @@ -1640,17 +1740,26 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, break; case ASN_OSUBV_STR: canonical_unit_bits = unit_bits = 8; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_CHAR; break; case ASN_OSUBV_U16: canonical_unit_bits = unit_bits = 16; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U16; break; case ASN_OSUBV_U32: canonical_unit_bits = unit_bits = 32; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U32; break; } @@ -1661,7 +1770,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); - if (!st) RETURN(RC_FAIL); + if (!st) + { + RETURN(RC_FAIL); + } } ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d", @@ -1671,7 +1783,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (csiz->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); - if (inext < 0) RETURN(RC_WMORE); + if (inext < 0) + { + RETURN(RC_WMORE); + } if (inext) { csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size; @@ -1712,7 +1827,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ret = OCTET_STRING_per_get_characters( pd, st->buf, csiz->upper_bound, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); - if (ret > 0) RETURN(RC_FAIL); + if (ret > 0) + { + RETURN(RC_FAIL); + } } else { @@ -1721,7 +1839,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ret = per_get_many_bits(pd, st->buf, 0, unit_bits * csiz->upper_bound); } - if (ret < 0) RETURN(RC_WMORE); + if (ret < 0) + { + RETURN(RC_WMORE); + } consumed_myself += unit_bits * csiz->upper_bound; st->buf[st->size] = 0; if (bpc == 0) @@ -1743,7 +1864,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, /* Get the PER length */ raw_len = uper_get_length(pd, csiz->effective_bits, &repeat); - if (raw_len < 0) RETURN(RC_WMORE); + if (raw_len < 0) + { + RETURN(RC_WMORE); + } raw_len += csiz->lower_bound; ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)", @@ -1758,11 +1882,17 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, { len_bits = raw_len; len_bytes = (len_bits + 7) >> 3; - if (len_bits & 0x7) st->bits_unused = 8 - (len_bits & 0x7); + if (len_bits & 0x7) + { + st->bits_unused = 8 - (len_bits & 0x7); + } /* len_bits be multiple of 16K if repeat is set */ } p = REALLOC(st->buf, st->size + len_bytes + 1); - if (!p) RETURN(RC_FAIL); + if (!p) + { + RETURN(RC_FAIL); + } st->buf = (uint8_t *)p; if (bpc) @@ -1770,14 +1900,20 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ret = OCTET_STRING_per_get_characters( pd, &st->buf[st->size], raw_len, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); - if (ret > 0) RETURN(RC_FAIL); + if (ret > 0) + { + RETURN(RC_FAIL); + } } else { ret = per_get_many_bits(pd, &st->buf[st->size], 0, len_bits); } - if (ret < 0) RETURN(RC_WMORE); + if (ret < 0) + { + RETURN(RC_WMORE); + } st->size += len_bytes; } while (repeat); @@ -1813,7 +1949,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, } bpc; /* Bytes per character */ int ct_extensible; - if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; + if (!st || (!st->buf && st->size)) + { + _ASN_ENCODE_FAILED; + } if (pc) { @@ -1841,19 +1980,28 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, break; case ASN_OSUBV_STR: canonical_unit_bits = unit_bits = 8; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_CHAR; sizeinunits = st->size; break; case ASN_OSUBV_U16: canonical_unit_bits = unit_bits = 16; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U16; sizeinunits = st->size / 2; break; case ASN_OSUBV_U32: canonical_unit_bits = unit_bits = 32; - if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; + if (cval->flags & APC_CONSTRAINED) + { + unit_bits = cval->range_bits; + } bpc = OS__BPC_U32; sizeinunits = st->size / 4; break; @@ -1880,7 +2028,9 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, inext = 1; } else - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } } else @@ -1891,7 +2041,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, if (ct_extensible) { /* Declare whether length is [not] within extension root */ - if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, inext, 1)) + { + _ASN_ENCODE_FAILED; + } } /* X.691, #16.5: zero-length encoding */ @@ -1903,7 +2056,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, sizeinunits - csiz->lower_bound, csiz->effective_bits); ret = per_put_few_bits(po, sizeinunits - csiz->lower_bound, csiz->effective_bits); - if (ret) _ASN_ENCODE_FAILED; + if (ret) + { + _ASN_ENCODE_FAILED; + } if (bpc) { ret = OCTET_STRING_per_put_characters( @@ -1915,7 +2071,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, ret = per_put_many_bits(po, st->buf, sizeinunits * unit_bits); } - if (ret) _ASN_ENCODE_FAILED; + if (ret) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -1923,7 +2082,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, if (sizeinunits == 0) { - if (uper_put_length(po, 0)) _ASN_ENCODE_FAILED; + if (uper_put_length(po, 0)) + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } @@ -1931,7 +2093,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, while (sizeinunits) { ssize_t maySave = uper_put_length(po, sizeinunits); - if (maySave < 0) _ASN_ENCODE_FAILED; + if (maySave < 0) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Encoding %ld of %ld", (long)maySave, (long)sizeinunits); @@ -1945,12 +2110,19 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, { ret = per_put_many_bits(po, buf, maySave * unit_bits); } - if (ret) _ASN_ENCODE_FAILED; + if (ret) + { + _ASN_ENCODE_FAILED; + } if (bpc) - buf += maySave * bpc; + { + buf += maySave * bpc; + } else - buf += maySave >> 3; + { + buf += maySave >> 3; + } sizeinunits -= maySave; assert(!(maySave & 0x07) || !sizeinunits); } @@ -1972,7 +2144,9 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, (void)td; /* Unused argument */ if (!st || (!st->buf && st->size)) - return (cb("", 8, app_key) < 0) ? -1 : 0; + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* * Dump the contents of the buffer in hexadecimal. @@ -1983,7 +2157,10 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, { if (!(i % 16) && (i || st->size > 16)) { - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } _i_INDENT(1); p = scratch; } @@ -1995,7 +2172,10 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, if (p > scratch) { p--; /* Remove the tail space */ - if (cb(scratch, p - scratch, app_key) < 0) return -1; + if (cb(scratch, p - scratch, app_key) < 0) + { + return -1; + } } return 0; @@ -2030,7 +2210,10 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); struct _stack *stck; - if (!td || !st) return; + if (!td || !st) + { + return; + } ASN_DEBUG("Freeing %s as OCTET STRING", td->name); @@ -2086,11 +2269,17 @@ int OCTET_STRING_fromBuf(OCTET_STRING_t *st, const char *str, int len) } /* Determine the original string size, if not explicitly given */ - if (len < 0) len = strlen(str); + if (len < 0) + { + len = strlen(str); + } /* Allocate and fill the memory */ buf = MALLOC(len + 1); - if (buf == NULL) return -1; + if (buf == NULL) + { + return -1; + } memcpy(buf, str, len); ((uint8_t *)buf)[len] = '\0'; /* Couldn't use memcpy(len+1)! */ diff --git a/src/core/libs/supl/asn-supl/Pathloss.c b/src/core/libs/supl/asn-supl/Pathloss.c index 33c93f128..d0e7d81da 100644 --- a/src/core/libs/supl/asn-supl/Pathloss.c +++ b/src/core/libs/supl/asn-supl/Pathloss.c @@ -48,7 +48,9 @@ static void Pathloss_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/PosMethod.c b/src/core/libs/supl/asn-supl/PosMethod.c index 5a5937d08..0da6951b1 100644 --- a/src/core/libs/supl/asn-supl/PosMethod.c +++ b/src/core/libs/supl/asn-supl/PosMethod.c @@ -29,7 +29,9 @@ static void PosMethod_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/PositionEstimate.c b/src/core/libs/supl/asn-supl/PositionEstimate.c index 828bc4f04..f389e404c 100644 --- a/src/core/libs/supl/asn-supl/PositionEstimate.c +++ b/src/core/libs/supl/asn-supl/PositionEstimate.c @@ -31,7 +31,9 @@ static void latitudeSign_2_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/PrefMethod.c b/src/core/libs/supl/asn-supl/PrefMethod.c index 41f0b5d0b..00b7cce15 100644 --- a/src/core/libs/supl/asn-supl/PrefMethod.c +++ b/src/core/libs/supl/asn-supl/PrefMethod.c @@ -29,7 +29,9 @@ static void PrefMethod_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c b/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c index 7e8f19505..9aea01bf6 100644 --- a/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c +++ b/src/core/libs/supl/asn-supl/PrimaryCCPCH-RSCP.c @@ -50,7 +50,9 @@ static void PrimaryCCPCH_RSCP_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/SETId.c b/src/core/libs/supl/asn-supl/SETId.c index d683fc6b7..35819adb0 100644 --- a/src/core/libs/supl/asn-supl/SETId.c +++ b/src/core/libs/supl/asn-supl/SETId.c @@ -16,7 +16,10 @@ static int check_permitted_alphabet_6(const void *sptr) for (; ch < end; ch++) { uint8_t cv = *ch; - if (!(cv <= 127)) return -1; + if (!(cv <= 127)) + { + return -1; + } } return 0; } diff --git a/src/core/libs/supl/asn-supl/SLPMode.c b/src/core/libs/supl/asn-supl/SLPMode.c index c178488d3..70e33445c 100644 --- a/src/core/libs/supl/asn-supl/SLPMode.c +++ b/src/core/libs/supl/asn-supl/SLPMode.c @@ -29,7 +29,9 @@ static void SLPMode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/Status.c b/src/core/libs/supl/asn-supl/Status.c index 09ad2e871..c420eb34c 100644 --- a/src/core/libs/supl/asn-supl/Status.c +++ b/src/core/libs/supl/asn-supl/Status.c @@ -29,7 +29,9 @@ static void Status_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/StatusCode.c b/src/core/libs/supl/asn-supl/StatusCode.c index 456b60fca..592d9ac7d 100644 --- a/src/core/libs/supl/asn-supl/StatusCode.c +++ b/src/core/libs/supl/asn-supl/StatusCode.c @@ -29,7 +29,9 @@ static void StatusCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + { + td->per_constraints = asn_DEF_ENUMERATED.per_constraints; + } td->elements = asn_DEF_ENUMERATED.elements; td->elements_count = asn_DEF_ENUMERATED.elements_count; /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined diff --git a/src/core/libs/supl/asn-supl/TGSN.c b/src/core/libs/supl/asn-supl/TGSN.c index cb58047e2..8dfc0869c 100644 --- a/src/core/libs/supl/asn-supl/TGSN.c +++ b/src/core/libs/supl/asn-supl/TGSN.c @@ -48,7 +48,9 @@ static void TGSN_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/TimeslotISCP.c b/src/core/libs/supl/asn-supl/TimeslotISCP.c index 27d3bb50c..863311c68 100644 --- a/src/core/libs/supl/asn-supl/TimeslotISCP.c +++ b/src/core/libs/supl/asn-supl/TimeslotISCP.c @@ -49,7 +49,9 @@ static void TimeslotISCP_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/UARFCN.c b/src/core/libs/supl/asn-supl/UARFCN.c index a7719dd0f..72f3ddacb 100644 --- a/src/core/libs/supl/asn-supl/UARFCN.c +++ b/src/core/libs/supl/asn-supl/UARFCN.c @@ -48,7 +48,9 @@ static void UARFCN_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/UTCTime.c b/src/core/libs/supl/asn-supl/UTCTime.c index d0c002f4f..4a80f356e 100644 --- a/src/core/libs/supl/asn-supl/UTCTime.c +++ b/src/core/libs/supl/asn-supl/UTCTime.c @@ -89,11 +89,16 @@ asn_enc_rval_t UTCTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, errno = EPERM; if (asn_UT2time((UTCTime_t *)sptr, &tm, 1) == -1 && errno != EPERM) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } /* Fractions are not allowed in UTCTime */ ut = asn_time2GT(0, 0, 1); - if (!ut) _ASN_ENCODE_FAILED; + if (!ut) + { + _ASN_ENCODE_FAILED; + } rv = OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags, cb, app_key); @@ -125,7 +130,9 @@ int UTCTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, errno = EPERM; if (asn_UT2time(st, &tm, 1) == -1 && errno != EPERM) - return (cb("", 11, app_key) < 0) ? -1 : 0; + { + return (cb("", 11, app_key) < 0) ? -1 : 0; + } ret = snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d (GMT)", @@ -175,7 +182,10 @@ UTCTime_t *asn_time2UT(UTCTime_t *opt_ut, const struct tm *tm, int force_gmt) GeneralizedTime_t *gt = (GeneralizedTime_t *)opt_ut; gt = asn_time2GT(gt, tm, force_gmt); - if (gt == 0) return 0; + if (gt == 0) + { + return 0; + } assert(gt->size >= 2); gt->size -= 2; diff --git a/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c b/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c index 2e4742954..a6c330d9d 100644 --- a/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c +++ b/src/core/libs/supl/asn-supl/UTRA-CarrierRSSI.c @@ -50,7 +50,9 @@ static void UTRA_CarrierRSSI_1_inherit_TYPE_descriptor( td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; + { + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + } td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; diff --git a/src/core/libs/supl/asn-supl/Ver.c b/src/core/libs/supl/asn-supl/Ver.c index f11e53b72..7cf89af25 100644 --- a/src/core/libs/supl/asn-supl/Ver.c +++ b/src/core/libs/supl/asn-supl/Ver.c @@ -57,7 +57,9 @@ static void Ver_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if (!td->per_constraints) - td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + { + td->per_constraints = asn_DEF_BIT_STRING.per_constraints; + } td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; diff --git a/src/core/libs/supl/asn-supl/asn_SEQUENCE_OF.c b/src/core/libs/supl/asn-supl/asn_SEQUENCE_OF.c index 67981e72f..13bb362ba 100644 --- a/src/core/libs/supl/asn-supl/asn_SEQUENCE_OF.c +++ b/src/core/libs/supl/asn-supl/asn_SEQUENCE_OF.c @@ -17,7 +17,9 @@ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) int n; if (number < 0 || number >= as->count) - return; /* Nothing to delete */ + { + return; /* Nothing to delete */ + } if (_do_free && as->free) { @@ -33,12 +35,17 @@ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) */ --as->count; for (n = number; n < as->count; n++) - as->array[n] = as->array[n + 1]; + { + as->array[n] = as->array[n + 1]; + } /* * Invoke the third-party function only when the state * of the parent structure is consistent. */ - if (ptr) as->free(ptr); + if (ptr) + { + as->free(ptr); + } } } diff --git a/src/core/libs/supl/asn-supl/asn_SET_OF.c b/src/core/libs/supl/asn-supl/asn_SET_OF.c index 317ebea09..2b7577198 100644 --- a/src/core/libs/supl/asn-supl/asn_SET_OF.c +++ b/src/core/libs/supl/asn-supl/asn_SET_OF.c @@ -51,7 +51,10 @@ void asn_set_del(void *asn_set_of_x, int number, int _do_free) if (as) { void *ptr; - if (number < 0 || number >= as->count) return; + if (number < 0 || number >= as->count) + { + return; + } if (_do_free && as->free) { @@ -68,7 +71,10 @@ void asn_set_del(void *asn_set_of_x, int number, int _do_free) * Invoke the third-party function only when the state * of the parent structure is consistent. */ - if (ptr) as->free(ptr); + if (ptr) + { + as->free(ptr); + } } } @@ -85,7 +91,10 @@ void asn_set_empty(void *asn_set_of_x) { if (as->free) { - while (as->count--) as->free(as->array[as->count]); + while (as->count--) + { + as->free(as->array[as->count]); + } } FREEMEM(as->array); as->array = 0; diff --git a/src/core/libs/supl/asn-supl/asn_codecs_prim.c b/src/core/libs/supl/asn-supl/asn_codecs_prim.c index 75b51ad38..753b943e9 100644 --- a/src/core/libs/supl/asn-supl/asn_codecs_prim.c +++ b/src/core/libs/supl/asn-supl/asn_codecs_prim.c @@ -24,7 +24,10 @@ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, if (st == NULL) { st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st)); - if (st == NULL) _ASN_DECODE_FAILED; + if (st == NULL) + { + _ASN_DECODE_FAILED; + } *sptr = (void *)st; } @@ -35,7 +38,10 @@ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); - if (rval.code != RC_OK) return rval; + if (rval.code != RC_OK) + { + return rval; + } ASN_DEBUG("%s length is %d bytes", td->name, (int)length); @@ -124,13 +130,22 @@ void ASN__PRIMITIVE_TYPE_free(asn_TYPE_descriptor_t *td, void *sptr, { ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr; - if (!td || !sptr) return; + if (!td || !sptr) + { + return; + } ASN_DEBUG("Freeing %s as a primitive type", td->name); - if (st->buf) FREEMEM(st->buf); + if (st->buf) + { + FREEMEM(st->buf); + } - if (!contents_only) FREEMEM(st); + if (!contents_only) + { + FREEMEM(st); + } } /* @@ -154,7 +169,9 @@ static int xer_decode__unexpected_tag(void *key, const void *chunk_buf, if (arg->decoded_something) { if (xer_is_whitespace(chunk_buf, chunk_size)) - return 0; /* Skip it. */ + { + return 0; /* Skip it. */ + } /* * Decoding was done once already. Prohibit doing it again. */ @@ -188,7 +205,10 @@ static ssize_t xer_decode__body(void *key, const void *chunk_buf, if (arg->decoded_something) { - if (xer_is_whitespace(chunk_buf, chunk_size)) return chunk_size; + if (xer_is_whitespace(chunk_buf, chunk_size)) + { + return chunk_size; + } /* * Decoding was done once already. Prohibit doing it again. */ @@ -244,7 +264,10 @@ asn_dec_rval_t xer_decode_primitive( if (!*sptr) { *sptr = CALLOC(1, struct_size); - if (!*sptr) _ASN_DECODE_FAILED; + if (!*sptr) + { + _ASN_DECODE_FAILED; + } } memset(&s_ctx, 0, sizeof(s_ctx)); @@ -291,9 +314,13 @@ asn_dec_rval_t xer_decode_primitive( case RC_FAIL: rc.consumed = 0; if (s_arg.want_more) - rc.code = RC_WMORE; + { + rc.code = RC_WMORE; + } else - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } break; } return rc; diff --git a/src/core/libs/supl/asn-supl/ber_decoder.c b/src/core/libs/supl/asn-supl/ber_decoder.c index c2dbabbfe..f59773a2e 100644 --- a/src/core/libs/supl/asn-supl/ber_decoder.c +++ b/src/core/libs/supl/asn-supl/ber_decoder.c @@ -92,7 +92,10 @@ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, /* * Make sure we didn't exceed the maximum stack size. */ - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) RETURN(RC_FAIL); + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + RETURN(RC_FAIL); + } /* * So what does all this implicit skip stuff mean? @@ -317,11 +320,18 @@ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, } } - if (opt_tlv_form) *opt_tlv_form = tlv_constr; + if (opt_tlv_form) + { + *opt_tlv_form = tlv_constr; + } if (expect_00_terminators) - *last_length = -expect_00_terminators; + { + *last_length = -expect_00_terminators; + } else - *last_length = tlv_len; + { + *last_length = tlv_len; + } RETURN(RC_OK); } diff --git a/src/core/libs/supl/asn-supl/ber_tlv_length.c b/src/core/libs/supl/asn-supl/ber_tlv_length.c index 4efe95b95..4967c570c 100644 --- a/src/core/libs/supl/asn-supl/ber_tlv_length.c +++ b/src/core/libs/supl/asn-supl/ber_tlv_length.c @@ -12,7 +12,10 @@ ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size, const uint8_t *buf = (const uint8_t *)bufptr; unsigned oct; - if (size == 0) return 0; /* Want more */ + if (size == 0) + { + return 0; /* Want more */ + } oct = *buf; if ((oct & 0x80) == 0) @@ -90,13 +93,19 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, /* * Make sure we didn't exceed the maximum stack size. */ - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) return -1; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + return -1; + } /* * Determine the size of L in TLV. */ ll = ber_fetch_length(_is_constructed, ptr, size, &vlen); - if (ll <= 0) return ll; + if (ll <= 0) + { + return ll; + } /* * Definite length. @@ -104,7 +113,10 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, if (vlen >= 0) { skip = ll + vlen; - if (skip > size) return 0; /* Want more */ + if (skip > size) + { + return 0; /* Want more */ + } return skip; } @@ -118,11 +130,17 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, /* Fetch the tag */ tl = ber_fetch_tag(ptr, size, &tag); - if (tl <= 0) return tl; + if (tl <= 0) + { + return tl; + } ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), ((const char *)ptr) + tl, size - tl); - if (ll <= 0) return ll; + if (ll <= 0) + { + return ll; + } skip += tl + ll; @@ -133,7 +151,9 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, */ if (((const uint8_t *)ptr)[0] == 0 && ((const uint8_t *)ptr)[1] == 0) - return skip; + { + return skip; + } ptr = ((const char *)ptr) + tl + ll; size -= tl + ll; @@ -152,7 +172,10 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) if (len <= 127) { /* Encoded in 1 octet */ - if (size) *buf = (uint8_t)len; + if (size) + { + *buf = (uint8_t)len; + } return 1; } @@ -162,12 +185,19 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) for (required_size = 1, i = 8; i < 8 * sizeof(len); i += 8) { if (len >> i) - required_size++; + { + required_size++; + } else - break; + { + break; + } } - if (size <= required_size) return required_size + 1; + if (size <= required_size) + { + return required_size + 1; + } *buf++ = (uint8_t)(0x80 | required_size); /* Length of the encoding */ @@ -175,7 +205,10 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) * Produce the len encoding, space permitting. */ end = buf + required_size; - for (i -= 8; buf < end; i -= 8, buf++) *buf = (uint8_t)(len >> i); + for (i -= 8; buf < end; i -= 8, buf++) + { + *buf = (uint8_t)(len >> i); + } return required_size + 1; } diff --git a/src/core/libs/supl/asn-supl/ber_tlv_tag.c b/src/core/libs/supl/asn-supl/ber_tlv_tag.c index 0bef65296..06defa3e6 100644 --- a/src/core/libs/supl/asn-supl/ber_tlv_tag.c +++ b/src/core/libs/supl/asn-supl/ber_tlv_tag.c @@ -12,7 +12,10 @@ ssize_t ber_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r) ber_tlv_tag_t tclass; size_t skipped; - if (size == 0) return 0; + if (size == 0) + { + return 0; + } val = *(const uint8_t *)ptr; tclass = (val >> 6); @@ -98,7 +101,10 @@ ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size) } ret = snprintf(buf, size, "[%s%u]", type, ((unsigned)tag) >> 2); - if (ret <= 0 && size) buf[0] = '\0'; /* against broken libc's */ + if (ret <= 0 && size) + { + buf[0] = '\0'; /* against broken libc's */ + } return ret; } @@ -124,7 +130,10 @@ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) if (tval <= 30) { /* Encoded in 1 octet */ - if (size) buf[0] = (tclass << 6) | tval; + if (size) + { + buf[0] = (tclass << 6) | tval; + } return 1; } else if (size) @@ -139,18 +148,28 @@ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) for (required_size = 1, i = 7; i < 8 * sizeof(tval); i += 7) { if (tval >> i) - required_size++; + { + required_size++; + } else - break; + { + break; + } } - if (size < required_size) return required_size + 1; + if (size < required_size) + { + return required_size + 1; + } /* * Fill in the buffer, space permitting. */ end = buf + required_size - 1; - for (i -= 7; buf < end; i -= 7, buf++) *buf = 0x80 | ((tval >> i) & 0x7F); + for (i -= 7; buf < end; i -= 7, buf++) + { + *buf = 0x80 | ((tval >> i) & 0x7F); + } *buf = (tval & 0x7F); /* Last octet without high bit */ return required_size + 1; diff --git a/src/core/libs/supl/asn-supl/constr_CHOICE.c b/src/core/libs/supl/asn-supl/constr_CHOICE.c index 7c0917700..cc0386625 100644 --- a/src/core/libs/supl/asn-supl/constr_CHOICE.c +++ b/src/core/libs/supl/asn-supl/constr_CHOICE.c @@ -92,11 +92,17 @@ static int _search4tag(const void *ap, const void *bp) ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); if (a_value == b_value) - return 0; + { + return 0; + } else if (a_value < b_value) - return -1; + { + return -1; + } else - return 1; + { + return 1; + } } else if (a_class < b_class) { @@ -202,7 +208,10 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tag_len) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -251,7 +260,9 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { case 0: if (!SIZE_VIOLATION) - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -366,7 +377,10 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tl) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -380,9 +394,13 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -424,7 +442,10 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, size_t computed_size = 0; int present; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name); @@ -483,12 +504,18 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, /* Encode member with its tag */ erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } /* Encode CHOICE with parent or my own tag */ ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag, cb, app_key); - if (ret == -1) _ASN_ENCODE_FAILED; + if (ret == -1) + { + _ASN_ENCODE_FAILED; + } computed_size += ret; } @@ -497,7 +524,10 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, */ erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", (long)erval.encoded, (long)computed_size); @@ -576,7 +606,10 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, elm->memb_offset); if (!memb_ptr) { - if (elm->optional) return 0; + if (elm->optional) + { + return 0; + } _ASN_CTFAIL(app_key, td, sptr, "%s: mandatory CHOICE element %s " "absent (%s:%d)", @@ -658,7 +691,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); - if (st == 0) RETURN(RC_FAIL); + if (st == 0) + { + RETURN(RC_FAIL); + } } /* @@ -666,7 +702,9 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, */ 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 */ + { + ctx->phase = 1; /* Skip the outer tag checking phase */ + } /* * Phases of XER/XML processing: @@ -714,7 +752,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, XER_ADVANCE(tmprval.consumed); ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d", elm->type->name, tmprval.code); - if (tmprval.code != RC_OK) RETURN(tmprval.code); + if (tmprval.code != RC_OK) + { + RETURN(tmprval.code); + } assert(_fetch_present_idx(st, specs->pres_offset, specs->pres_size) == 0); /* Record what we've got */ @@ -788,7 +829,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, case XCT_BOTH: break; /* No CHOICE? */ case XCT_CLOSING: - if (ctx->phase != 3) break; + if (ctx->phase != 3) + { + break; + } XER_ADVANCE(ch_size); ctx->phase = 5; /* Phase out */ RETURN(RC_OK); @@ -803,7 +847,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: - if (ctx->phase != 1) break; /* Really unexpected */ + if (ctx->phase != 1) + { + break; /* Really unexpected */ + } /* * Search which inner member corresponds to this tag. @@ -832,7 +879,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, } break; } - if (edx != td->elements_count) continue; + if (edx != td->elements_count) + { + continue; + } /* It is expected extension */ if (specs->ext_start != -1) @@ -885,7 +935,10 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, asn_enc_rval_t er; int present; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } /* * Figure out which CHOICE element is encoded. @@ -907,7 +960,10 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (!memb_ptr) _ASN_ENCODE_FAILED; + if (!memb_ptr) + { + _ASN_ENCODE_FAILED; + } } else { @@ -916,19 +972,28 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded = 0; - if (!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel); + if (!(flags & XER_F_CANONICAL)) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } - if (!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!(flags & XER_F_CANONICAL)) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -949,7 +1014,10 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, void *st = *sptr; int value; - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + _ASN_DECODE_FAILED; + } /* * Create the target structure if it is not present already. @@ -957,42 +1025,75 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = *sptr = CALLOC(1, specs->struct_size); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - ct = 0; + { + ct = 0; + } if (ct && ct->flags & APC_EXTENSIBLE) { value = per_get_few_bits(pd, 1); - if (value < 0) _ASN_DECODE_STARVED; - if (value) ct = 0; /* Not restricted */ + if (value < 0) + { + _ASN_DECODE_STARVED; + } + if (value) + { + ct = 0; /* Not restricted */ + } } if (ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } ASN_DEBUG("CHOICE %s got index %d in range %d", td->name, value, ct->range_bits); - if (value > ct->upper_bound) _ASN_DECODE_FAILED; + if (value > ct->upper_bound) + { + _ASN_DECODE_FAILED; + } } else { - if (specs->ext_start == -1) _ASN_DECODE_FAILED; + if (specs->ext_start == -1) + { + _ASN_DECODE_FAILED; + } value = uper_get_nsnnwn(pd); - if (value < 0) _ASN_DECODE_STARVED; + if (value < 0) + { + _ASN_DECODE_STARVED; + } value += specs->ext_start; - if (value >= td->elements_count) _ASN_DECODE_FAILED; + if (value >= td->elements_count) + { + _ASN_DECODE_FAILED; + } } /* Adjust if canonical order is different from natural order */ - if (specs->canonical_order) value = specs->canonical_order[value]; + if (specs->canonical_order) + { + value = specs->canonical_order[value]; + } /* Set presence to be able to free it later */ _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); @@ -1022,8 +1123,10 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, } if (rv.code != RC_OK) - ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, - rv.code); + { + ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, + rv.code); + } return rv; } @@ -1037,16 +1140,25 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, void *memb_ptr; int present; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Encoding %s as CHOICE", td->name); if (constraints) - ct = &constraints->value; + { + ct = &constraints->value; + } else if (td->per_constraints) - ct = &td->per_constraints->value; + { + ct = &td->per_constraints->value; + } else - ct = 0; + { + ct = 0; + } present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); @@ -1055,12 +1167,19 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, * can't deduce what to encode in the choice type. */ if (present <= 0 || present > td->elements_count) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } else - present--; + { + present--; + } /* Adjust if canonical order is different from natural order */ - if (specs->canonical_order) present = specs->canonical_order[present]; + if (specs->canonical_order) + { + present = specs->canonical_order[present]; + } ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present); @@ -1070,7 +1189,10 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, { if (ct->flags & APC_EXTENSIBLE) { - if (per_put_few_bits(po, 1, 1)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, 1, 1)) + { + _ASN_ENCODE_FAILED; + } } else { @@ -1080,14 +1202,22 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, } } if (ct && ct->flags & APC_EXTENSIBLE) - if (per_put_few_bits(po, 0, 1)) _ASN_ENCODE_FAILED; + { + if (per_put_few_bits(po, 0, 1)) + { + _ASN_ENCODE_FAILED; + } + } elm = &td->elements[present]; if (elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (!memb_ptr) _ASN_ENCODE_FAILED; + if (!memb_ptr) + { + _ASN_ENCODE_FAILED; + } } else { @@ -1097,7 +1227,9 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, if (ct && ct->range_bits >= 0) { if (per_put_few_bits(po, present, ct->range_bits)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } return elm->type->uper_encoder(elm->type, elm->per_constraints, memb_ptr, po); @@ -1105,12 +1237,19 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, else { asn_enc_rval_t rval; - if (specs->ext_start == -1) _ASN_ENCODE_FAILED; + if (specs->ext_start == -1) + { + _ASN_ENCODE_FAILED; + } if (uper_put_nsnnwn(po, present - specs->ext_start)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } if (uper_open_type_put(elm->type, elm->per_constraints, memb_ptr, po)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } rval.encoded = 0; _ASN_ENCODED_OK(rval); } @@ -1122,7 +1261,10 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; - if (!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!sptr) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* * Figure out which CHOICE element is encoded. @@ -1142,7 +1284,9 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, memb_ptr = *(const void *const *)((const char *)sptr + elm->memb_offset); if (!memb_ptr) - return (cb("", 8, app_key) < 0) ? -1 : 0; + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } } else { @@ -1155,7 +1299,9 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, { if (cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) - return -1; + { + return -1; + } } return elm->type->print_struct(elm->type, memb_ptr, ilevel, cb, @@ -1172,7 +1318,10 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; - if (!td || !ptr) return; + if (!td || !ptr) + { + return; + } ASN_DEBUG("Freeing %s as CHOICE", td->name); @@ -1192,7 +1341,10 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)ptr + elm->memb_offset); - if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); + if (memb_ptr) + { + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } } else { diff --git a/src/core/libs/supl/asn-supl/constr_SEQUENCE.c b/src/core/libs/supl/asn-supl/constr_SEQUENCE.c index ddf0d87fd..1097239c5 100644 --- a/src/core/libs/supl/asn-supl/constr_SEQUENCE.c +++ b/src/core/libs/supl/asn-supl/constr_SEQUENCE.c @@ -99,7 +99,10 @@ static int _t2e_cmp(const void *ap, const void *bp) if (a_value == b_value) { - if (a->el_no > b->el_no) return 1; + if (a->el_no > b->el_no) + { + return 1; + } /* * Important: we do not check * for a->el_no <= b->el_no! @@ -107,9 +110,13 @@ static int _t2e_cmp(const void *ap, const void *bp) return 0; } else if (a_value < b_value) - return -1; + { + return -1; + } else - return 1; + { + return 1; + } } else if (a_class < b_class) { @@ -187,7 +194,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if (ctx->left >= 0) - ctx->left += rval.consumed; /* ?Subtracted below! */ + { + ctx->left += rval.consumed; /* ?Subtracted below! */ + } ADVANCE(rval.consumed); NEXT_PHASE(ctx); @@ -217,7 +226,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, int use_bsearch; int n; - if (ctx->step & 1) goto microphase2; + if (ctx->step & 1) + { + goto microphase2; + } /* * MICROPHASE 1: Synchronize decoding. @@ -259,7 +271,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tag_len) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -270,9 +285,13 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -306,7 +325,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, use_bsearch = 0; opt_edx_end = edx + elements[edx].optional + 1; if (opt_edx_end > td->elements_count) - opt_edx_end = td->elements_count; /* Cap */ + { + opt_edx_end = td->elements_count; /* Cap */ + } else if (opt_edx_end - edx > 8) { /* Limit the scope of linear search... */ @@ -372,8 +393,14 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, t2m_l = t2m + t2m->toff_last; for (t2m = t2m_f; t2m <= t2m_l; t2m++) { - if (t2m->el_no > edx_max) break; - if (t2m->el_no < edx) continue; + if (t2m->el_no > edx_max) + { + break; + } + if (t2m->el_no < edx) + { + continue; + } best = t2m; } if (best) @@ -428,7 +455,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { case 0: if (!SIZE_VIOLATION) - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -524,7 +553,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tl) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -538,9 +570,13 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -571,7 +607,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (ll) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -612,7 +651,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } @@ -623,7 +665,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, } erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } computed_size += erval.encoded; ASN_DEBUG("Member %d %s estimated %ld bytes", edx, elm->name, (long)erval.encoded); @@ -634,10 +679,16 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, */ ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key); ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size); - if (ret == -1) _ASN_ENCODE_FAILED; + if (ret == -1) + { + _ASN_ENCODE_FAILED; + } erval.encoded = computed_size + ret; - if (!cb) _ASN_ENCODED_OK(erval); + if (!cb) + { + _ASN_ENCODED_OK(erval); + } /* * Encode all members. @@ -651,7 +702,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } } else { @@ -659,17 +713,22 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, } tmperval = elm->type->der_encoder( elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); - if (tmperval.encoded == -1) return tmperval; + if (tmperval.encoded == -1) + { + return tmperval; + } computed_size -= tmperval.encoded; ASN_DEBUG("Member %d %s of SEQUENCE %s encoded in %ld bytes", edx, elm->name, td->name, (long)tmperval.encoded); } if (computed_size != 0) - /* + { + /* * Encoded size is not equal to the computed size. */ - _ASN_ENCODE_FAILED; + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(erval); } @@ -717,7 +776,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); - if (st == 0) RETURN(RC_FAIL); + if (st == 0) + { + RETURN(RC_FAIL); + } } /* @@ -769,7 +831,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); - if (tmprval.code != RC_OK) RETURN(tmprval.code); + if (tmprval.code != RC_OK) + { + RETURN(tmprval.code); + } ctx->phase = 1; /* Back to body processing */ ctx->step = ++edx; ASN_DEBUG("XER/SEQUENCE phase => %d, step => %d", @@ -827,7 +892,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, switch (tcv) { case XCT_CLOSING: - if (ctx->phase == 0) break; + if (ctx->phase == 0) + { + break; + } ctx->phase = 0; /* Fall through */ case XCT_BOTH: @@ -879,7 +947,9 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, */ edx_end = edx + elements[edx].optional + 1; if (edx_end > td->elements_count) - edx_end = td->elements_count; + { + edx_end = td->elements_count; + } for (n = edx; n < edx_end; n++) { elm = &td->elements[n]; @@ -904,7 +974,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, } break; } - if (n != edx_end) continue; + if (n != edx_end) + { + continue; + } } else { @@ -965,7 +1038,10 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int xcan = (flags & XER_F_CANONICAL); int edx; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -982,7 +1058,10 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } @@ -992,19 +1071,28 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, memb_ptr = (void *)((char *)sptr + elm->memb_offset); } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); /* Print the member itself */ tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -1017,12 +1105,17 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, int edx; int ret; - if (!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!sptr) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* Dump preamble */ if (cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) - return -1; + { + return -1; + } for (edx = 0; edx < td->elements_count; edx++) { @@ -1035,7 +1128,10 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Print line */ /* Fall through */ } @@ -1052,12 +1148,17 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, /* Print the member's name and stuff */ if (cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) - return -1; + { + return -1; + } /* Print the member itself */ ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } ilevel--; @@ -1070,7 +1171,10 @@ void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { int edx; - if (!td || !sptr) return; + if (!td || !sptr) + { + return; + } ASN_DEBUG("Freeing %s as SEQUENCE", td->name); @@ -1081,7 +1185,10 @@ void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) if (elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); - if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); + if (memb_ptr) + { + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } } else { @@ -1122,7 +1229,10 @@ int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, elm->memb_offset); if (!memb_ptr) { - if (elm->optional) continue; + if (elm->optional) + { + continue; + } _ASN_CTFAIL( app_key, td, sptr, "%s: mandatory element %s absent (%s:%d)", @@ -1140,13 +1250,19 @@ int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, { int ret = elm->memb_constraints(elm->type, memb_ptr, ctfailcb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } else { int ret = elm->type->check_constraints(elm->type, memb_ptr, ctfailcb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } /* * Cannot inherit it earlier: * need to make sure we get the updated version. @@ -1173,12 +1289,18 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, (void)constraints; - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + _ASN_DECODE_FAILED; + } if (!st) { st = *sptr = CALLOC(1, specs->struct_size); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name); @@ -1187,7 +1309,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (specs->ext_before >= 0) { extpresent = per_get_few_bits(pd, 1); - if (extpresent < 0) _ASN_DECODE_STARVED; + if (extpresent < 0) + { + _ASN_DECODE_STARVED; + } } else { @@ -1199,7 +1324,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (specs->roms_count) { opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1); - if (!opres) _ASN_DECODE_FAILED; + if (!opres) + { + _ASN_DECODE_FAILED; + } /* Get the presence map */ if (per_get_many_bits(pd, opres, 0, specs->roms_count)) { @@ -1225,7 +1353,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ - if (IN_EXTENSION_GROUP(specs, edx)) continue; + if (IN_EXTENSION_GROUP(specs, edx)) + { + continue; + } /* Fetch the pointer to this member */ if (elm->flags & ATF_POINTER) @@ -1289,12 +1420,18 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_per_data_t epmd; bmlength = uper_get_nslength(pd); - if (bmlength < 0) _ASN_DECODE_STARVED; + if (bmlength < 0) + { + _ASN_DECODE_STARVED; + } ASN_DEBUG("Extensions %d present in %s", bmlength, td->name); epres = (uint8_t *)MALLOC((bmlength + 15) >> 3); - if (!epres) _ASN_DECODE_STARVED; + if (!epres) + { + _ASN_DECODE_STARVED; + } /* Get the extensions map */ if (per_get_many_bits(pd, epres, 0, bmlength)) @@ -1337,7 +1474,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, present = per_get_few_bits(&epmd, 1); if (present <= 0) { - if (present < 0) break; /* No more extensions */ + if (present < 0) + { + break; /* No more extensions */ + } continue; } @@ -1384,13 +1524,19 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_member_t *elm = &td->elements[edx]; void **memb_ptr2; /* Pointer to member pointer */ - if (!elm->default_value) continue; + if (!elm->default_value) + { + continue; + } /* Fetch the pointer to this member */ if (elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)st + elm->memb_offset); - if (*memb_ptr2) continue; + if (*memb_ptr2) + { + continue; + } } else { @@ -1417,7 +1563,10 @@ static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr, int exts_count = 0; int edx; - if (specs->ext_before < 0) return 0; + if (specs->ext_before < 0) + { + return 0; + } /* Find out which extensions are present */ for (edx = specs->ext_after + 1; edx < td->elements_count; edx++) @@ -1453,12 +1602,17 @@ static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr, exts_present += present; /* Encode as presence marker */ - if (po1 && per_put_few_bits(po1, present, 1)) return -1; + if (po1 && per_put_few_bits(po1, present, 1)) + { + return -1; + } /* Encode as open type field */ if (po2 && present && uper_open_type_put(elm->type, elm->per_constraints, *memb_ptr2, po2)) - return -1; + { + return -1; + } } return exts_present ? exts_count : 0; @@ -1476,7 +1630,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, (void)constraints; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -1523,13 +1680,18 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, /* Eliminate default values */ if (present && elm->default_value && elm->default_value(0, memb_ptr2) == 1) - present = 0; + { + present = 0; + } ASN_DEBUG("Element %s %s %s->%s is %s", elm->flags & ATF_POINTER ? "ptr" : "inline", elm->default_value ? "def" : "wtv", td->name, elm->name, present ? "present" : "absent"); - if (per_put_few_bits(po, present, 1)) _ASN_ENCODE_FAILED; + if (per_put_few_bits(po, present, 1)) + { + _ASN_ENCODE_FAILED; + } } /* @@ -1545,7 +1707,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ - if (IN_EXTENSION_GROUP(specs, edx)) continue; + if (IN_EXTENSION_GROUP(specs, edx)) + { + continue; + } ASN_DEBUG("About to encode %s", elm->type->name); @@ -1557,7 +1722,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, { ASN_DEBUG("Element %s %d not present", elm->name, edx); - if (elm->optional) continue; + if (elm->optional) + { + continue; + } /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } @@ -1570,31 +1738,46 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, /* Eliminate default values */ if (elm->default_value && elm->default_value(0, memb_ptr2) == 1) - continue; + { + continue; + } ASN_DEBUG("Encoding %s->%s", td->name, elm->name); er = elm->type->uper_encoder(elm->type, elm->per_constraints, *memb_ptr2, po); - if (er.encoded == -1) return er; + if (er.encoded == -1) + { + return er; + } } /* No extensions to encode */ - if (!n_extensions) _ASN_ENCODED_OK(er); + if (!n_extensions) + { + _ASN_ENCODED_OK(er); + } ASN_DEBUG("Length of %d bit-map", n_extensions); /* #18.8. Write down the presence bit-map length. */ - if (uper_put_nslength(po, n_extensions)) _ASN_ENCODE_FAILED; + if (uper_put_nslength(po, n_extensions)) + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Bit-map of %d elements", n_extensions); /* #18.7. Encoding the extensions presence bit-map. */ /* TODO: act upon NOTE in #18.7 for canonical PER */ if (SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } ASN_DEBUG("Writing %d extensions", n_extensions); /* #18.9. Encode extensions as open type fields. */ if (SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } _ASN_ENCODED_OK(er); } diff --git a/src/core/libs/supl/asn-supl/constr_SEQUENCE_OF.c b/src/core/libs/supl/asn-supl/constr_SEQUENCE_OF.c index afdfa64a2..7dd683d73 100644 --- a/src/core/libs/supl/asn-supl/constr_SEQUENCE_OF.c +++ b/src/core/libs/supl/asn-supl/constr_SEQUENCE_OF.c @@ -30,10 +30,16 @@ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for (edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } computed_size += erval.encoded; } @@ -65,10 +71,16 @@ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for (edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, cb, app_key); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } encoding_size += erval.encoded; } @@ -108,7 +120,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int xcan = (flags & XER_F_CANONICAL); int i; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } er.encoded = 0; @@ -116,22 +131,34 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, { asn_enc_rval_t tmper; void *memb_ptr = list->array[i]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } if (mname) { - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); } tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } if (tmper.encoded == 0 && specs->as_XMLValueList) { const char *name = elm->type->xml_tag; size_t len = strlen(name); - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel + 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel + 1); + } _ASN_CALLBACK3("<", 1, name, len, "/>", 2); } @@ -144,7 +171,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded += (2 * mlen) + tmper.encoded; } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } _ASN_ENCODED_OK(er); cb_failed: @@ -161,7 +191,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, asn_TYPE_member_t *elm = td->elements; int seq; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } list = _A_SEQUENCE_FROM_VOID(sptr); er.encoded = 0; @@ -169,11 +202,17 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count); if (constraints) - ct = &constraints->size; + { + ct = &constraints->size; + } else if (td->per_constraints) - ct = &td->per_constraints->size; + { + ct = &td->per_constraints->size; + } else - ct = 0; + { + ct = 0; + } /* If extensible constraint, check if size is in root */ if (ct) @@ -186,11 +225,18 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, { /* Declare whether size is in extension root */ if (per_put_few_bits(po, not_in_root, 1)) - _ASN_ENCODE_FAILED; - if (not_in_root) ct = 0; + { + _ASN_ENCODE_FAILED; + } + if (not_in_root) + { + ct = 0; + } } else if (not_in_root && ct->effective_bits >= 0) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } if (ct && ct->effective_bits >= 0) @@ -198,13 +244,18 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, /* X.691, #19.5: No length determinant */ if (per_put_few_bits(po, list->count - ct->lower_bound, ct->effective_bits)) - _ASN_ENCODE_FAILED; + { + _ASN_ENCODE_FAILED; + } } for (seq = -1; seq < list->count;) { ssize_t mayEncode; - if (seq < 0) seq = 0; + if (seq < 0) + { + seq = 0; + } if (ct && ct->effective_bits >= 0) { mayEncode = list->count; @@ -212,16 +263,25 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, else { mayEncode = uper_put_length(po, list->count - seq); - if (mayEncode < 0) _ASN_ENCODE_FAILED; + if (mayEncode < 0) + { + _ASN_ENCODE_FAILED; + } } while (mayEncode--) { void *memb_ptr = list->array[seq++]; - if (!memb_ptr) _ASN_ENCODE_FAILED; + if (!memb_ptr) + { + _ASN_ENCODE_FAILED; + } er = elm->type->uper_encoder( elm->type, elm->per_constraints, memb_ptr, po); - if (er.encoded == -1) _ASN_ENCODE_FAILED; + if (er.encoded == -1) + { + _ASN_ENCODE_FAILED; + } } } 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 25638af5d..2be5881d6 100644 --- a/src/core/libs/supl/asn-supl/constr_SET_OF.c +++ b/src/core/libs/supl/asn-supl/constr_SET_OF.c @@ -140,7 +140,9 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, } if (ctx->left >= 0) - ctx->left += rval.consumed; /* ?Subtracted below! */ + { + ctx->left += rval.consumed; /* ?Subtracted below! */ + } ADVANCE(rval.consumed); ASN_DEBUG( @@ -160,7 +162,10 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, { ssize_t tag_len; /* Length of TLV's T */ - if (ctx->step & 1) goto microphase2; + if (ctx->step & 1) + { + goto microphase2; + } /* * MICROPHASE 1: Synchronize decoding. @@ -184,7 +189,10 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, switch (tag_len) { case 0: - if (!SIZE_VIOLATION) RETURN(RC_WMORE); + if (!SIZE_VIOLATION) + { + RETURN(RC_WMORE); + } /* Fall through */ case -1: RETURN(RC_FAIL); @@ -195,9 +203,13 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, if (LEFT < 2) { if (SIZE_VIOLATION) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - RETURN(RC_WMORE); + { + RETURN(RC_WMORE); + } } else if (((const uint8_t *)ptr)[1] == 0) { @@ -255,9 +267,13 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); if (ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } else - ctx->ptr = 0; + { + ctx->ptr = 0; + } } break; case RC_WMORE: /* More data expected */ @@ -327,7 +343,10 @@ 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; - if (el_buf->length + size > el_buf->size) return -1; + if (el_buf->length + size > el_buf->size) + { + return -1; + } memcpy(el_buf->buf + el_buf->length, buffer, size); @@ -342,17 +361,25 @@ static int _el_buf_cmp(const void *ap, const void *bp) size_t common_len; if (a->length < b->length) - common_len = a->length; + { + common_len = a->length; + } else - common_len = b->length; + { + common_len = b->length; + } ret = memcmp(a->buf, b->buf, common_len); if (ret == 0) { if (a->length < b->length) - ret = -1; + { + ret = -1; + } else if (a->length > b->length) - ret = 1; + { + ret = 1; + } } return ret; @@ -386,14 +413,22 @@ 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]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); - if (erval.encoded == -1) return erval; + if (erval.encoded == -1) + { + return erval; + } computed_size += erval.encoded; /* Compute maximum encoding's size */ if (max_encoded_len < (size_t)erval.encoded) - max_encoded_len = erval.encoded; + { + max_encoded_len = erval.encoded; + } } /* @@ -441,7 +476,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, void *memb_ptr = list->array[edx]; struct _el_buffer *encoded_el = &encoded_els[eels_count]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } /* * Prepare space for encoding. @@ -454,7 +492,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, } else { - for (edx--; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf); + for (edx--; edx >= 0; edx--) + { + FREEMEM(encoded_els[edx].buf); + } FREEMEM(encoded_els); erval.encoded = -1; erval.failed_type = td; @@ -469,7 +510,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, encoded_el); if (erval.encoded == -1) { - for (; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf); + for (; edx >= 0; edx--) + { + FREEMEM(encoded_els[edx].buf); + } FREEMEM(encoded_els); return erval; } @@ -493,7 +537,9 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, /* Report encoded chunks to the application */ if (ret == 0 && cb(encoded_el->buf, encoded_el->length, app_key) < 0) - ret = -1; + { + ret = -1; + } FREEMEM(encoded_el->buf); } FREEMEM(encoded_els); @@ -558,7 +604,10 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, if (st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); - if (st == 0) RETURN(RC_FAIL); + if (st == 0) + { + RETURN(RC_FAIL); + } } /* Which tag is expected for the downstream */ @@ -604,7 +653,9 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, { asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); if (ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); + { + RETURN(RC_FAIL); + } ctx->ptr = 0; XER_ADVANCE(tmprval.consumed); } @@ -646,7 +697,10 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, switch (tcv) { case XCT_CLOSING: - if (ctx->phase == 0) break; + if (ctx->phase == 0) + { + break; + } ctx->phase = 0; /* Fall through */ case XCT_BOTH: @@ -705,7 +759,10 @@ static int SET_OF_encode_xer_callback(const void *buffer, size_t size, { size_t newsize = (t->size << 2) + size; void *p = REALLOC(t->buffer, newsize); - if (!p) return -1; + if (!p) + { + return -1; + } t->buffer = p; t->size = newsize; } @@ -719,12 +776,24 @@ static int SET_OF_xer_order(const void *aptr, const void *bptr) const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; size_t minlen = a->offset; int ret; - if (b->offset < minlen) minlen = b->offset; + if (b->offset < minlen) + { + minlen = b->offset; + } /* Well-formed UTF-8 has this nice lexicographical property... */ ret = memcmp(a->buffer, b->buffer, minlen); - if (ret != 0) return ret; - if (a->offset == b->offset) return 0; - if (a->offset == minlen) return -1; + if (ret != 0) + { + return ret; + } + if (a->offset == b->offset) + { + return 0; + } + if (a->offset == minlen) + { + return -1; + } return 1; } @@ -747,12 +816,18 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *original_cb = cb; int i; - if (!sptr) _ASN_ENCODE_FAILED; + if (!sptr) + { + _ASN_ENCODE_FAILED; + } if (xcan) { encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); - if (!encs) _ASN_ENCODE_FAILED; + if (!encs) + { + _ASN_ENCODE_FAILED; + } cb = SET_OF_encode_xer_callback; } @@ -763,7 +838,10 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, asn_enc_rval_t tmper; void *memb_ptr = list->array[i]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } if (encs) { @@ -774,12 +852,17 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if (mname) { - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel); + } _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); } if (!xcan && specs->as_XMLValueList == 1) - _i_ASN_TEXT_INDENT(1, ilevel + 1); + { + _i_ASN_TEXT_INDENT(1, ilevel + 1); + } tmper = elm->type->xer_encoder( elm->type, memb_ptr, ilevel + (specs->as_XMLValueList != 2), flags, cb, app_key); @@ -805,7 +888,10 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, er.encoded += (2 * mlen) + tmper.encoded; } - if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + if (!xcan) + { + _i_ASN_TEXT_INDENT(1, ilevel - 1); + } if (encs) { @@ -838,7 +924,9 @@ cleanup: while (encs_count-- > 0) { if (encs[encs_count].buffer) - FREEMEM(encs[encs_count].buffer); + { + FREEMEM(encs[encs_count].buffer); + } } FREEMEM(encs); } @@ -853,23 +941,34 @@ int SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, int ret; int i; - if (!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + if (!sptr) + { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } /* Dump preamble */ if (cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) - return -1; + { + return -1; + } for (i = 0; i < list->count; i++) { const void *memb_ptr = list->array[i]; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } _i_INDENT(1); ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } ilevel--; @@ -895,7 +994,10 @@ void SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) for (i = 0; i < list->count; i++) { void *memb_ptr = list->array[i]; - if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); + if (memb_ptr) + { + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } } list->count = 0; /* No meaningful elements left */ @@ -932,7 +1034,10 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } constr = elm->memb_constraints; - if (!constr) constr = elm->type->check_constraints; + if (!constr) + { + constr = elm->type->check_constraints; + } /* * Iterate over the members of an array. @@ -943,10 +1048,16 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, const void *memb_ptr = list->array[i]; int ret; - if (!memb_ptr) continue; + if (!memb_ptr) + { + continue; + } ret = constr(elm->type, memb_ptr, ctfailcb, app_key); - if (ret) return ret; + if (ret) + { + return ret; + } } /* @@ -954,7 +1065,9 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, * need to make sure we get the updated version. */ if (!elm->memb_constraints) - elm->memb_constraints = elm->type->check_constraints; + { + elm->memb_constraints = elm->type->check_constraints; + } return 0; } @@ -973,7 +1086,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, int repeat = 0; ssize_t nelems; - if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; + if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + { + _ASN_DECODE_FAILED; + } /* * Create the target structure if it is not present already. @@ -981,23 +1097,38 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, if (!st) { st = *sptr = CALLOC(1, specs->struct_size); - if (!st) _ASN_DECODE_FAILED; + if (!st) + { + _ASN_DECODE_FAILED; + } } list = _A_SET_FROM_VOID(st); /* Figure out which constraints to use */ if (constraints) - ct = &constraints->size; + { + ct = &constraints->size; + } else if (td->per_constraints) - ct = &td->per_constraints->size; + { + ct = &td->per_constraints->size; + } else - ct = 0; + { + ct = 0; + } if (ct && ct->flags & APC_EXTENSIBLE) { int value = per_get_few_bits(pd, 1); - if (value < 0) _ASN_DECODE_STARVED; - if (value) ct = 0; /* Not restricted! */ + if (value < 0) + { + _ASN_DECODE_STARVED; + } + if (value) + { + ct = 0; /* Not restricted! */ + } } if (ct && ct->effective_bits >= 0) @@ -1006,7 +1137,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, nelems = per_get_few_bits(pd, ct->effective_bits); ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s", (long)nelems, ct->lower_bound, td->name); - if (nelems < 0) _ASN_DECODE_STARVED; + if (nelems < 0) + { + _ASN_DECODE_STARVED; + } nelems += ct->lower_bound; } else @@ -1022,7 +1156,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, &repeat); ASN_DEBUG("Got to decode %d elements (eff %d)", (int)nelems, (long)ct ? ct->effective_bits : -1); - if (nelems < 0) _ASN_DECODE_STARVED; + if (nelems < 0) + { + _ASN_DECODE_STARVED; + } } for (ssize_t k = 0; k < nelems; k++) @@ -1036,7 +1173,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, elm->type->name, rv.code, ptr); if (rv.code == RC_OK) { - if (ASN_SET_ADD(list, ptr) == 0) continue; + if (ASN_SET_ADD(list, ptr) == 0) + { + continue; + } ASN_DEBUG("Failed to add element into %s", td->name); /* Fall through */ @@ -1047,7 +1187,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, ASN_DEBUG("Failed decoding %s of %s (SET OF)", elm->type->name, td->name); } - if (ptr) ASN_STRUCT_FREE(*elm->type, ptr); + if (ptr) + { + ASN_STRUCT_FREE(*elm->type, ptr); + } return rv; } diff --git a/src/core/libs/supl/asn-supl/constr_TYPE.c b/src/core/libs/supl/asn-supl/constr_TYPE.c index 0e0cf4bda..193b42075 100644 --- a/src/core/libs/supl/asn-supl/constr_TYPE.c +++ b/src/core/libs/supl/asn-supl/constr_TYPE.c @@ -20,9 +20,15 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) { - if (tag_mode) return tag; + if (tag_mode) + { + return tag; + } - if (type_descriptor->tags_count) return type_descriptor->tags[0]; + if (type_descriptor->tags_count) + { + return type_descriptor->tags[0]; + } return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0); } @@ -32,7 +38,10 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor, */ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) { - if (!stream) stream = stdout; + if (!stream) + { + stream = stdout; + } if (!td || !struct_ptr) { errno = EINVAL; @@ -40,10 +49,16 @@ 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)) return -1; + if (td->print_struct(td, struct_ptr, 1, _print2fp, stream)) + { + return -1; + } /* Terminate the output */ - if (_print2fp("\n", 1, stream)) return -1; + if (_print2fp("\n", 1, stream)) + { + return -1; + } return fflush(stream); } @@ -53,7 +68,10 @@ static int _print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; - if (fwrite(buffer, 1, size, stream) != size) return -1; + if (fwrite(buffer, 1, size, stream) != size) + { + return -1; + } return 0; } diff --git a/src/core/libs/supl/asn-supl/constraints.c b/src/core/libs/supl/asn-supl/constraints.c index 3d96897ac..31dee7c77 100644 --- a/src/core/libs/supl/asn-supl/constraints.c +++ b/src/core/libs/supl/asn-supl/constraints.c @@ -49,7 +49,10 @@ static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, arg->failed_struct_ptr = sptr; maxlen = arg->errlen; - if (maxlen <= 0) return; + if (maxlen <= 0) + { + return; + } va_start(ap, fmt); vlen = vsnprintf(arg->errbuf, maxlen, fmt, ap); @@ -91,7 +94,10 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor, ret = type_descriptor->check_constraints(type_descriptor, struct_ptr, _asn_i_ctfailcb, &arg); - if (ret == -1 && errlen) *errlen = arg.errlen; + if (ret == -1 && errlen) + { + *errlen = arg.errlen; + } return ret; } diff --git a/src/core/libs/supl/asn-supl/der_encoder.c b/src/core/libs/supl/asn-supl/der_encoder.c index b65475a4d..76547e701 100644 --- a/src/core/libs/supl/asn-supl/der_encoder.c +++ b/src/core/libs/supl/asn-supl/der_encoder.c @@ -39,7 +39,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) enc_to_buf_arg *arg = (enc_to_buf_arg *)key; if (arg->left < size) - return -1; /* Data exceeds the available buffer size */ + { + return -1; /* Data exceeds the available buffer size */ + } memcpy(arg->buffer, buffer, size); arg->buffer = ((char *)arg->buffer) + size; @@ -114,7 +116,9 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, tags[0] = tag; stag_offset = -1 + ((tag_mode == -1) && sd->tags_count); for (i = 1; i < tags_count; i++) - tags[i] = sd->tags[i + stag_offset]; + { + tags[i] = sd->tags[i + stag_offset]; + } } else { @@ -123,7 +127,10 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, } /* No tags to write */ - if (tags_count == 0) return 0; + if (tags_count == 0) + { + return 0; + } lens = (ssize_t *)alloca(tags_count * sizeof(lens[0])); if (!lens) @@ -140,12 +147,18 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, for (i = tags_count - 1; i >= 0; --i) { lens[i] = der_write_TL(tags[i], overall_length, 0, 0, 0); - if (lens[i] == -1) return -1; + if (lens[i] == -1) + { + return -1; + } overall_length += lens[i]; lens[i] = overall_length - lens[i]; } - if (!cb) return overall_length - struct_length; + if (!cb) + { + return overall_length - struct_length; + } ASN_DEBUG("%s %s TL sequence (%d elements)", cb ? "Encoding" : "Estimating", sd->name, tags_count); @@ -162,7 +175,10 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, _constr = (last_tag_form || i < (tags_count - 1)); len = der_write_TL(tags[i], lens[i], cb, app_key, _constr); - if (len == -1) return -1; + if (len == -1) + { + return -1; + } } return overall_length - struct_length; @@ -179,24 +195,39 @@ static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len, /* Serialize tag (T from TLV) into possibly zero-length buffer */ tmp = ber_tlv_tag_serialize(tag, buf, buf_size); - if (tmp == -1 || tmp > (ssize_t)sizeof(buf)) return -1; + if (tmp == -1 || tmp > (ssize_t)sizeof(buf)) + { + return -1; + } size += tmp; /* Serialize length (L from TLV) into possibly zero-length buffer */ tmp = der_tlv_length_serialize(len, buf + size, buf_size ? buf_size - size : 0); - if (tmp == -1) return -1; + if (tmp == -1) + { + return -1; + } size += tmp; - if (size > sizeof(buf)) return -1; + if (size > sizeof(buf)) + { + return -1; + } /* * If callback is specified, invoke it, and check its return value. */ if (cb) { - if (constructed) *buf |= 0x20; - if (cb(buf, size, app_key) < 0) return -1; + if (constructed) + { + *buf |= 0x20; + } + if (cb(buf, size, app_key) < 0) + { + return -1; + } } return size; diff --git a/src/core/libs/supl/asn-supl/per_decoder.c b/src/core/libs/supl/asn-supl/per_decoder.c index cb9effce6..1374967f9 100644 --- a/src/core/libs/supl/asn-supl/per_decoder.c +++ b/src/core/libs/supl/asn-supl/per_decoder.c @@ -58,7 +58,9 @@ asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx, if (skip_bits < 0 || skip_bits > 7 || unused_bits < 0 || unused_bits > 7 || (unused_bits > 0 && !size)) - _ASN_DECODE_FAILED; + { + _ASN_DECODE_FAILED; + } /* * Stack checker requires that the codec context @@ -85,12 +87,18 @@ asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx, pd.buffer = (const uint8_t *)buffer; pd.nboff = skip_bits; pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from */ - if (pd.nboff > pd.nbits) _ASN_DECODE_FAILED; + if (pd.nboff > pd.nbits) + { + _ASN_DECODE_FAILED; + } /* * Invoke type-specific decoder. */ - if (!td->uper_decoder) _ASN_DECODE_FAILED; /* PER is not compiled in */ + if (!td->uper_decoder) + { + _ASN_DECODE_FAILED; /* PER is not compiled in */ + } rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd); if (rval.code == RC_OK) { diff --git a/src/core/libs/supl/asn-supl/per_encoder.c b/src/core/libs/supl/asn-supl/per_encoder.c index b0013b1ff..bce368190 100644 --- a/src/core/libs/supl/asn-supl/per_encoder.c +++ b/src/core/libs/supl/asn-supl/per_encoder.c @@ -25,7 +25,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) enc_to_buf_arg *arg = (enc_to_buf_arg *)key; if (arg->left < size) - return -1; /* Data exceeds the available buffer size */ + { + return -1; /* Data exceeds the available buffer size */ + } memcpy(arg->buffer, buffer, size); arg->buffer = ((char *)arg->buffer) + size; @@ -42,7 +44,10 @@ asn_enc_rval_t uper_encode_to_buffer(asn_TYPE_descriptor_t *td, void *sptr, key.buffer = buffer; key.left = buffer_size; - if (td) ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name); + if (td) + { + ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name); + } return uper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key); } @@ -117,7 +122,10 @@ static int _uper_encode_flush_outp(asn_per_outp_t *po) { uint8_t *buf; - if (po->nboff == 0 && po->buffer == po->tmpspace) return 0; + if (po->nboff == 0 && po->buffer == po->tmpspace) + { + return 0; + } buf = po->buffer + (po->nboff >> 3); /* Make sure we account for the last, partially filled */ @@ -143,7 +151,9 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, * Invoke type-specific encoder. */ if (!td || !td->uper_encoder) - _ASN_ENCODE_FAILED; /* PER is not compiled in */ + { + _ASN_ENCODE_FAILED; /* PER is not compiled in */ + } po.buffer = po.tmpspace; po.nboff = 0; @@ -162,7 +172,10 @@ 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)) _ASN_ENCODE_FAILED; + if (_uper_encode_flush_outp(&po)) + { + _ASN_ENCODE_FAILED; + } } return er; diff --git a/src/core/libs/supl/asn-supl/per_opentype.c b/src/core/libs/supl/asn-supl/per_opentype.c index 5a91e77ae..b48fc82ec 100644 --- a/src/core/libs/supl/asn-supl/per_opentype.c +++ b/src/core/libs/supl/asn-supl/per_opentype.c @@ -40,19 +40,31 @@ int uper_open_type_put(asn_TYPE_descriptor_t *td, ASN_DEBUG("Open type put %s ...", td->name); size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); - if (size <= 0) return -1; + if (size <= 0) + { + return -1; + } for (bptr = buf, toGo = size; toGo;) { ssize_t maySave = uper_put_length(po, toGo); - if (maySave < 0) break; - if (per_put_many_bits(po, bptr, maySave * 8)) break; + if (maySave < 0) + { + break; + } + if (per_put_many_bits(po, bptr, maySave * 8)) + { + break; + } bptr = (char *)bptr + maySave; toGo -= maySave; } FREEMEM(buf); - if (toGo) return -1; + if (toGo) + { + return -1; + } ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", td->name, size); @@ -241,7 +253,10 @@ static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex( UPDRESTOREPD; /* Skip data not consumed by the decoder */ - if (arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); + if (arg.unclaimed) + { + ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); + } if (arg.unclaimed) { switch (per_skip_bits(pd, arg.unclaimed)) @@ -288,9 +303,13 @@ int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); if (rv.code != RC_OK) - return -1; + { + return -1; + } else - return 0; + { + return 0; + } } /* @@ -310,7 +329,9 @@ static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *ctx, (void)sptr; while (per_get_few_bits(pd, 24) >= 0) - ; + { + ; + } rv.code = RC_OK; rv.consumed = pd->moved; @@ -340,7 +361,10 @@ static int uper_ugot_refill(asn_per_data_t *pd) if (arg->unclaimed) { /* Refill the container */ - if (per_get_few_bits(oldpd, 1)) return -1; + if (per_get_few_bits(oldpd, 1)) + { + return -1; + } if (oldpd->nboff == 0) { assert(0); @@ -362,7 +386,10 @@ static int uper_ugot_refill(asn_per_data_t *pd) next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", next_chunk_bytes, oldpd->moved, arg->repeat); - if (next_chunk_bytes < 0) return -1; + if (next_chunk_bytes < 0) + { + return -1; + } if (next_chunk_bytes == 0) { pd->refill = 0; /* No more refills, naturally */ @@ -399,9 +426,13 @@ static int per_skip_bits(asn_per_data_t *pd, int skip_nbits) { int skip = 0; if (skip_nbits < skip) - skip = skip_nbits; + { + skip = skip_nbits; + } else - skip = 24; + { + skip = 24; + } skip_nbits -= skip; switch (per_get_few_bits(pd, skip)) diff --git a/src/core/libs/supl/asn-supl/per_support.c b/src/core/libs/supl/asn-supl/per_support.c index 9fdc23629..c37a01cb4 100644 --- a/src/core/libs/supl/asn-supl/per_support.c +++ b/src/core/libs/supl/asn-supl/per_support.c @@ -41,20 +41,32 @@ int32_t per_get_few_bits(asn_per_data_t *pd, int nbits) uint32_t accum; const uint8_t *buf; - if (nbits < 0) return -1; + if (nbits < 0) + { + return -1; + } nleft = pd->nbits - pd->nboff; if (nbits > nleft) { int32_t tailv; int32_t vhead; - if (!pd->refill || nbits > 31) return -1; + if (!pd->refill || nbits > 31) + { + return -1; + } /* Accumulate unused bytes before refill */ ASN_DEBUG("Obtain the rest %d bits (want %d)", (int)nleft, nbits); tailv = per_get_few_bits(pd, nleft); - if (tailv < 0) return -1; + if (tailv < 0) + { + return -1; + } /* Refill (replace pd contents with new data) */ - if (pd->refill(pd)) return -1; + if (pd->refill(pd)) + { + return -1; + } nbits -= nleft; vhead = per_get_few_bits(pd, nbits); /* Combine the rest of previous pd with the head of new one */ @@ -80,14 +92,22 @@ int32_t per_get_few_bits(asn_per_data_t *pd, int nbits) * Extract specified number of bits. */ if (off <= 8) - accum = nbits ? (buf[0]) >> (8 - off) : 0; + { + accum = nbits ? (buf[0]) >> (8 - off) : 0; + } else if (off <= 16) - accum = ((buf[0] << 8) + buf[1]) >> (16 - off); + { + accum = ((buf[0] << 8) + buf[1]) >> (16 - off); + } else if (off <= 24) - accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off); + { + accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off); + } else if (off <= 31) - accum = ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3])) >> - (32 - off); + { + accum = ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3])) >> + (32 - off); + } else if (nbits <= 31) { asn_per_data_t tpd = *pd; @@ -129,7 +149,10 @@ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) { /* Perform right alignment of a first few bits */ value = per_get_few_bits(pd, nbits & 0x07); - if (value < 0) return -1; + if (value < 0) + { + return -1; + } *dst++ = value; /* value is already right-aligned */ nbits &= ~7; } @@ -139,7 +162,10 @@ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) if (nbits >= 24) { value = per_get_few_bits(pd, 24); - if (value < 0) return -1; + if (value < 0) + { + return -1; + } *(dst++) = value >> 16; *(dst++) = value >> 8; *(dst++) = value; @@ -148,14 +174,26 @@ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) else { value = per_get_few_bits(pd, nbits); - if (value < 0) return -1; + if (value < 0) + { + return -1; + } if (nbits & 7) { /* implies left alignment */ value <<= 8 - (nbits & 7), nbits += 8 - (nbits & 7); - if (nbits > 24) *dst++ = value >> 24; + if (nbits > 24) + { + *dst++ = value >> 24; + } + } + if (nbits > 16) + { + *dst++ = value >> 16; + } + if (nbits > 8) + { + *dst++ = value >> 8; } - if (nbits > 16) *dst++ = value >> 16; - if (nbits > 8) *dst++ = value >> 8; *dst++ = value; break; } @@ -219,7 +257,10 @@ ssize_t uper_get_nslength(asn_per_data_t *pd) if (per_get_few_bits(pd, 1) == 0) { length = per_get_few_bits(pd, 6) + 1; - if (length <= 0) return -1; + if (length <= 0) + { + return -1; + } ASN_DEBUG("l=%d", (int)length); return length; } @@ -227,7 +268,10 @@ ssize_t uper_get_nslength(asn_per_data_t *pd) { int repeat; length = uper_get_length(pd, -1, &repeat); - if (length >= 0 && !repeat) return length; + if (length >= 0 && !repeat) + { + return length; + } return -1; /* Error, or do not support >16K extensions */ } } @@ -246,10 +290,18 @@ ssize_t uper_get_nsnnwn(asn_per_data_t *pd) value &= 63; value <<= 2; value |= per_get_few_bits(pd, 2); - if (value & 128) /* implicit (value < 0) */ - return -1; - if (value == 0) return 0; - if (value >= 3) return -1; + if (value & 128) + { /* implicit (value < 0) */ + return -1; + } + if (value == 0) + { + return 0; + } + if (value >= 3) + { + return -1; + } value = per_get_few_bits(pd, 8 * value); return value; } @@ -267,18 +319,32 @@ int uper_put_nsnnwn(asn_per_outp_t *po, int n) if (n <= 63) { - if (n < 0) return -1; + if (n < 0) + { + return -1; + } return per_put_few_bits(po, n, 7); } if (n < 256) - bytes = 1; + { + bytes = 1; + } else if (n < 65536) - bytes = 2; + { + bytes = 2; + } else if (n < 256 * 65536) - bytes = 3; + { + bytes = 3; + } else - return -1; /* This is not a "normally small" value */ - if (per_put_few_bits(po, bytes, 8)) return -1; + { + return -1; /* This is not a "normally small" value */ + } + if (per_put_few_bits(po, bytes, 8)) + { + return -1; + } return per_put_few_bits(po, n, 8 * bytes); } @@ -293,17 +359,29 @@ int uper_get_constrained_whole_number(asn_per_data_t *pd, if (nbits <= 31) { half = per_get_few_bits(pd, nbits); - if (half < 0) return -1; + if (half < 0) + { + return -1; + } *out_value = half; return 0; } - if ((size_t)nbits > 8 * sizeof(*out_value)) return -1; /* RANGE */ + if ((size_t)nbits > 8 * sizeof(*out_value)) + { + return -1; /* RANGE */ + } half = per_get_few_bits(pd, 31); - if (half < 0) return -1; + if (half < 0) + { + return -1; + } - if (uper_get_constrained_whole_number(pd, &lhalf, nbits - 31)) return -1; + if (uper_get_constrained_whole_number(pd, &lhalf, nbits - 31)) + { + return -1; + } *out_value = ((unsigned long)half << (nbits - 31)) | lhalf; return 0; @@ -336,7 +414,9 @@ int uper_put_constrained_whole_number_u(asn_per_outp_t *po, unsigned long v, { /* Put higher portion first, followed by lower 31-bit */ if (uper_put_constrained_whole_number_u(po, v >> 31, nbits - 31)) - return -1; + { + return -1; + } return per_put_few_bits(po, v, 31); } } @@ -375,7 +455,10 @@ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) size_t omsk; /* Existing last byte meaningful bits mask */ uint8_t *buf; - if (obits <= 0 || obits >= 32) return obits ? -1 : 0; + if (obits <= 0 || obits >= 32) + { + return obits ? -1 : 0; + } ASN_DEBUG("[PER put %d bits %x to %p+%d bits]", obits, (int)bits, po->buffer, (int)po->nboff); @@ -396,13 +479,21 @@ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) if (po->nboff + obits > po->nbits) { size_t complete_bytes; - if (!po->buffer) po->buffer = po->tmpspace; + if (!po->buffer) + { + po->buffer = po->tmpspace; + } complete_bytes = (po->buffer - po->tmpspace); ASN_DEBUG("[PER output %ld complete + %ld]", (long)complete_bytes, (long)po->flushed_bytes); if (po->outper(po->tmpspace, complete_bytes, po->op_key) < 0) - return -1; - if (po->nboff) po->tmpspace[0] = po->buffer[0]; + { + return -1; + } + if (po->nboff) + { + po->tmpspace[0] = po->buffer[0]; + } po->buffer = po->tmpspace; po->nbits = 8 * sizeof(po->tmpspace); po->flushed_bytes += complete_bytes; @@ -422,27 +513,40 @@ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) (int)bits, (int)po->nboff, (int)off, buf[0], (int)(omsk & 0xff), (int)(buf[0] & omsk)); - if (off <= 8) /* Completely within 1 byte */ - po->nboff = off, bits <<= (8 - off), buf[0] = (buf[0] & omsk) | bits; + if (off <= 8) + { /* Completely within 1 byte */ + po->nboff = off, bits <<= (8 - off), buf[0] = (buf[0] & omsk) | bits; + } else if (off <= 16) - po->nboff = off, bits <<= (16 - off), - buf[0] = (buf[0] & omsk) | (bits >> 8), buf[1] = bits; + { + po->nboff = off, bits <<= (16 - off), + buf[0] = (buf[0] & omsk) | (bits >> 8), buf[1] = bits; + } else if (off <= 24) - po->nboff = off, bits <<= (24 - off), - buf[0] = (buf[0] & omsk) | (bits >> 16), buf[1] = bits >> 8, - buf[2] = bits; + { + po->nboff = off, bits <<= (24 - off), + buf[0] = (buf[0] & omsk) | (bits >> 16), buf[1] = bits >> 8, + buf[2] = bits; + } else if (off <= 31) - po->nboff = off, bits <<= (32 - off), - buf[0] = (buf[0] & omsk) | (bits >> 24), buf[1] = bits >> 16, - buf[2] = bits >> 8, buf[3] = bits; + { + po->nboff = off, bits <<= (32 - off), + buf[0] = (buf[0] & omsk) | (bits >> 24), buf[1] = bits >> 16, + buf[2] = bits >> 8, buf[3] = bits; + } else { if ((obits - 24) > 0) { if (per_put_few_bits(po, bits >> (obits - 24), 24)) - return -1; + { + return -1; + } + } + if (per_put_few_bits(po, bits, obits - 24)) + { + return -1; } - if (per_put_few_bits(po, bits, obits - 24)) return -1; } ASN_DEBUG("[PER out %u/%x => %02x buf+%ld]", (int)bits, (int)bits, buf[0], @@ -465,15 +569,30 @@ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int nbits) value = (src[0] << 16) | (src[1] << 8) | src[2]; src += 3; nbits -= 24; - if (per_put_few_bits(po, value, 24)) return -1; + if (per_put_few_bits(po, value, 24)) + { + return -1; + } } else { value = src[0]; - if (nbits > 8) value = (value << 8) | src[1]; - if (nbits > 16) value = (value << 8) | src[2]; - if (nbits & 0x07) value >>= (8 - (nbits & 0x07)); - if (per_put_few_bits(po, value, nbits)) return -1; + if (nbits > 8) + { + value = (value << 8) | src[1]; + } + if (nbits > 16) + { + value = (value << 8) | src[2]; + } + if (nbits & 0x07) + { + value >>= (8 - (nbits & 0x07)); + } + if (per_put_few_bits(po, value, nbits)) + { + return -1; + } break; } } @@ -486,13 +605,20 @@ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int nbits) */ ssize_t uper_put_length(asn_per_outp_t *po, size_t length) { - if (length <= 127) /* #10.9.3.6 */ - return per_put_few_bits(po, length, 8) ? -1 : (ssize_t)length; - else if (length < 16384) /* #10.9.3.7 */ - return per_put_few_bits(po, length | 0x8000, 16) ? -1 : (ssize_t)length; + if (length <= 127) + { /* #10.9.3.6 */ + return per_put_few_bits(po, length, 8) ? -1 : (ssize_t)length; + } + else if (length < 16384) + { /* #10.9.3.7 */ + return per_put_few_bits(po, length | 0x8000, 16) ? -1 : (ssize_t)length; + } length >>= 14; - if (length > 4) length = 4; + if (length > 4) + { + length = 4; + } return per_put_few_bits(po, 0xC0 | length, 8) ? -1 : (ssize_t)(length << 14); @@ -508,7 +634,10 @@ int uper_put_nslength(asn_per_outp_t *po, size_t length) if (length <= 64) { /* #10.9.3.4 */ - if (length == 0) return -1; + if (length == 0) + { + return -1; + } return per_put_few_bits(po, length - 1, 7) ? -1 : 0; } else diff --git a/src/core/libs/supl/asn-supl/xer_decoder.c b/src/core/libs/supl/asn-supl/xer_decoder.c index a027b0d11..4d1e28a1f 100644 --- a/src/core/libs/supl/asn-supl/xer_decoder.c +++ b/src/core/libs/supl/asn-supl/xer_decoder.c @@ -72,7 +72,10 @@ ssize_t xer_next_token(int *stateContext, const void *buffer, size_t size, arg.callback_not_invoked = 1; ret = pxml_parse(&new_stateContext, buffer, size, xer__token_cb, &arg); - if (ret < 0) return -1; + if (ret < 0) + { + return -1; + } if (arg.callback_not_invoked) { assert(ret == 0); /* No data was consumed */ @@ -121,7 +124,9 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, if (size < 2 || buf[0] != LANGLE || buf[size - 1] != RANGLE) { if (size >= 2) - ASN_DEBUG("Broken XML tag: \"%c...%c\"", buf[0], buf[size - 1]); + { + ASN_DEBUG("Broken XML tag: \"%c...%c\"", buf[0], buf[size - 1]); + } return XCT_BROKEN; } @@ -134,7 +139,9 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, size -= 3; /* strip "" */ ct = XCT_CLOSING; if (size > 0 && buf[size - 1] == CSLASH) - return XCT_BROKEN; /* */ + { + return XCT_BROKEN; /* */ + } } else { @@ -148,7 +155,10 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, } /* Sometimes we don't care about the tag */ - if (!need_tag || !*need_tag) return (xer_check_tag_e)(XCT__UNK__MASK | ct); + if (!need_tag || !*need_tag) + { + return (xer_check_tag_e)(XCT__UNK__MASK | ct); + } /* * Determine the tag name. @@ -174,9 +184,15 @@ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, } return (xer_check_tag_e)(XCT__UNK__MASK | ct); } - if (b == 0) return XCT_BROKEN; /* Embedded 0 in buf?! */ + if (b == 0) + { + return XCT_BROKEN; /* Embedded 0 in buf?! */ + } + } + if (*need_tag) + { + return (xer_check_tag_e)(XCT__UNK__MASK | ct); } - if (*need_tag) return (xer_check_tag_e)(XCT__UNK__MASK | ct); return ct; } @@ -246,7 +262,10 @@ asn_dec_rval_t xer_decode_general( * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. */ - if (ctx->phase > 1) RETURN(RC_FAIL); + if (ctx->phase > 1) + { + RETURN(RC_FAIL); + } for (;;) { pxer_chunk_type_e ch_type; /* XER chunk type */ @@ -305,19 +324,28 @@ asn_dec_rval_t xer_decode_general( switch (tcv) { case XCT_BOTH: - if (ctx->phase) break; + if (ctx->phase) + { + break; + } /* Finished decoding of an empty element */ XER_GOT_EMPTY(); ADVANCE(ch_size); ctx->phase = 2; /* Phase out */ RETURN(RC_OK); case XCT_OPENING: - if (ctx->phase) break; + if (ctx->phase) + { + break; + } ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; case XCT_CLOSING: - if (!ctx->phase) break; + if (!ctx->phase) + { + break; + } ADVANCE(ch_size); ctx->phase = 2; /* Phase out */ RETURN(RC_OK); @@ -397,7 +425,10 @@ int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth) return 0; case XCT_CLOSING: case XCT_UNKNOWN_CL: - if (--(*depth) == 0) return (tcv == XCT_CLOSING) ? 2 : 1; + if (--(*depth) == 0) + { + return (tcv == XCT_CLOSING) ? 2 : 1; + } return 0; default: return -1; diff --git a/src/core/libs/supl/asn-supl/xer_encoder.c b/src/core/libs/supl/asn-supl/xer_encoder.c index 584fbac1a..c04fd2dd7 100644 --- a/src/core/libs/supl/asn-supl/xer_encoder.c +++ b/src/core/libs/supl/asn-supl/xer_encoder.c @@ -19,7 +19,10 @@ asn_enc_rval_t xer_encode(asn_TYPE_descriptor_t *td, void *sptr, size_t mlen; int xcan = (xer_flags & XER_F_CANONICAL) ? 1 : 2; - if (!td || !sptr) goto cb_failed; + if (!td || !sptr) + { + goto cb_failed; + } mname = td->xml_tag; mlen = strlen(mname); @@ -27,7 +30,10 @@ asn_enc_rval_t xer_encode(asn_TYPE_descriptor_t *td, void *sptr, _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key); - if (tmper.encoded == -1) return tmper; + if (tmper.encoded == -1) + { + return tmper; + } _ASN_CALLBACK3("\n", xcan); @@ -46,7 +52,10 @@ static int xer__print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; - if (fwrite(buffer, 1, size, stream) != size) return -1; + if (fwrite(buffer, 1, size, stream) != size) + { + return -1; + } return 0; } @@ -55,11 +64,20 @@ int xer_fprint(FILE *stream, asn_TYPE_descriptor_t *td, void *sptr) { asn_enc_rval_t er; - if (!stream) stream = stdout; - if (!td || !sptr) return -1; + if (!stream) + { + stream = stdout; + } + if (!td || !sptr) + { + return -1; + } er = xer_encode(td, sptr, XER_F_BASIC, xer__print2fp, stream); - if (er.encoded == -1) return -1; + if (er.encoded == -1) + { + return -1; + } return fflush(stream); } diff --git a/src/core/libs/supl/asn-supl/xer_support.c b/src/core/libs/supl/asn-supl/xer_support.c index 1edf24f11..0ba225655 100644 --- a/src/core/libs/supl/asn-supl/xer_support.c +++ b/src/core/libs/supl/asn-supl/xer_support.c @@ -106,20 +106,28 @@ ssize_t pxml_parse(int *stateContext, const void *xmlbuf, size_t size, * Initial state: we're in the middle of some text, * or just have started. */ - if (C == LANGLE) /* We're now in the tag, probably */ - TOKEN_CB(PXML_TEXT, ST_TAG_START, 0); + if (C == LANGLE) + { /* We're now in the tag, probably */ + TOKEN_CB(PXML_TEXT, ST_TAG_START, 0); + } break; case ST_TAG_START: if (ALPHA(C) || (C == CSLASH)) - state = ST_TAG_BODY; + { + state = ST_TAG_BODY; + } else if (C == EXCLAM) - state = ST_COMMENT_WAIT_DASH1; + { + state = ST_COMMENT_WAIT_DASH1; + } else - /* + { + /* * Not characters and not whitespace. * Must be something like "3 < 4". */ - TOKEN_CB(PXML_TEXT, ST_TEXT, 1); /* Flush as data */ + TOKEN_CB(PXML_TEXT, ST_TEXT, 1); /* Flush as data */ + } break; case ST_TAG_BODY: switch (C) @@ -156,8 +164,10 @@ ssize_t pxml_parse(int *stateContext, const void *xmlbuf, size_t size, break; default: if (!WHITESPACE( - C)) /* Unquoted string value */ - state = ST_TAG_UNQUOTED_STRING; + C)) + { /* Unquoted string value */ + state = ST_TAG_UNQUOTED_STRING; + } } break; case ST_TAG_QUOTED_STRING: diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc index b3aa88208..fa0aa3f02 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc @@ -294,7 +294,9 @@ int GpsL1CADllPllTrackingTestFpga::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList);