Replace C-style casts by C++ casts

This commit is contained in:
Carles Fernandez 2017-08-19 11:27:22 +02:00
parent 7a50c67de8
commit e7246d4565
13 changed files with 29 additions and 29 deletions

View File

@ -483,7 +483,7 @@ inline std::string & Rinex_Printer::rightJustify(std::string & s,
}
else
{
s.insert((std::string::size_type)0, length-s.length(), pad);
s.insert(static_cast<std::string::size_type>(0), length - s.length(), pad);
}
return s;
}
@ -614,13 +614,13 @@ inline std::string & Rinex_Printer::sci2for(std::string & aStr,
// (if it's negative, there's a leading '-'
if (aStr[0] == '.')
{
aStr.insert((std::string::size_type)0, 1, ' ');
aStr.insert(static_cast<std::string::size_type>(0), 1, ' ');
}
//If checkSwitch is false, add on one leading zero to the string
if (!checkSwitch)
{
aStr.insert((std::string::size_type)1, 1, '0');
aStr.insert(static_cast<std::string::size_type>(1), 1, '0');
}
return aStr;

View File

@ -284,7 +284,7 @@ float pcps_acquisition_fine_doppler_cc::estimate_input_power(gr_vector_const_voi
int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items)
{
// initialize acquisition algorithm
const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer
const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]); //Get the input samples pointer
DLOG(INFO) << "Channel: " << d_channel
<< " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN

View File

