From a99ceafe851ecccaca2633af258bee3e39179080 Mon Sep 17 00:00:00 2001 From: Victor Castillo Date: Sat, 17 Aug 2024 23:06:24 +0200 Subject: [PATCH] Fixed arithmetic operations on pointers --- src/algorithms/signal_source/libs/ion_gsms.cc | 4 ++-- .../signal_source/libs/ion_gsms_chunk_data.cc | 20 +++++++++---------- .../signal_source/libs/ion_gsms_chunk_data.h | 4 ++-- .../libs/ion_gsms_metadata_handler.cc | 13 +++++++++--- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/algorithms/signal_source/libs/ion_gsms.cc b/src/algorithms/signal_source/libs/ion_gsms.cc index c19011dfd..0c9670030 100644 --- a/src/algorithms/signal_source/libs/ion_gsms.cc +++ b/src/algorithms/signal_source/libs/ion_gsms.cc @@ -84,7 +84,7 @@ int IONGSMSFileSource::work( std::fread(io_buffer_.data(), sizeof(decltype(io_buffer_)::value_type), io_buffer_.size(), fd_); items_produced_.resize(output_items.size()); - for (int i = 0; i < items_produced_.size(); ++i) + for (std::size_t i = 0; i < items_produced_.size(); ++i) { items_produced_[i] = 0; } @@ -99,7 +99,7 @@ int IONGSMSFileSource::work( } } - for (int i = 0; i < items_produced_.size(); ++i) + for (std::size_t i = 0; i < items_produced_.size(); ++i) { produce(i, items_produced_[i]); } diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc index 03bcab79c..6e64e23a9 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc @@ -155,7 +155,7 @@ void IONGSMSChunkData::unpack_words(gr_vector_void_star& outputs, std::vector(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, out); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int8_t**)(out)); } else if (sample_bitsize <= 16) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, out); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int16_t**)(out)); } else if (sample_bitsize <= 32) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, out); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int32_t**)(out)); } else if (sample_bitsize <= 64) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, out); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int64_t**)(out)); } return sample_count; @@ -205,11 +205,11 @@ void IONGSMSChunkData::write_n_samples( uint8_t sample_bitsize, std::size_t sample_count, GnssMetadata::StreamEncoding stream_encoding, - void*& out) + OT** out) { if (lump_shift == GnssMetadata::Lump::shiftRight) { - auto* sample = static_cast(out); + auto* sample = static_cast(*out); sample += sample_count; for (std::size_t i = 0; i < sample_count; ++i) { @@ -222,7 +222,7 @@ void IONGSMSChunkData::write_n_samples( } else // if (lump_shift == GnssMetadata::Lump::shiftLeft || lump_shift == GnssMetadata::Lump::shiftUndefined) { - auto* sample = static_cast(out); + auto* sample = static_cast(*out); for (std::size_t i = 0; i < sample_count; ++i) { *sample = 0; @@ -233,7 +233,7 @@ void IONGSMSChunkData::write_n_samples( } } - out += sample_count * sizeof(OT); + (*out) += sample_count; } diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h index bc0c5834d..3081c823b 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h @@ -107,7 +107,7 @@ private: const GnssMetadata::Lump& lump, const GnssMetadata::IonStream& stream, GnssMetadata::StreamEncoding stream_encoding, - void*& out); + void** out); template void write_n_samples( @@ -116,7 +116,7 @@ private: uint8_t sample_bitsize, std::size_t sample_count, GnssMetadata::StreamEncoding stream_encoding, - void*& out); + OT** out); static void decode_sample(uint8_t sample_bitsize, auto* sample, GnssMetadata::StreamEncoding encoding); diff --git a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc index 47ae4e6ed..c5fccef61 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc +++ b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc @@ -70,9 +70,16 @@ std::vector IONGSMSMetadataHandler::make_stream_sources { for (const auto& stream : lump.Streams()) { - if (std::ranges::any_of(stream_ids.begin(), stream_ids.end(), [&](const std::string& it) { - return stream.Id() == it; - })) + bool found = false; + for (const auto & stream_id : stream_ids) + { + if (stream_id == stream.Id()) + { + found = true; + break; + } + } + if (found) { auto source = gnss_make_shared( configuration,