@ -387,7 +387,7 @@ int pcps_multithread_acquisition_cc::general_work(int noutput_items,
unsigned int num_dwells = std::min(static_cast<int>(d_max_dwells - d_in_dwell_count), ninput_items[0]);
for (unsigned int i = 0; i < num_dwells; i++)
{
memcpy(d_in_buffer[d_in_dwell_count++], (gr_complex*)input_items[i],
memcpy(d_in_buffer[d_in_dwell_count++], reinterpret_cast<const gr_complex*>(input_items[i]),
sizeof(gr_complex)*d_fft_size);
d_sample_counter += d_fft_size;
d_sample_counter_buffer.push_back(d_sample_counter);
@ -395,7 +395,7 @@ int pcps_multithread_acquisition_cc::general_work(int noutput_items,
if (ninput_items[0] > static_cast<int>(num_dwells))
{
d_sample_counter += d_fft_size * (ninput_items[0]-num_dwells);
d_sample_counter += d_fft_size * (ninput_items[0] - num_dwells);
}
}
else

View File

@ -730,10 +730,10 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items,
// Fill internal buffer with d_max_dwells signal blocks. This step ensures that
// consecutive signal blocks will be processed in multi-dwell operation. This is
// essential when d_bit_transition_flag = true.
unsigned int num_dwells = std::min(static_cast<int>(d_max_dwells-d_in_dwell_count), ninput_items[0]);
unsigned int num_dwells = std::min(static_cast<int>(d_max_dwells - d_in_dwell_count), ninput_items[0]);
for (unsigned int i = 0; i < num_dwells; i++)
{
memcpy(d_in_buffer[d_in_dwell_count++], (gr_complex*)input_items[i],
memcpy(d_in_buffer[d_in_dwell_count++], static_cast<const gr_complex*>(input_items[i]),
sizeof(gr_complex)*d_fft_size);
d_sample_counter += d_fft_size;
d_sample_counter_buffer.push_back(d_sample_counter);

View File

@ -67,7 +67,7 @@ beamformer::~beamformer()
int beamformer::work(int noutput_items,gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
gr_complex *out = (gr_complex *) output_items[0];
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
// channel output buffers
// gr_complex *ch1 = (gr_complex *) input_items[0];
// gr_complex *ch2 = (gr_complex *) input_items[1];
@ -86,7 +86,7 @@ int beamformer::work(int noutput_items,gr_vector_const_void_star &input_items,
sum = gr_complex(0,0);
for (int i = 0; i < GNSS_SDR_BEAMFORMER_CHANNELS; i++)
{
sum = sum + ((gr_complex*)input_items[i])[n] * weight_vector[i];
sum = sum + (reinterpret_cast<const gr_complex *>(input_items[i]))[n] * weight_vector[i];
}
out[n] = sum;
}

View File

@ -54,9 +54,9 @@ int complex_byte_to_float_x2::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_8sc_t *in = (const lv_8sc_t *) input_items[0];
float *out0 = (float*) output_items[0];
float *out1 = (float*) output_items[1];
const lv_8sc_t *in = reinterpret_cast<const lv_8sc_t *>(input_items[0]);
float *out0 = reinterpret_cast<float *>(output_items[0]);
float *out1 = reinterpret_cast<float *>(output_items[1]);
const float scalar = 1;
volk_8ic_s32f_deinterleave_32f_x2(out0, out1, in, scalar, noutput_items);
return noutput_items;

View File

@ -54,9 +54,9 @@ int cshort_to_float_x2::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_16sc_t *in = (const lv_16sc_t *) input_items[0];
float *out0 = (float*) output_items[0];
float *out1 = (float*) output_items[1];
const lv_16sc_t *in = reinterpret_cast<const lv_16sc_t *>(input_items[0]);
float *out0 = reinterpret_cast<float *>(output_items[0]);
float *out1 = reinterpret_cast<float *>(output_items[1]);
const float scalar = 1;
volk_16ic_s32f_deinterleave_32f_x2(out0, out1, in, scalar, noutput_items);
return noutput_items;

View File

@ -254,7 +254,7 @@ int signal_generator_c::general_work (int noutput_items __attribute__((unused)),
gr_vector_const_void_star &input_items __attribute__((unused)),
gr_vector_void_star &output_items)
{
gr_complex *out = (gr_complex *) output_items[0];
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
work_counter_++;

View File

@ -122,10 +122,10 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
d_symbols_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol;
memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GALILEO_INAV_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int));
memcpy(static_cast<unsigned short int*>(this->d_preambles_bits), static_cast<unsigned short int*>(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int));
// preamble bits to sampled symbols
d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * d_symbols_per_preamble);
d_preambles_symbols = static_cast<signed int*>(malloc(sizeof(signed int) * d_symbols_per_preamble));
int n = 0;
for (int i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++)
{

View File

@ -78,10 +78,10 @@ void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols
//create appropriate transition matrices
int *out0, *out1, *state0, *state1;
out0 = (int*)calloc( max_states, sizeof(int) );
out1 = (int*)calloc( max_states, sizeof(int) );
state0 = (int*)calloc( max_states, sizeof(int) );
state1 = (int*)calloc( max_states, sizeof(int) );
out0 = static_cast<int*>(calloc( max_states, sizeof(int) ));
out1 = static_cast<int*>(calloc( max_states, sizeof(int) ));
state0 = static_cast<int*>(calloc( max_states, sizeof(int) ));
state1 = static_cast<int*>(calloc( max_states, sizeof(int) ));
nsc_transit( out0, state0, 0, g_encoder, KK, nn );
nsc_transit( out1, state1, 1, g_encoder, KK, nn );

View File

@ -101,7 +101,7 @@ int gps_l2c_telemetry_decoder_cc::general_work (int noutput_items __attribute__(
u32 delay = 0;
//add the symbol to the decoder
u8 symbol_clip = (u8)(in[0].Prompt_I > 0) * 255;
u8 symbol_clip = static_cast<u8>(in[0].Prompt_I > 0) * 255;
flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay);
consume_each(1); //one by one

View File

@ -234,7 +234,7 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector
// get the next samples
for (int i = 0; i < d_n_smpls_in_history; i++)
{
smpls[i] = ((int)i_sym)*sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1 == -1 ? d_past_sample : samples[i_sym*sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1];
smpls[i] = static_cast<int>(i_sym) * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1 == -1 ? d_past_sample : samples[i_sym*sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1];
}
// update the pseudo correlations (IIR method) of the two possible alignments
@ -466,7 +466,7 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_by
{
int idx_bit = candidate_bit_it - msg_candidate.begin();
int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= (unsigned char)(*candidate_bit_it) << bit_pos_in_current_byte;
byte |= static_cast<unsigned char>(*candidate_bit_it) << bit_pos_in_current_byte;
ss << *candidate_bit_it;
if (idx_bit % bits_per_byte == bits_per_byte - 1)
{
@ -493,7 +493,7 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_b
for (std::vector<int>::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it)
{
int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= (unsigned char)(*candidate_bit_it) << bit_pos_in_current_byte;
byte |= static_cast<unsigned char>(*candidate_bit_it) << bit_pos_in_current_byte;
ss << *candidate_bit_it;
if (idx_bit % bits_per_byte == bits_per_byte - 1)
{

View File

@ -87,7 +87,7 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::forecast (int noutput_items,
{
if (noutput_items != 0)
{
ninput_items_required[0] = (int)d_vector_length*2; // set the required available samples in each call
ninput_items_required[0] = static_cast<int>(d_vector_length) * 2; // set the required available samples in each call
}
}
@ -173,7 +173,7 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc(
d_enable_tracking = false;
d_pull_in = false;
d_current_prn_length_samples = (int)d_vector_length;
d_current_prn_length_samples = static_cast<int>(d_vector_length);
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;