diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e2670c13..ec72710a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2352,14 +2352,14 @@ endif() ################################################################################ # Set compiler flags ################################################################################ +set(CXX_WARNING_FLAGS -Wall -Wextra) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) # Add warning flags # For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html - set(cxx_warning_flags -Wall -Wextra) if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) - add_compile_options("$<$:${cxx_warning_flags}>") + add_compile_options("$<$:${CXX_WARNING_FLAGS}>") else() - add_compile_options("$<$,CXX>:${cxx_warning_flags}>") + add_compile_options("$<$,CXX>:${CXX_WARNING_FLAGS}>") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") add_compile_options(-Wno-missing-field-initializers) @@ -2368,6 +2368,13 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) add_compile_options(-Wno-psabi) endif() endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) + add_compile_options("$<$:${CXX_WARNING_FLAGS}>") + else() + add_compile_options("$<$,CXX>:${CXX_WARNING_FLAGS}>") + endif() +endif() # Processor-architecture related flags # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html diff --git a/docs/changelog b/docs/changelog index 63ce184bb..57a0bc242 100644 --- a/docs/changelog +++ b/docs/changelog @@ -11,19 +11,24 @@ ### Improvements in Portability: - The CMake scripts now find dependencies in Debian's riscv64 architecture. +- Enable AVX2 kernels of the volk_gnsssdr library when using the Clang compiler. +- Added a CMake toolchain for building volk_gnsssdr in a Raspberry Pi. ### Improvements in Reliability: - Decoding of navigation messages no longer rely on implementation defined behavior for shifting left a signed integer. -- Removed usage of functions with insecure API (e.g., strcpy). +- Removed usage of functions with insecure API (e.g., strcpy, sprintf). - Added clang-tidy checks clang-analyzer-security.*, clang-analyzer-optin.portability.UnixAPI clang-tidy checks. Fixed raised warnings. +- Fixed cpplint.py runtime/printf and runtime/explicit errors. +- All constructors callable with one argument are marked with the keyword explicit. See MISRA C++:2008, 12-1-3 - All constructors that are callable with a single argument of fundamental type shall be declared explicit. ### Improvements in Usability: - Improved DLL-PLL binary dump MATLAB/Octave plot script. Old versions removed. - Simplified RTKLIB error log. +- Added a Python 3 plotting script to show relative performance of generic volk_gnsssdr kernels wrt SIMD fastest versions. diff --git a/src/algorithms/PVT/libs/geojson_printer.h b/src/algorithms/PVT/libs/geojson_printer.h index 56dcda070..099045aa1 100644 --- a/src/algorithms/PVT/libs/geojson_printer.h +++ b/src/algorithms/PVT/libs/geojson_printer.h @@ -48,7 +48,7 @@ class Pvt_Solution; class GeoJSON_Printer { public: - GeoJSON_Printer(const std::string& base_path = "."); + explicit GeoJSON_Printer(const std::string& base_path = "."); ~GeoJSON_Printer(); bool set_headers(const std::string& filename, bool time_tag_name = true); bool print_position(const std::shared_ptr& position, bool print_average_values); diff --git a/src/algorithms/PVT/libs/gpx_printer.h b/src/algorithms/PVT/libs/gpx_printer.h index 70cd84846..f8bd898fa 100644 --- a/src/algorithms/PVT/libs/gpx_printer.h +++ b/src/algorithms/PVT/libs/gpx_printer.h @@ -48,7 +48,7 @@ class Rtklib_Solver; class Gpx_Printer { public: - Gpx_Printer(const std::string& base_path = "."); + explicit Gpx_Printer(const std::string& base_path = "."); ~Gpx_Printer(); bool set_headers(const std::string& filename, bool time_tag_name = true); bool print_position(const std::shared_ptr& position, bool print_average_values); diff --git a/src/algorithms/PVT/libs/kml_printer.h b/src/algorithms/PVT/libs/kml_printer.h index b88491da4..d9b10e277 100644 --- a/src/algorithms/PVT/libs/kml_printer.h +++ b/src/algorithms/PVT/libs/kml_printer.h @@ -47,7 +47,7 @@ class Rtklib_Solver; class Kml_Printer { public: - Kml_Printer(const std::string& base_path = std::string(".")); + explicit Kml_Printer(const std::string& base_path = std::string(".")); ~Kml_Printer(); bool set_headers(const std::string& filename, bool time_tag_name = true); bool print_position(const std::shared_ptr& position, bool print_average_values); diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 75d9b72d7..ca71b51e1 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -89,7 +89,7 @@ public: /*! * \brief Default constructor. Creates GNSS Navigation and Observables RINEX files and their headers */ - Rinex_Printer(int version = 0, const std::string& base_path = "."); + explicit Rinex_Printer(int version = 0, const std::string& base_path = "."); /*! * \brief Default destructor. Closes GNSS Navigation and Observables RINEX files diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index a75e28962..b124203ba 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -97,7 +97,7 @@ using b_io_context = boost::asio::io_service; class Rtcm { public: - Rtcm(uint16_t port = 2101); //!< Default constructor that sets TCP port of the RTCM message server and RTCM Station ID. 2101 is the standard RTCM port according to the Internet Assigned Numbers Authority (IANA). See https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml + explicit Rtcm(uint16_t port = 2101); //!< Default constructor that sets TCP port of the RTCM message server and RTCM Station ID. 2101 is the standard RTCM port according to the Internet Assigned Numbers Authority (IANA). See https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml ~Rtcm(); /*! @@ -593,7 +593,7 @@ private: inline void encode_header() { char header[header_length + 1] = ""; - std::sprintf(header, "GS%4d", static_cast(body_length_)); + std::snprintf(header, header_length, "GS%4d", static_cast(body_length_)); std::memcpy(data_, header, header_length); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h index b026dae6f..30ca0102e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h @@ -214,7 +214,7 @@ public: private: friend pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_); - pcps_acquisition(const Acq_Conf& conf_); + explicit pcps_acquisition(const Acq_Conf& conf_); bool d_active; bool d_worker_active; bool d_cshort; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h index 2c79f1527..92b2d6e93 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h @@ -194,7 +194,7 @@ public: private: friend pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_); - pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_); + explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_); int compute_and_accumulate_grid(gr_vector_const_void_star& input_items); int estimate_Doppler(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index bb441890f..88106ef3f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -203,7 +203,7 @@ public: private: friend pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_); - pcps_acquisition_fpga(pcpsconf_fpga_t conf_); + explicit pcps_acquisition_fpga(pcpsconf_fpga_t conf_); bool d_active; bool d_make_2_steps; uint32_t d_doppler_index; diff --git a/src/algorithms/channel/libs/channel_fsm.h b/src/algorithms/channel/libs/channel_fsm.h index 332f8a2a5..03864861a 100644 --- a/src/algorithms/channel/libs/channel_fsm.h +++ b/src/algorithms/channel/libs/channel_fsm.h @@ -50,7 +50,7 @@ class ChannelFsm { public: ChannelFsm(); - ChannelFsm(std::shared_ptr acquisition); + explicit ChannelFsm(std::shared_ptr acquisition); void set_acquisition(std::shared_ptr acquisition); void set_tracking(std::shared_ptr tracking); diff --git a/src/algorithms/libs/opencl/fft_kernelstring.cc b/src/algorithms/libs/opencl/fft_kernelstring.cc index 338c13dbc..522efe2d2 100644 --- a/src/algorithms/libs/opencl/fft_kernelstring.cc +++ b/src/algorithms/libs/opencl/fft_kernelstring.cc @@ -66,7 +66,7 @@ static string num2str(int num) { char temp[200]; - sprintf(temp, "%d", num); + snprintf(temp, sizeof(temp), "%d", num); return string(temp); } @@ -814,7 +814,7 @@ createLocalMemfftKernelString(cl_fft_plan *plan) (*kInfo)->in_place_possible = 1; (*kInfo)->next = nullptr; (*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1)); - strcpy((*kInfo)->kernel_name, kernelName.c_str()); + snprintf((*kInfo)->kernel_name, sizeof((*kInfo)->kernel_name), kernelName.c_str()); unsigned int numWorkItemsPerXForm = n / radixArray[0]; unsigned int numWorkItemsPerWG = numWorkItemsPerXForm <= 64 ? 64 : numWorkItemsPerXForm; @@ -1035,7 +1035,7 @@ createGlobalFFTKernelString(cl_fft_plan *plan, int n, int BS, cl_fft_kernel_dir (*kInfo)->in_place_possible = 0; (*kInfo)->next = nullptr; (*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1)); - strcpy((*kInfo)->kernel_name, kernelName.c_str()); + snprintf((*kInfo)->kernel_name, sizeof((*kInfo)->kernel_name), kernelName.c_str()); insertVariables(localString, R1); diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index 533888af5..9f5de53bb 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -595,7 +595,7 @@ int valsol(const double *azel, const int *vsat, int n, vv = dot(v, v, nv); if (nv > nx && vv > CHISQR[nv - nx - 1]) { - sprintf(msg, "chi-square error nv=%d vv=%.1f cs=%.1f", nv, vv, CHISQR[nv - nx - 1]); + std::snprintf(msg, MAXSOLBUF, "chi-square error nv=%d vv=%.1f cs=%.1f", nv, vv, CHISQR[nv - nx - 1]); return 0; } /* large gdop check */ @@ -612,7 +612,7 @@ int valsol(const double *azel, const int *vsat, int n, dops(ns, azels, opt->elmin, dop); if (dop[0] <= 0.0 || dop[0] > opt->maxgdop) { - sprintf(msg, "gdop error nv=%d gdop=%.1f", nv, dop[0]); + std::snprintf(msg, MAXSOLBUF, "gdop error nv=%d gdop=%.1f", nv, dop[0]); return 0; } return 1; @@ -639,6 +639,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, int stat; int nv; int ns; + char msg_aux[128]; trace(3, "estpos : n=%d\n", n); @@ -658,7 +659,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, if (nv < NX) { - sprintf(msg, "lack of valid sats ns=%d", nv); + std::snprintf(msg_aux, sizeof(msg_aux), "lack of valid sats ns=%d", nv); break; } /* weight by variance */ @@ -674,7 +675,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, /* least square estimation */ if ((info = lsq(H, v, NX, nv, dx, Q))) { - sprintf(msg, "lsq error info=%d", info); + std::snprintf(msg_aux, sizeof(msg_aux), "lsq error info=%d", info); break; } for (j = 0; j < NX; j++) @@ -712,18 +713,19 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, free(v); free(H); free(var); - + msg = msg_aux; return stat; } } if (i >= MAXITR) { - sprintf(msg, "iteration divergent i=%d", i); + std::snprintf(msg_aux, sizeof(msg_aux), "iteration divergent i=%d", i); } free(v); free(H); free(var); + msg = msg_aux; return 0; } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc index 69d09599a..7bab22997 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc @@ -644,7 +644,7 @@ int decode_rtcm2(rtcm_t *rtcm) if (rtcm->outtype) { - sprintf(rtcm->msgtype, "RTCM %2d (%4d) zcnt=%7.1f staid=%3d seqno=%d", + std::snprintf(rtcm->msgtype, sizeof(rtcm->msgtype), "RTCM %2d (%4d) zcnt=%7.1f staid=%3d seqno=%d", type, rtcm->len, zcnt, staid, seqno); } if (type == 3 || type == 22 || type == 23 || type == 24) diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index e5c35e1aa..62db7d8ae 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -317,7 +317,7 @@ int decode_head1001(rtcm_t *rtcm, int *sync) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d %s nsat=%2d sync=%d", staid, + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d %s nsat=%2d sync=%d", staid, time_str(rtcm->time, 2), nsat, *sync); } return nsat; @@ -583,7 +583,7 @@ int decode_type1005(rtcm_t *rtcm) re[j] = rr[j] * 0.0001; } ecef2pos(re, pos); - sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] * R2D, pos[1] * R2D, + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] * R2D, pos[1] * R2D, pos[2]); } /* test station id */ @@ -644,7 +644,7 @@ int decode_type1006(rtcm_t *rtcm) re[j] = rr[j] * 0.0001; } ecef2pos(re, pos); - sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] * R2D, + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] * R2D, pos[1] * R2D, pos[2], anth); } /* test station id */ @@ -697,7 +697,7 @@ int decode_type1007(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d", staid); + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d", staid); } /* test station id */ if (!test_staid(rtcm, staid)) @@ -754,7 +754,7 @@ int decode_type1008(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d", staid); + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d", staid); } /* test station id */ if (!test_staid(rtcm, staid)) @@ -813,7 +813,7 @@ int decode_head1009(rtcm_t *rtcm, int *sync) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d %s nsat=%2d sync=%d", staid, + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d %s nsat=%2d sync=%d", staid, time_str(rtcm->time, 2), nsat, *sync); } return nsat; @@ -1127,7 +1127,7 @@ int decode_type1019(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); } if (!(sat = satno(sys, prn))) @@ -1228,7 +1228,7 @@ int decode_type1020(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%2d tk=%02.0f:%02.0f:%02.0f frq=%2d bn=%d tb=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d tk=%02.0f:%02.0f:%02.0f frq=%2d bn=%d tb=%d", prn, tk_h, tk_m, tk_s, geph.frq, bn, tb); } geph.sat = sat; @@ -1371,7 +1371,7 @@ int decode_type1029(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d text=%s", staid, rtcm->msg); + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d text=%s", staid, rtcm->msg); } return 0; } @@ -1469,7 +1469,7 @@ int decode_type1033(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d", staid); + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d", staid); } /* test station id */ if (!test_staid(rtcm, staid)) @@ -1619,7 +1619,7 @@ int decode_type1044(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%3d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%3d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); } if (!(sat = satno(sys, prn))) @@ -1732,7 +1732,7 @@ int decode_type1045(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", prn, eph.iode, week, eph.toes, toc, e5a_hs, e5a_dvs); } if (!(sat = satno(sys, prn))) @@ -1846,7 +1846,7 @@ int decode_type1046(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", prn, eph.iode, week, eph.toes, toc, e5a_hs, e5a_dvs); } if (!(sat = satno(sys, prn))) @@ -1963,7 +1963,7 @@ int decode_type1047(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); } if (!(sat = satno(sys, prn))) @@ -2077,7 +2077,7 @@ int decode_type63(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", + std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); } if (!(sat = satno(sys, prn))) @@ -2162,7 +2162,7 @@ int decode_ssr1_head(rtcm_t *rtcm, int sys, int *sync, int *iod, if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " %s nsat=%2d iod=%2d udi=%2d sync=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " %s nsat=%2d iod=%2d udi=%2d sync=%d", time_str(rtcm->time, 2), nsat, *iod, udi, *sync); } *hsize = i; @@ -2224,7 +2224,7 @@ int decode_ssr2_head(rtcm_t *rtcm, int sys, int *sync, int *iod, if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " %s nsat=%2d iod=%2d udi=%2d sync=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " %s nsat=%2d iod=%2d udi=%2d sync=%d", time_str(rtcm->time, 2), nsat, *iod, udi, *sync); } *hsize = i; @@ -2290,7 +2290,7 @@ int decode_ssr7_head(rtcm_t *rtcm, int sys, int *sync, int *iod, if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " %s nsat=%2d iod=%2d udi=%2d sync=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " %s nsat=%2d iod=%2d udi=%2d sync=%d", time_str(rtcm->time, 2), nsat, *iod, udi, *sync); } *hsize = i; @@ -3167,14 +3167,14 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, { if (q) { - q += sprintf(q, "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); + q += std::snprintf(q, sizeof(rtcm->msmtype[0]), "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); } } else { if (q) { - q += sprintf(q, "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); + q += std::snprintf(q, sizeof(rtcm->msmtype[0]), "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); } trace(2, "rtcm3 %d: unknown signal id=%2d\n", type, h->sigs[i]); @@ -3372,7 +3372,7 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - sprintf(msg, " staid=%4d %s nsat=%2d nsig=%2d iod=%2d ncell=%2d sync=%d", + std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d %s nsat=%2d nsig=%2d iod=%2d ncell=%2d sync=%d", staid, time_str(rtcm->time, 2), h->nsat, h->nsig, *iod, ncell, *sync); } return ncell; @@ -3893,7 +3893,7 @@ int decode_rtcm3(rtcm_t *rtcm) if (rtcm->outtype) { - sprintf(rtcm->msgtype, "RTCM %4d (%4d):", type, rtcm->len); + std::snprintf(rtcm->msgtype, sizeof(rtcm->msgtype), "RTCM %4d (%4d):", type, rtcm->len); } /* real-time input option */ if (strstr(rtcm->opt, "-RT_INP")) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 3bc8e2440..efec6edeb 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -476,34 +476,34 @@ int satid2no(const char *id) void satno2id(int sat, char *id) { int prn; + char id_aux[16]; switch (satsys(sat, &prn)) { case SYS_GPS: - sprintf(id, "G%02d", prn - MINPRNGPS + 1); + std::snprintf(id, sizeof(id_aux), "G%02d", prn - MINPRNGPS + 1); return; case SYS_GLO: - sprintf(id, "R%02d", prn - MINPRNGLO + 1); + snprintf(id, sizeof(id_aux), "R%02d", prn - MINPRNGLO + 1); return; case SYS_GAL: - sprintf(id, "E%02d", prn - MINPRNGAL + 1); + std::snprintf(id, sizeof(id_aux), "E%02d", prn - MINPRNGAL + 1); return; case SYS_QZS: - sprintf(id, "J%02d", prn - MINPRNQZS + 1); + std::snprintf(id, sizeof(id_aux), "J%02d", prn - MINPRNQZS + 1); return; case SYS_BDS: - sprintf(id, "C%02d", prn - MINPRNBDS + 1); + std::snprintf(id, sizeof(id_aux), "C%02d", prn - MINPRNBDS + 1); return; case SYS_IRN: - sprintf(id, "I%02d", prn - MINPRNIRN + 1); + std::snprintf(id, sizeof(id_aux), "I%02d", prn - MINPRNIRN + 1); return; case SYS_LEO: - sprintf(id, "L%02d", prn - MINPRNLEO + 1); + std::snprintf(id, sizeof(id_aux), "L%02d", prn - MINPRNLEO + 1); return; case SYS_SBS: - sprintf(id, "%03d", prn); + std::snprintf(id, sizeof(id_aux), "%03d", prn); return; } - std::strncpy(id, "", 1); } @@ -1448,7 +1448,7 @@ void matsprint(const double A[], int n, int m, int p, int q, std::string &buffer for (j = 0; j < m; j++) { char buf_[256]; - sprintf(buf_, " %*.*f", p, q, A[i + j * n]); + std::snprintf(buf_, sizeof(buf_), " %*.*f", p, q, A[i + j * n]); std::string s(buf_); buffer += s; } @@ -2073,7 +2073,7 @@ void time2str(gtime_t t, char *s, int n) t.sec = 0.0; }; time2epoch(t, ep); - sprintf(s, "%04.0f/%02.0f/%02.0f %02.0f:%02.0f:%0*.*f", ep[0], ep[1], ep[2], + std::snprintf(s, MAXSTATMSG, "%04.0f/%02.0f/%02.0f %02.0f:%02.0f:%0*.*f", ep[0], ep[1], ep[2], ep[3], ep[4], n <= 0 ? 2 : n + 3, n <= 0 ? 0 : n, ep[5]); } @@ -4147,7 +4147,7 @@ int repstr(char *str, const char *pat, const char *rep) } strncpy(r, p, q - p); r += q - p; - r += sprintf(r, "%s", rep); + r += std::snprintf(r, sizeof(buff), "%s", rep); } if (p <= str) { @@ -4227,35 +4227,35 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, ep0[0] = ep[0]; dow = static_cast(floor(time2gpst(time, &week) / 86400.0)); doy = static_cast(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1; - sprintf(rep, "%02d", (static_cast(ep[3]) / 3) * 3); + std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[3]) / 3) * 3); stat |= repstr(rpath, "%ha", rep); - sprintf(rep, "%02d", (static_cast(ep[3]) / 6) * 6); + std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[3]) / 6) * 6); stat |= repstr(rpath, "%hb", rep); - sprintf(rep, "%02d", (static_cast(ep[3]) / 12) * 12); + std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[3]) / 12) * 12); stat |= repstr(rpath, "%hc", rep); - sprintf(rep, "%04.0f", ep[0]); + std::snprintf(rep, sizeof(rep), "%04.0f", ep[0]); stat |= repstr(rpath, "%Y", rep); - sprintf(rep, "%02.0f", fmod(ep[0], 100.0)); + std::snprintf(rep, sizeof(rep), "%02.0f", fmod(ep[0], 100.0)); stat |= repstr(rpath, "%y", rep); - sprintf(rep, "%02.0f", ep[1]); + std::snprintf(rep, sizeof(rep), "%02.0f", ep[1]); stat |= repstr(rpath, "%m", rep); - sprintf(rep, "%02.0f", ep[2]); + std::snprintf(rep, sizeof(rep), "%02.0f", ep[2]); stat |= repstr(rpath, "%d", rep); - sprintf(rep, "%02.0f", ep[3]); + std::snprintf(rep, sizeof(rep), "%02.0f", ep[3]); stat |= repstr(rpath, "%h", rep); - sprintf(rep, "%02.0f", ep[4]); + std::snprintf(rep, sizeof(rep), "%02.0f", ep[4]); stat |= repstr(rpath, "%M", rep); - sprintf(rep, "%02.0f", floor(ep[5])); + std::snprintf(rep, sizeof(rep), "%02.0f", floor(ep[5])); stat |= repstr(rpath, "%S", rep); - sprintf(rep, "%03d", doy); + std::snprintf(rep, sizeof(rep), "%03d", doy); stat |= repstr(rpath, "%n", rep); - sprintf(rep, "%04d", week); + std::snprintf(rep, sizeof(rep), "%04d", week); stat |= repstr(rpath, "%W", rep); - sprintf(rep, "%d", dow); + std::snprintf(rep, sizeof(rep), "%d", dow); stat |= repstr(rpath, "%D", rep); - sprintf(rep, "%c", 'a' + static_cast(ep[3])); + std::snprintf(rep, sizeof(rep), "%c", 'a' + static_cast(ep[3])); stat |= repstr(rpath, "%H", rep); - sprintf(rep, "%02d", (static_cast(ep[4]) / 15) * 15); + std::snprintf(rep, sizeof(rep), "%02d", (static_cast(ep[4]) / 15) * 15); stat |= repstr(rpath, "%t", rep); } else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") || @@ -5114,7 +5114,7 @@ int rtk_uncompress(const char *file, char *uncfile) { std::strncpy(uncfile, tmpfile, 1024); uncfile[p - tmpfile] = '\0'; - sprintf(cmd, R"(gzip -f -d -c "%s" > "%s")", tmpfile, uncfile); + std::snprintf(cmd, sizeof(cmd), R"(gzip -f -d -c "%s" > "%s")", tmpfile, uncfile); if (execcmd(cmd)) { @@ -5144,8 +5144,6 @@ int rtk_uncompress(const char *file, char *uncfile) dir = fname; fname = p + 1; } - // sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile); - // NOTE: This sprintf triggers a format overflow warning. Replaced by: std::ostringstream temp; std::string s_aux1(dir); std::string s_aux2(tmpfile); @@ -5185,7 +5183,7 @@ int rtk_uncompress(const char *file, char *uncfile) { std::strncpy(uncfile, tmpfile, 1024); uncfile[p - tmpfile + 3] = *(p + 3) == 'D' ? 'O' : 'o'; - sprintf(cmd, R"(crx2rnx < "%s" > "%s")", tmpfile, uncfile); + std::snprintf(cmd, sizeof(cmd), R"(crx2rnx < "%s" > "%s")", tmpfile, uncfile); if (execcmd(cmd)) { @@ -5256,8 +5254,8 @@ int expath(const char *path, char *paths[], int nmax) { continue; } - sprintf(s1, "^%s$", d->d_name); - sprintf(s2, "^%s$", file); + std::snprintf(s1, sizeof(s1), "^%s$", d->d_name); + std::snprintf(s2, sizeof(s2), "^%s$", file); for (p = s1; *p; p++) { *p = static_cast(tolower(static_cast(*p))); @@ -5280,7 +5278,7 @@ int expath(const char *path, char *paths[], int nmax) } if (p && n < nmax) { - sprintf(paths[n++], "%s%s", dir, d->d_name); + std::snprintf(paths[n++], MAXSTRPATH, "%s%s", dir, d->d_name); } } closedir(dp); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 992faf97c..a269b4d70 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -524,7 +524,7 @@ void errmsg(rtk_t *rtk, const char *format, ...) int n; va_list ap; time2str(rtk->sol.time, tstr, 2); - n = sprintf(buff, "%s: ", tstr + 11); + n = std::snprintf(buff, sizeof(buff), "%s: ", tstr + 11); va_start(ap, format); n += vsprintf(buff + n, format, ap); va_end(ap); diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index 0e15c0db8..407d41f1e 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -64,7 +64,7 @@ /* write solution header to output stream ------------------------------------*/ void writesolhead(stream_t *stream, const solopt_t *solopt) { - unsigned char buff[1024]; + unsigned char buff[MAXSOLMSG]; int n; n = outsolheads(buff, solopt); strwrite(stream, buff, n); @@ -88,7 +88,7 @@ void saveoutbuf(rtksvr_t *svr, unsigned char *buff, int n, int index) void writesol(rtksvr_t *svr, int index) { solopt_t solopt = SOLOPT_DEFAULT; - unsigned char buff[1024]; + unsigned char buff[MAXSOLMSG]; int i; int n; @@ -1247,7 +1247,7 @@ void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg) sstat[i] = strstat(svr->stream + i, s); if (*s) { - p += sprintf(p, "(%d) %s ", i + 1, s); + p += std::snprintf(p, MAXSTRMSG, "(%d) %s ", i + 1, s); } } rtksvrunlock(svr); diff --git a/src/algorithms/libs/rtklib/rtklib_solution.cc b/src/algorithms/libs/rtklib/rtklib_solution.cc index caf9cf46f..1f47b97d1 100644 --- a/src/algorithms/libs/rtklib/rtklib_solution.cc +++ b/src/algorithms/libs/rtklib/rtklib_solution.cc @@ -1411,7 +1411,7 @@ int readsolstatt(char *files[], int nfile, gtime_t ts, gtime_t te, for (i = 0; i < nfile; i++) { - sprintf(path, "%s.stat", files[i]); + std::snprintf(path, sizeof(path), "%s.stat", files[i]); if (!(fp = fopen(path, "re"))) { trace(1, "readsolstatt: file open error %s\n", path); @@ -1447,7 +1447,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol, trace(3, "outecef:\n"); - p += snprintf(p, 255, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", + p += std::snprintf(p, MAXSOLBUF, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", s, sep, sol->rr[0], sep, sol->rr[1], sep, sol->rr[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(sol->qr[0]), sep, SQRT_SOL(sol->qr[1]), sep, SQRT_SOL(sol->qr[2]), sep, sqvar(sol->qr[3]), sep, sqvar(sol->qr[4]), sep, sqvar(sol->qr[5]), @@ -1481,15 +1481,15 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol, { deg2dms(pos[0] * R2D, dms1); deg2dms(pos[1] * R2D, dms2); - p += sprintf(p, "%s%s%4.0f%s%02.0f%s%08.5f%s%4.0f%s%02.0f%s%08.5f", s, sep, + p += std::snprintf(p, MAXSOLMSG, "%s%s%4.0f%s%02.0f%s%08.5f%s%4.0f%s%02.0f%s%08.5f", s, sep, dms1[0], sep, dms1[1], sep, dms1[2], sep, dms2[0], sep, dms2[1], sep, dms2[2]); } else { - p += sprintf(p, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); + p += std::snprintf(p, MAXSOLMSG, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); } - p += sprintf(p, "%s%10.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", + p += std::snprintf(p, MAXSOLMSG, "%s%10.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", sep, pos[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[2]), sep, sqvar(Q[5]), sep, sol->age, sep, sol->ratio); @@ -1520,7 +1520,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol, soltocov(sol, P); covenu(pos, P, Q); ecef2enu(pos, rr, enu); - p += sprintf(p, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", + p += std::snprintf(p, MAXSOLMSG, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", s, sep, enu[0], sep, enu[1], sep, enu[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[5]), sep, sqvar(Q[2]), sep, sol->age, sep, sol->ratio); @@ -1550,12 +1550,12 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) if (sol->stat <= SOLQ_NONE) { - p += sprintf(p, "$GPRMC,,,,,,,,,,,,"); + p += std::snprintf(p, MAXSOLBUF, "$GPRMC,,,,,,,,,,,,"); for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) { sum ^= *q; } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } time = gpst2utc(sol->time); @@ -1583,7 +1583,7 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) } deg2dms(fabs(pos[0]) * R2D, dms1); deg2dms(fabs(pos[1]) * R2D, dms2); - p += sprintf(p, "$GPRMC,%02.0f%02.0f%05.2f,A,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%4.2f,%4.2f,%02.0f%02.0f%02d,%.1f,%s,%s", + p += std::snprintf(p, MAXSOLBUF, "$GPRMC,%02.0f%02.0f%05.2f,A,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%4.2f,%4.2f,%02.0f%02.0f%02d,%.1f,%s,%s", ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", vel / KNOT2M, dir, ep[2], ep[1], static_cast(ep[0]) % 100, amag, emag, @@ -1592,7 +1592,7 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1616,12 +1616,12 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) if (sol->stat <= SOLQ_NONE) { - p += sprintf(p, "$GPGGA,,,,,,,,,,,,,,"); + p += std::snprintf(p, MAXSOLBUF, "$GPGGA,,,,,,,,,,,,,,"); for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) { sum ^= *q; } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } for (solq = 0; solq < 8; solq++) @@ -1646,7 +1646,7 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) h = 0; // geoidh(pos); deg2dms(fabs(pos[0]) * R2D, dms1); deg2dms(fabs(pos[1]) * R2D, dms2); - p += sprintf(p, "$GPGGA,%02.0f%02.0f%05.2f,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%d,%02d,%.1f,%.3f,M,%.3f,M,%.1f,", + p += std::snprintf(p, MAXSOLBUF, "$GPGGA,%02.0f%02.0f%05.2f,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%d,%02d,%.1f,%.3f,M,%.3f,M,%.1f,", ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", solq, sol->ns, dop, pos[2] - h, h, sol->age); @@ -1654,7 +1654,7 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1679,12 +1679,12 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, if (sol->stat <= SOLQ_NONE) { - p += sprintf(p, "$GPGSA,A,1,,,,,,,,,,,,,,,"); + p += std::snprintf(p, MAXSOLBUF, "$GPGSA,A,1,,,,,,,,,,,,,,,"); for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) { sum ^= *q; } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1713,25 +1713,25 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, if (nsat > 0) { s = p; - p += sprintf(p, "$GPGSA,A,%d", sol->stat <= 0 ? 1 : 3); + p += std::snprintf(p, MAXSOLBUF, "$GPGSA,A,%d", sol->stat <= 0 ? 1 : 3); for (i = 0; i < 12; i++) { if (i < nsat) { - p += sprintf(p, ",%02d", prn[i]); + p += std::snprintf(p, MAXSOLBUF, ",%02d", prn[i]); } else { - p += sprintf(p, ","); + p += std::snprintf(p, MAXSOLBUF, ","); } } dops(nsat, azel, 0.0, dop); - p += sprintf(p, ",%3.1f,%3.1f,%3.1f,1", dop[1], dop[2], dop[3]); + p += std::snprintf(p, MAXSOLBUF, ",%3.1f,%3.1f,%3.1f,1", dop[1], dop[2], dop[3]); for (q = s + 1, sum = 0; *q; q++) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GLGSA: glonass */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) @@ -1753,25 +1753,25 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, if (nsat > 0) { s = p; - p += sprintf(p, "$GLGSA,A,%d", sol->stat <= 0 ? 1 : 3); + p += std::snprintf(p, MAXSOLBUF, "$GLGSA,A,%d", sol->stat <= 0 ? 1 : 3); for (i = 0; i < 12; i++) { if (i < nsat) { - p += sprintf(p, ",%02d", prn[i] + 64); + p += std::snprintf(p, MAXSOLBUF, ",%02d", prn[i] + 64); } else { - p += sprintf(p, ","); + p += std::snprintf(p, MAXSOLBUF, ","); } } dops(nsat, azel, 0.0, dop); - p += sprintf(p, ",%3.1f,%3.1f,%3.1f,2", dop[1], dop[2], dop[3]); + p += std::snprintf(p, MAXSOLBUF, ",%3.1f,%3.1f,%3.1f,2", dop[1], dop[2], dop[3]); for (q = s + 1, sum = 0; *q; q++) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GAGSA: galileo */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) @@ -1793,25 +1793,25 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, if (nsat > 0) { s = p; - p += sprintf(p, "$GAGSA,A,%d", sol->stat <= 0 ? 1 : 3); + p += std::snprintf(p, MAXSOLBUF, "$GAGSA,A,%d", sol->stat <= 0 ? 1 : 3); for (i = 0; i < 12; i++) { if (i < nsat) { - p += sprintf(p, ",%02d", prn[i]); + p += std::snprintf(p, MAXSOLBUF, ",%02d", prn[i]); } else { - p += sprintf(p, ","); + p += std::snprintf(p, MAXSOLBUF, ","); } } dops(nsat, azel, 0.0, dop); - p += sprintf(p, ",%3.1f,%3.1f,%3.1f,3", dop[1], dop[2], dop[3]); + p += std::snprintf(p, MAXSOLBUF, ",%3.1f,%3.1f,%3.1f,3", dop[1], dop[2], dop[3]); for (q = s + 1, sum = 0; *q; q++) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); } return p - reinterpret_cast(buff); } @@ -1842,12 +1842,12 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, if (sol->stat <= SOLQ_NONE) { - p += sprintf(p, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,"); + p += std::snprintf(p, MAXSOLBUF, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,"); for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) { sum ^= *q; } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } /* GPGSV: gps/sbas */ @@ -1868,7 +1868,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, for (i = k = 0; i < nmsg; i++) { s = p; - p += sprintf(p, "$GPGSV,%d,%d,%02d", nmsg, i + 1, n); + p += std::snprintf(p, MAXSOLBUF, "$GPGSV,%d,%d,%02d", nmsg, i + 1, n); for (j = 0; j < 4; j++, k++) { @@ -1885,19 +1885,19 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; - p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); + p += std::snprintf(p, MAXSOLBUF, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else { - p += sprintf(p, ",,,,"); + p += std::snprintf(p, MAXSOLBUF, ",,,,"); } } - p += sprintf(p, ",1"); /* L1C/A */ + p += std::snprintf(p, MAXSOLBUF, ",1"); /* L1C/A */ for (q = s + 1, sum = 0; *q; q++) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GLGSV: glonass */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) @@ -1916,7 +1916,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, for (i = k = 0; i < nmsg; i++) { s = p; - p += sprintf(p, "$GLGSV,%d,%d,%02d", nmsg, i + 1, n); + p += std::snprintf(p, MAXSOLBUF, "$GLGSV,%d,%d,%02d", nmsg, i + 1, n); for (j = 0; j < 4; j++, k++) { @@ -1931,19 +1931,19 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; - p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); + p += std::snprintf(p, MAXSOLBUF, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else { - p += sprintf(p, ",,,,"); + p += std::snprintf(p, MAXSOLBUF, ",,,,"); } } - p += sprintf(p, ",1"); /* L1C/A */ + p += std::snprintf(p, MAXSOLBUF, ",1"); /* L1C/A */ for (q = s + 1, sum = 0; *q; q++) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GAGSV: galileo */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) @@ -1962,7 +1962,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, for (i = k = 0; i < nmsg; i++) { s = p; - p += sprintf(p, "$GAGSV,%d,%d,%02d", nmsg, i + 1, n); + p += std::snprintf(p, MAXSOLBUF, "$GAGSV,%d,%d,%02d", nmsg, i + 1, n); for (j = 0; j < 4; j++, k++) { @@ -1976,19 +1976,19 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; - p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); + p += std::snprintf(p, MAXSOLBUF, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else { - p += sprintf(p, ",,,,"); + p += std::snprintf(p, MAXSOLBUF, ",,,,"); } } - p += sprintf(p, ",7"); /* L1BC */ + p += std::snprintf(p, MAXSOLBUF, ",7"); /* L1BC */ for (q = s + 1, sum = 0; *q; q++) { sum ^= *q; /* check-sum */ } - p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); + p += std::snprintf(p, MAXSOLBUF, "*%02X%c%c", sum, 0x0D, 0x0A); } return p - reinterpret_cast(buff); } @@ -2021,55 +2021,55 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) trace(3, "outprcopts:\n"); - p += sprintf(p, "%s pos mode : %s\n", COMMENTH, s1[opt->mode]); + p += std::snprintf(p, MAXSOLMSG, "%s pos mode : %s\n", COMMENTH, s1[opt->mode]); if (PMODE_DGPS <= opt->mode && opt->mode <= PMODE_FIXED) { - p += sprintf(p, "%s freqs : %s\n", COMMENTH, s2[opt->nf - 1]); + p += std::snprintf(p, MAXSOLMSG, "%s freqs : %s\n", COMMENTH, s2[opt->nf - 1]); } if (opt->mode > PMODE_SINGLE) { - p += sprintf(p, "%s solution : %s\n", COMMENTH, s3[opt->soltype]); + p += std::snprintf(p, MAXSOLMSG, "%s solution : %s\n", COMMENTH, s3[opt->soltype]); } - p += sprintf(p, "%s elev mask : %.1f deg\n", COMMENTH, opt->elmin * R2D); + p += std::snprintf(p, MAXSOLMSG, "%s elev mask : %.1f deg\n", COMMENTH, opt->elmin * R2D); if (opt->mode > PMODE_SINGLE) { - p += sprintf(p, "%s dynamics : %s\n", COMMENTH, opt->dynamics ? "on" : "off"); - p += sprintf(p, "%s tidecorr : %s\n", COMMENTH, opt->tidecorr ? "on" : "off"); + p += std::snprintf(p, MAXSOLMSG, "%s dynamics : %s\n", COMMENTH, opt->dynamics ? "on" : "off"); + p += std::snprintf(p, MAXSOLMSG, "%s tidecorr : %s\n", COMMENTH, opt->tidecorr ? "on" : "off"); } if (opt->mode <= PMODE_FIXED) { - p += sprintf(p, "%s ionos opt : %s\n", COMMENTH, s4[opt->ionoopt]); + p += std::snprintf(p, MAXSOLMSG, "%s ionos opt : %s\n", COMMENTH, s4[opt->ionoopt]); } - p += sprintf(p, "%s tropo opt : %s\n", COMMENTH, s5[opt->tropopt]); - p += sprintf(p, "%s ephemeris : %s\n", COMMENTH, s6[opt->sateph]); + p += std::snprintf(p, MAXSOLMSG, "%s tropo opt : %s\n", COMMENTH, s5[opt->tropopt]); + p += std::snprintf(p, MAXSOLMSG, "%s ephemeris : %s\n", COMMENTH, s6[opt->sateph]); if (opt->navsys != SYS_GPS) { - p += sprintf(p, "%s navi sys :", COMMENTH); + p += std::snprintf(p, MAXSOLMSG, "%s navi sys :", COMMENTH); for (i = 0; sys[i]; i++) { if (opt->navsys & sys[i]) { - p += sprintf(p, " %s", s7[i]); + p += std::snprintf(p, MAXSOLMSG, " %s", s7[i]); } } - p += sprintf(p, "\n"); + p += std::snprintf(p, MAXSOLMSG, "\n"); } if (PMODE_KINEMA <= opt->mode && opt->mode <= PMODE_FIXED) { - p += sprintf(p, "%s amb res : %s\n", COMMENTH, s8[opt->modear]); + p += std::snprintf(p, MAXSOLMSG, "%s amb res : %s\n", COMMENTH, s8[opt->modear]); if (opt->navsys & SYS_GLO) { - p += sprintf(p, "%s amb glo : %s\n", COMMENTH, s9[opt->glomodear]); + p += std::snprintf(p, MAXSOLMSG, "%s amb glo : %s\n", COMMENTH, s9[opt->glomodear]); } if (opt->thresar[0] > 0.0) { - p += sprintf(p, "%s val thres : %.1f\n", COMMENTH, opt->thresar[0]); + p += std::snprintf(p, MAXSOLMSG, "%s val thres : %.1f\n", COMMENTH, opt->thresar[0]); } } if (opt->mode == PMODE_MOVEB && opt->baseline[0] > 0.0) { - p += sprintf(p, "%s baseline : %.4f %.4f m\n", COMMENTH, + p += std::snprintf(p, MAXSOLMSG, "%s baseline : %.4f %.4f m\n", COMMENTH, opt->baseline[0], opt->baseline[1]); } for (i = 0; i < 2; i++) @@ -2078,7 +2078,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) { continue; } - p += sprintf(p, "%s antenna%d : %-21s (%7.4f %7.4f %7.4f)\n", COMMENTH, + p += std::snprintf(p, MAXSOLMSG, "%s antenna%d : %-21s (%7.4f %7.4f %7.4f)\n", COMMENTH, i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1], opt->antdel[i][2]); } @@ -2110,35 +2110,35 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) if (opt->outhead) { - p += sprintf(p, "%s (", COMMENTH); + p += std::snprintf(p, MAXSOLMSG, "%s (", COMMENTH); if (opt->posf == SOLF_XYZ) { - p += sprintf(p, "x/y/z-ecef=WGS84"); + p += std::snprintf(p, MAXSOLMSG, "x/y/z-ecef=WGS84"); } else if (opt->posf == SOLF_ENU) { - p += sprintf(p, "e/n/u-baseline=WGS84"); + p += std::snprintf(p, MAXSOLMSG, "e/n/u-baseline=WGS84"); } else { - p += sprintf(p, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); + p += std::snprintf(p, MAXSOLMSG, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); } - p += sprintf(p, ",Q=1:fix,2:float,3:sbas,4:dgps,5:single,6:ppp,ns=# of satellites)\n"); + p += std::snprintf(p, MAXSOLMSG, ",Q=1:fix,2:float,3:sbas,4:dgps,5:single,6:ppp,ns=# of satellites)\n"); } - p += sprintf(p, "%s %-*s%s", COMMENTH, (opt->timef ? 16 : 8) + timeu + 1, s3[opt->times], sep); + p += std::snprintf(p, MAXSOLMSG, "%s %-*s%s", COMMENTH, (opt->timef ? 16 : 8) + timeu + 1, s3[opt->times], sep); if (opt->posf == SOLF_LLH) { /* lat/lon/hgt */ if (opt->degf) { - p += sprintf(p, "%16s%s%16s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", + p += std::snprintf(p, MAXSOLMSG, "%16s%s%16s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", "latitude(d'\")", sep, "longitude(d'\")", sep, "height(m)", sep, "Q", sep, "ns", sep, "sdn(m)", sep, "sde(m)", sep, "sdu(m)", sep, "sdne(m)", sep, "sdeu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio"); } else { - p += sprintf(p, "%14s%s%14s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", + p += std::snprintf(p, MAXSOLMSG, "%14s%s%14s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", "latitude(deg)", sep, "longitude(deg)", sep, "height(m)", sep, "Q", sep, "ns", sep, "sdn(m)", sep, "sde(m)", sep, "sdu(m)", sep, "sdne(m)", sep, "sdeu(m)", sep, "sdun(m)", sep, "age(s)", sep, "ratio"); @@ -2146,14 +2146,14 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) } else if (opt->posf == SOLF_XYZ) { /* x/y/z-ecef */ - p += sprintf(p, "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", + p += std::snprintf(p, MAXSOLMSG, "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", "x-ecef(m)", sep, "y-ecef(m)", sep, "z-ecef(m)", sep, "Q", sep, "ns", sep, "sdx(m)", sep, "sdy(m)", sep, "sdz(m)", sep, "sdxy(m)", sep, "sdyz(m)", sep, "sdzx(m)", sep, "age(s)", sep, "ratio"); } else if (opt->posf == SOLF_ENU) { /* e/n/u-baseline */ - p += sprintf(p, "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", + p += std::snprintf(p, MAXSOLMSG, "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", "e-baseline(m)", sep, "n-baseline(m)", sep, "u-baseline(m)", sep, "Q", sep, "ns", sep, "sde(m)", sep, "sdn(m)", sep, "sdu(m)", sep, "sden(m)", sep, "sdnu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio"); @@ -2223,7 +2223,7 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb, week++; gpst = 0.0; } - snprintf(s, 255, "%4d%s%*.*f", week, sep, 6 + (timeu <= 0 ? 0 : timeu + 1), timeu, gpst); + std::snprintf(s, sizeof(s), "%4d%s%*.*f", week, sep, 6 + (timeu <= 0 ? 0 : timeu + 1), timeu, gpst); } switch (opt->posf) { diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 6b1fd4673..3bf654db6 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -131,14 +131,13 @@ serial_t *openserial(const char *path, int mode, char *msg) } if (i >= 11) { - sprintf(msg, "bitrate error (%d)", brate); + std::snprintf(msg, MAXSTRMSG, "bitrate error (%d)", brate); tracet(1, "openserial: %s path=%s\n", msg, path); free(serial); return nullptr; } parity = static_cast(toupper(static_cast(parity))); - // sprintf(dev, "/dev/%s", port); This line triggers a warning. Replaced by: std::string s_aux = "/dev/" + std::string(port); s_aux.resize(128, '\0'); int n = s_aux.length(); @@ -166,7 +165,7 @@ serial_t *openserial(const char *path, int mode, char *msg) if ((serial->dev = open(dev, rw | O_NOCTTY | O_NONBLOCK)) < 0) { - sprintf(msg, "device open error (%d)", errno); + std::snprintf(msg, MAXSTRMSG, "device open error (%d)", errno); tracet(1, "openserial: %s dev=%s\n", msg, dev); free(serial); return nullptr; @@ -284,19 +283,19 @@ int openfile_(file_t *file, gtime_t time, char *msg) if (!(file->fp = fopen(file->openpath, rw))) { - sprintf(msg, "file open error: %s", file->openpath); + std::snprintf(msg, MAXSTRMSG, "file open error"); tracet(1, "openfile: %s\n", msg); return 0; } tracet(4, "openfile_: open file %s (%s)\n", file->openpath, rw); - sprintf(tagpath, "%s.tag", file->openpath); + std::snprintf(tagpath, MAXSTRPATH + 4, "%s.tag", file->openpath); if (file->timetag) { /* output/sync time-tag */ if (!(file->fp_tag = fopen(tagpath, rw))) { - sprintf(msg, "tag open error: %s", tagpath); + std::snprintf(msg, MAXSTRMSG, "tag open error"); tracet(1, "openfile: %s\n", msg); fclose(file->fp); return 0; @@ -319,7 +318,7 @@ int openfile_(file_t *file, gtime_t time, char *msg) } else { - sprintf(tagh, "TIMETAG RTKLIB %s", VER_RTKLIB); + std::snprintf(tagh, TIMETAGH_LEN + 1, "TIMETAG RTKLIB %s", VER_RTKLIB); memcpy(tagh + TIMETAGH_LEN - 4, &file->tick_f, sizeof(file->tick_f)); fwrite(&tagh, 1, TIMETAGH_LEN, file->fp_tag); fwrite(&file->time, 1, sizeof(file->time), file->fp_tag); @@ -571,7 +570,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) { trace(1, "fseek error"); } - sprintf(msg, "end"); + std::snprintf(msg, MAXSTRPATH, "end"); break; } if (file->repmode || file->speed > 0.0) @@ -586,7 +585,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) tick_master = tick; } - sprintf(msg, "T%+.1fs", static_cast(tick) < 0 ? 0.0 : static_cast(tick) / 1000.0); + std::snprintf(msg, MAXSTRPATH, "T%+.1fs", static_cast(tick) < 0 ? 0.0 : static_cast(tick) / 1000.0); if (static_cast(fpos - file->fpos) >= nmax) { @@ -615,7 +614,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) file->fpos += nr; if (nr <= 0) { - sprintf(msg, "end"); + std::snprintf(msg, MAXSTRPATH, "end"); } } tracet(5, "readfile: fp=%p \n nr=%d fpos=%u\n", file->fp, nr, file->fpos); @@ -829,7 +828,7 @@ int setsock(socket_t sock, char *msg) if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&tv), sizeof(tv)) == -1 || setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast(&tv), sizeof(tv)) == -1) { - sprintf(msg, "sockopt error: notimeo"); + std::snprintf(msg, MAXSTRMSG, "sockopt error: notimeo"); tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock()); closesocket(sock); return 0; @@ -838,12 +837,12 @@ int setsock(socket_t sock, char *msg) setsockopt(sock, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&bs), sizeof(bs)) == -1) { tracet(1, "setsock: setsockopt error 2 sock=%d err=%d bs=%d\n", sock, errsock(), bs); - sprintf(msg, "sockopt error: bufsiz"); + std::snprintf(msg, MAXSTRMSG, "sockopt error: bufsiz"); } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&mode), sizeof(mode)) == -1) { tracet(1, "setsock: setsockopt error 3 sock=%d err=%d\n", sock, errsock()); - sprintf(msg, "sockopt error: nodelay"); + std::snprintf(msg, MAXSTRMSG, "sockopt error: nodelay"); } return 1; } @@ -940,7 +939,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) /* generate socket */ if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - sprintf(msg, "socket error (%d)", errsock()); + std::snprintf(msg, MAXSTRMSG, "socket error (%d)", errsock()); tracet(1, "gentcp: socket error err=%d\n", errsock()); tcp->state = -1; return 0; @@ -963,7 +962,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) #endif if (bind(tcp->sock, reinterpret_cast(&tcp->addr), sizeof(tcp->addr)) == -1) { - sprintf(msg, "bind error (%d) : %d", errsock(), tcp->port); + std::snprintf(msg, MAXSTRMSG, "bind error (%d) : %d", errsock(), tcp->port); tracet(1, "gentcp: bind error port=%d err=%d\n", tcp->port, errsock()); closesocket(tcp->sock); tcp->state = -1; @@ -975,7 +974,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) { /* client socket */ if (!(hp = gethostbyname(tcp->saddr))) { - sprintf(msg, "address error (%s)", tcp->saddr); + std::snprintf(msg, MAXSTRMSG, "address error (%s)", tcp->saddr); tracet(1, "gentcp: gethostbyname error addr=%s err=%d\n", tcp->saddr, errsock()); closesocket(tcp->sock); tcp->state = 0; @@ -1019,7 +1018,7 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg) decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpsvr->svr.port) < 1) { - sprintf(msg, "port error: %s", port); + std::snprintf(msg, MAXSTRMSG, "port error: %s", port); tracet(1, "opentcpsvr: port error port=%s\n", port); free(tcpsvr); return nullptr; @@ -1096,17 +1095,17 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) if (n == 0) { tcpsvr->svr.state = 1; - sprintf(msg, "waiting..."); + std::snprintf(msg, MAXSTRMSG, "waiting..."); return; } tcpsvr->svr.state = 2; if (n == 1) { - sprintf(msg, "%s", saddr); + std::snprintf(msg, MAXSTRMSG, "%s", saddr); } else { - sprintf(msg, "%d clients", n); + std::snprintf(msg, MAXSTRMSG, "%d clients", n); } } @@ -1139,7 +1138,7 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast(&addr), &len)) == -1) { err = errsock(); - sprintf(msg, "accept error (%d)", err); + std::snprintf(msg, MAXSTRMSG, "accept error (%d)", err); tracet(1, "accsock: accept error sock=%d err=%d\n", tcpsvr->svr.sock, err); closesocket(tcpsvr->svr.sock); tcpsvr->svr.state = 0; @@ -1161,7 +1160,7 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) std::strncpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr), 256); tcpsvr->cli[i].saddr[255] = '\0'; } - sprintf(msg, "%s", tcpsvr->cli[i].saddr); + std::snprintf(msg, MAXSTRMSG, "%s", tcpsvr->cli[i].saddr); tracet(2, "accsock: connected sock=%d addr=%s\n", tcpsvr->cli[i].sock, tcpsvr->cli[i].saddr); tcpsvr->cli[i].state = 2; tcpsvr->cli[i].tact = tickget(); @@ -1203,7 +1202,7 @@ int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) { err = errsock(); tracet(1, "readtcpsvr: recv error sock=%d err=%d\n", tcpsvr->cli[0].sock, err); - sprintf(msg, "recv error (%d)", err); + std::snprintf(msg, MAXSTRMSG, "recv error (%d)", err); discontcp(&tcpsvr->cli[0], ticonnect); updatetcpsvr(tcpsvr, msg); return 0; @@ -1242,7 +1241,7 @@ int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) { err = errsock(); tracet(1, "writetcpsvr: send error i=%d sock=%d err=%d\n", i, tcpsvr->cli[i].sock, err); - sprintf(msg, "send error (%d)", err); + std::snprintf(msg, MAXSTRMSG, "send error (%d)", err); discontcp(&tcpsvr->cli[i], ticonnect); updatetcpsvr(tcpsvr, msg); return 0; @@ -1283,7 +1282,7 @@ int consock(tcpcli_t *tcpcli, char *msg) sizeof(tcpcli->svr.addr))) == -1) { err = errsock(); - sprintf(msg, "connect error (%d)", err); + std::snprintf(msg, MAXSTRMSG, "connect error (%d)", err); tracet(1, "consock: connect error sock=%d err=%d\n", tcpcli->svr.sock, err); closesocket(tcpcli->svr.sock); tcpcli->svr.state = 0; @@ -1291,10 +1290,10 @@ int consock(tcpcli_t *tcpcli, char *msg) } if (!stat) { /* not connect */ - sprintf(msg, "connecting..."); + std::snprintf(msg, MAXSTRMSG, "connecting..."); return 0; } - sprintf(msg, "%s", tcpcli->svr.saddr); + std::snprintf(msg, MAXSTRMSG, "%s", tcpcli->svr.saddr); tracet(2, "consock: connected sock=%d addr=%s\n", tcpcli->svr.sock, tcpcli->svr.saddr); tcpcli->svr.state = 2; tcpcli->svr.tact = tickget(); @@ -1319,7 +1318,7 @@ tcpcli_t *opentcpcli(const char *path, char *msg) decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpcli->svr.port) < 1) { - sprintf(msg, "port error: %s", port); + std::snprintf(msg, MAXSTRMSG, "port error: %s", port); tracet(1, "opentcp: port error port=%s\n", port); free(tcpcli); return nullptr; @@ -1369,7 +1368,7 @@ int waittcpcli(tcpcli_t *tcpcli, char *msg) if (tcpcli->toinact > 0 && static_cast(tickget() - tcpcli->svr.tact) > tcpcli->toinact) { - sprintf(msg, "timeout"); + std::snprintf(msg, MAXSTRMSG, "timeout"); tracet(2, "waittcpcli: inactive timeout sock=%d\n", tcpcli->svr.sock); discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; @@ -1396,7 +1395,7 @@ int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) { err = errsock(); tracet(1, "readtcpcli: recv error sock=%d err=%d\n", tcpcli->svr.sock, err); - sprintf(msg, "recv error (%d)", err); + std::snprintf(msg, MAXSTRMSG, "recv error (%d)", err); discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; } @@ -1426,7 +1425,7 @@ int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) { err = errsock(); tracet(1, "writetcp: send error sock=%d err=%d\n", tcpcli->svr.sock, err); - sprintf(msg, "send error (%d)", err); + std::snprintf(msg, MAXSTRMSG, "send error (%d)", err); discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; } @@ -1488,10 +1487,10 @@ int reqntrip_s(ntrip_t *ntrip, char *msg) tracet(3, "reqntrip_s: state=%d\n", ntrip->state); - p += snprintf(p, 256 + NTRIP_MAXSTR, "SOURCE %s %s\r\n", ntrip->passwd, ntrip->mntpnt); - p += sprintf(p, "Source-Agent: NTRIP %s\r\n", NTRIP_AGENT); - p += sprintf(p, "STR: %s\r\n", ntrip->str); - p += sprintf(p, "\r\n"); + p += std::snprintf(p, 256 + NTRIP_MAXSTR, "SOURCE %s %s\r\n", ntrip->passwd, ntrip->mntpnt); + p += std::snprintf(p, NTRIP_MAXSTR, "Source-Agent: NTRIP %s\r\n", NTRIP_AGENT); + p += std::snprintf(p, NTRIP_MAXSTR, "STR: %s\r\n", ntrip->str); + p += std::snprintf(p, NTRIP_MAXSTR, "\r\n"); if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) { @@ -1514,22 +1513,22 @@ int reqntrip_c(ntrip_t *ntrip, char *msg) tracet(3, "reqntrip_c: state=%d\n", ntrip->state); - p += sprintf(p, "GET %s/%s HTTP/1.0\r\n", ntrip->url, ntrip->mntpnt); - p += sprintf(p, "User-Agent: NTRIP %s\r\n", NTRIP_AGENT); + p += std::snprintf(p, NTRIP_MAXSTR, "GET %s/%s HTTP/1.0\r\n", ntrip->url, ntrip->mntpnt); + p += std::snprintf(p, NTRIP_MAXSTR, "User-Agent: NTRIP %s\r\n", NTRIP_AGENT); if (!*ntrip->user) { - p += sprintf(p, "Accept: */*\r\n"); - p += sprintf(p, "Connection: close\r\n"); + p += std::snprintf(p, NTRIP_MAXSTR, "Accept: */*\r\n"); + p += std::snprintf(p, NTRIP_MAXSTR, "Connection: close\r\n"); } else { - sprintf(user, "%s:%s", ntrip->user, ntrip->passwd); - p += sprintf(p, "Authorization: Basic "); + std::snprintf(user, sizeof(user), "%s:%s", ntrip->user, ntrip->passwd); + p += std::snprintf(p, NTRIP_MAXSTR, "Authorization: Basic "); p += encbase64(p, reinterpret_cast(user), strlen(user)); - p += sprintf(p, "\r\n"); + p += std::snprintf(p, NTRIP_MAXSTR, "\r\n"); } - p += sprintf(p, "\r\n"); + p += std::snprintf(p, NTRIP_MAXSTR, "\r\n"); if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) { @@ -1565,7 +1564,7 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) *q++ = *p++; } ntrip->state = 2; - sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); + std::snprintf(msg, MAXSTRMSG, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb); return 1; } @@ -1589,7 +1588,7 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) } else if (ntrip->nb >= NTRIP_MAXRSP) { /* buffer overflow */ - sprintf(msg, "response overflow"); + std::snprintf(msg, MAXSTRMSG, "response overflow"); tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb); ntrip->nb = 0; ntrip->buff[0] = '\0'; @@ -1622,7 +1621,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) *q++ = *p++; } ntrip->state = 2; - sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); + std::snprintf(msg, MAXSTRMSG, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb); return 1; } @@ -1631,11 +1630,11 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) if (!*ntrip->mntpnt) { /* source table request */ ntrip->state = 2; - sprintf(msg, "source table received"); + std::snprintf(msg, MAXSTRMSG, "source table received"); tracet(2, "rspntrip_c: receive source table nb=%d\n", ntrip->nb); return 1; } - sprintf(msg, "no mountp. reconnect..."); + std::snprintf(msg, MAXSTRMSG, "no mountp. reconnect..."); tracet(2, "rspntrip_c: no mount point nb=%d\n", ntrip->nb); ntrip->nb = 0; ntrip->buff[0] = '\0'; @@ -1661,7 +1660,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) } else if (ntrip->nb >= NTRIP_MAXRSP) { /* buffer overflow */ - sprintf(msg, "response overflow"); + std::snprintf(msg, MAXSTRMSG, "response overflow"); tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb); ntrip->nb = 0; ntrip->buff[0] = '\0'; @@ -1750,14 +1749,13 @@ ntrip_t *openntrip(const char *path, int type, char *msg) /* use default port if no port specified */ if (!*port) { - sprintf(port, "%d", type ? NTRIP_CLI_PORT : NTRIP_SVR_PORT); + std::snprintf(port, sizeof(port), "%d", type ? NTRIP_CLI_PORT : NTRIP_SVR_PORT); } - sprintf(tpath, "%s:%s", addr, port); + std::snprintf(tpath, MAXSTRPATH, "%s:%s", addr, port); /* ntrip access via proxy server */ if (*proxyaddr) { - // sprintf(ntrip->url, "http://%s", tpath); This line triggers a warning. Replaced by: std::string s_aux = "http://" + std::string(tpath); int n = s_aux.length(); if (n < 256) @@ -1978,7 +1976,6 @@ void *ftpthread(void *arg) { p = remote; } - // sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p); This line triggers a warning. Replaced by: std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p); int n = s_aux.length(); if (n < 1024) @@ -1989,7 +1986,6 @@ void *ftpthread(void *arg) } } - // sprintf(errfile, "%s.err", local); This line triggers a warning. Replaced by: std::string s_aux2 = std::string(local) + ".err"; n = s_aux2.length(); if (n < 1024) @@ -2022,14 +2018,12 @@ void *ftpthread(void *arg) if (*proxyaddr) { proto = ftp->proto ? const_cast("http") : const_cast("ftp"); - sprintf(env, "set %s_proxy=http://%s & ", proto, proxyaddr); + std::snprintf(env, sizeof(env), "set %s_proxy=http://%s & ", proto, proxyaddr); proxyopt = const_cast("--proxy=on "); } /* download command (ref [2]) */ if (ftp->proto == 0) { /* ftp */ - // sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"", - // ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by: std::string s_aux = "--ftp-user=" + std::string(ftp->user) + " --ftp-password=" + std::string(ftp->passwd) + " --glob=off --passive-ftp " + std::string(proxyopt) + "s-t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\""; @@ -2042,8 +2036,6 @@ void *ftpthread(void *arg) } } - // sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, - // remote, errfile); This line triggers a warning. Replaced by: std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + "\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; k = s_aux2.length(); @@ -2054,7 +2046,6 @@ void *ftpthread(void *arg) } else { /* http */ - // sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by: std::string s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\""; int l = s_aux.length(); for (int i = 0; (i < l) && (i < 1024); i++) @@ -2062,8 +2053,6 @@ void *ftpthread(void *arg) opt[i] = s_aux[i]; } - // sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, - // remote, errfile); This line triggers a warning. Replaced by: std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + "\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; l = s_aux2.length(); @@ -2186,7 +2175,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) if (ftp->state <= 0) { /* ftp/http not executed? */ ftp->state = 1; - sprintf(msg, "%s://%s", ftp->proto ? "http" : "ftp", ftp->addr); + if (std::snprintf(msg, sizeof(ftp->addr), "%s://%s", ftp->proto ? "http" : "ftp", ftp->addr) < 0) + { + tracet(1, "readftp: ftp address truncation\n"); + } if (pthread_create(&ftp->thread, nullptr, ftpthread, ftp)) { @@ -2203,7 +2195,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) if (ftp->state == 3) { /* ftp error */ - sprintf(msg, "%s error (%d)", ftp->proto ? "http" : "ftp", ftp->error); + if (std::snprintf(msg, sizeof(ftp->addr), "%s error (%d)", ftp->proto ? "http" : "ftp", ftp->error) < 0) + { + tracet(1, "readftp: ftp address truncation\n"); + } /* set next retry time */ ftp->tnext = nextdltime(ftp->topts, 0); @@ -2217,7 +2212,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) { *p++ = *q++; } - p += sprintf(reinterpret_cast(p), "\r\n"); + p += std::snprintf(reinterpret_cast(p), sizeof("\r\n") + 1, "\r\n"); /* set next download time */ ftp->tnext = nextdltime(ftp->topts, 1); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index cb8f87bed..ff83b6231 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -339,6 +339,7 @@ install(FILES ${PROJECT_BINARY_DIR}/include/volk_gnsssdr/volk_gnsssdr_typedefs.h ${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_malloc.h ${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_sine_table.h + ${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/constants.h DESTINATION include/volk_gnsssdr COMPONENT "volk_gnsssdr_devel" ) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/plot_best_vs_generic.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/plot_best_vs_generic.py new file mode 100644 index 000000000..b4a089e86 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/plot_best_vs_generic.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) +# +# This file is part of GNSS-SDR. +# +# GNSS-SDR is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNSS-SDR is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNSS-SDR. If not, see . + +# This script is used to compare the generic kernels to the highest performing kernel, for each operation +# Run: +# ./volk_gnsssdr_profile -j volk_gnsssdr_results.json +# Then run this script under python3 + +import matplotlib.pyplot as plt +import numpy as np +import json + +filename = 'volk_gnsssdr_results.json' + +operations = [] +metrics = [] +with open(filename) as json_file: + data = json.load(json_file) + for test in data['volk_gnsssdr_tests']: + if ('generic' in test['results']) or ('u_generic' in test['results']): # some dont have a generic kernel + operations.append(test['name'][13:]) # remove volk_gnsssdr_ prefix that they all have + extension_performance = [] + for key, val in test['results'].items(): + if key not in ['generic', 'u_generic']: # exclude generic results, when trying to find fastest time + extension_performance.append(val['time']) + try: + generic_time = test['results']['generic']['time'] + except: + generic_time = test['results']['u_generic']['time'] + metrics.append(extension_performance[np.argmin(extension_performance)]/generic_time) + +plt.bar(np.arange(len(metrics)), metrics) +plt.hlines(1.0, -1, len(metrics), colors='r', linestyles='dashed') +plt.axis([-1, len(metrics), 0, 2]) +plt.xticks(np.arange(len(operations)), operations, rotation=90) +plt.ylabel('Time taken of fastest kernel relative to generic kernel') +plt.show() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h index 69332ef60..fb3d1f420 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h @@ -57,7 +57,7 @@ public: class option_list { public: - option_list(std::string program_name); + explicit option_list(std::string program_name); void add(const option_t &opt); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index b23e4b51f..34cc8d288 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -193,7 +193,7 @@ int main(int argc, char *argv[]) void read_results(std::vector *results) { char path[1024]; - volk_gnsssdr_get_config_path(path); + volk_gnsssdr_get_config_path(path, true); read_results(results, std::string(path)); } @@ -255,7 +255,7 @@ void read_results(std::vector *results, std::string void write_results(const std::vector *results, bool update_result) { char path[1024]; - volk_gnsssdr_get_config_path(path); + volk_gnsssdr_get_config_path(path, false); write_results(results, update_result, std::string(path)); } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake new file mode 100644 index 000000000..a5eeb74da --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake @@ -0,0 +1,8 @@ +######################################################################## +# Toolchain file for building native on a ARM Cortex A72 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml index 6d293da91..3e3fa6489 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/archs.xml @@ -107,6 +107,7 @@ 12 -mfma + -mfma /arch:AVX2 32 @@ -241,6 +242,7 @@ -mavx2 + -mavx2 /arch:AVX2 32 diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_neon_intrinsics.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_neon_intrinsics.h index 033ce850a..7a73e483d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_neon_intrinsics.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_neon_intrinsics.h @@ -53,4 +53,47 @@ static inline float32x4_t vsqrtq_f32(float32x4_t q_x) return vmulq_f32(q_x, q_step_2); } +/* Magnitude squared for float32x4x2_t */ +static inline float32x4_t _vmagnitudesquaredq_f32(float32x4x2_t cmplxValue) +{ + float32x4_t iValue, qValue, result; + iValue = vmulq_f32(cmplxValue.val[0], cmplxValue.val[0]); // Square the values + qValue = vmulq_f32(cmplxValue.val[1], cmplxValue.val[1]); // Square the values + result = vaddq_f32(iValue, qValue); // Add the I2 and Q2 values + return result; +} + +/* Inverse square root for float32x4_t */ +static inline float32x4_t _vinvsqrtq_f32(float32x4_t x) +{ + float32x4_t sqrt_reciprocal = vrsqrteq_f32(x); + sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x, sqrt_reciprocal), sqrt_reciprocal), sqrt_reciprocal); + sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x, sqrt_reciprocal), sqrt_reciprocal), sqrt_reciprocal); + + return sqrt_reciprocal; +} + +/* Complex multiplication for float32x4x2_t */ +static inline float32x4x2_t _vmultiply_complexq_f32(float32x4x2_t a_val, float32x4x2_t b_val) +{ + float32x4x2_t tmp_real; + float32x4x2_t tmp_imag; + float32x4x2_t c_val; + + // multiply the real*real and imag*imag to get real result + // a0r*b0r|a1r*b1r|a2r*b2r|a3r*b3r + tmp_real.val[0] = vmulq_f32(a_val.val[0], b_val.val[0]); + // a0i*b0i|a1i*b1i|a2i*b2i|a3i*b3i + tmp_real.val[1] = vmulq_f32(a_val.val[1], b_val.val[1]); + // Multiply cross terms to get the imaginary result + // a0r*b0i|a1r*b1i|a2r*b2i|a3r*b3i + tmp_imag.val[0] = vmulq_f32(a_val.val[0], b_val.val[1]); + // a0i*b0r|a1i*b1r|a2i*b2r|a3i*b3r + tmp_imag.val[1] = vmulq_f32(a_val.val[1], b_val.val[0]); + // combine the products + c_val.val[0] = vsubq_f32(tmp_real.val[0], tmp_real.val[1]); + c_val.val[1] = vaddq_f32(tmp_imag.val[0], tmp_imag.val[1]); + return c_val; +} + #endif /* INCLUDED_VOLK_GNSSSDR_NEON_INTRINSICS_H_ */ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_prefs.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_prefs.h index c753a2046..fe74acc0e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_prefs.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_prefs.h @@ -26,6 +26,7 @@ #define INCLUDED_VOLK_GNSSSDR_PREFS_H #include +#include #include __VOLK_DECL_BEGIN @@ -38,10 +39,11 @@ typedef struct volk_gnsssdr_arch_pref } volk_gnsssdr_arch_pref_t; //////////////////////////////////////////////////////////////////////// -// get path to volk_gnsssdr_config profiling info; +// get path to volk_gnsssdr_config profiling info; second arguments specifies +// if config file should be tested on existence for reading. // returns \0 in the argument on failure. //////////////////////////////////////////////////////////////////////// -VOLK_API void volk_gnsssdr_get_config_path(char *); +VOLK_API void volk_gnsssdr_get_config_path(char *, bool); //////////////////////////////////////////////////////////////////////// // load prefs into global prefs struct diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c index 68bb830d5..281684bec 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c @@ -16,6 +16,7 @@ * along with GNSS-SDR. If not, see . */ +#include #include #include #include @@ -29,7 +30,7 @@ #include -void volk_gnsssdr_get_config_path(char *path) +void volk_gnsssdr_get_config_path(char *path, bool read) { if (!path) return; const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config"; @@ -42,7 +43,10 @@ void volk_gnsssdr_get_config_path(char *path) { strncpy(path, home, 512); strcat(path, suffix2); - return; + if (!read || (access(path, F_OK) != -1)) + { + return; + } } // check for user-local config file @@ -51,7 +55,7 @@ void volk_gnsssdr_get_config_path(char *path) { strncpy(path, home, 512); strcat(path, suffix); - if (access(path, F_OK) != -1) + if (!read || (access(path, F_OK) != -1)) { return; } @@ -63,7 +67,7 @@ void volk_gnsssdr_get_config_path(char *path) { strncpy(path, home, 512); strcat(path, suffix); - if (access(path, F_OK) != -1) + if (!read || (access(path, F_OK) != -1)) { return; } @@ -99,7 +103,7 @@ size_t volk_gnsssdr_load_preferences(volk_gnsssdr_arch_pref_t **prefs_res) volk_gnsssdr_arch_pref_t *prefs = NULL; // get the config path - volk_gnsssdr_get_config_path(path); + volk_gnsssdr_get_config_path(path, true); if (!path[0]) return n_arch_prefs; //no prefs found config_file = fopen(path, "r"); if (!config_file) return n_arch_prefs; //no prefs found diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py index 7c4059e90..040aed05c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/python/volk_gnsssdr_modtool/cfg.py @@ -23,6 +23,7 @@ from __future__ import print_function import sys import os +import exceptions import re from six.moves import configparser, input diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h index 5b4d9c94c..e1bc2f0ac 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h @@ -48,7 +48,7 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit); void decode_4bits_word(uint32_t input_uint32, gr_complex *out, int adc_bits); - unpack_spir_gss6450_samples(unsigned int adc_nbit); + explicit unpack_spir_gss6450_samples(unsigned int adc_nbit); ~unpack_spir_gss6450_samples() = default; private: diff --git a/src/algorithms/signal_source/libs/fpga_switch.h b/src/algorithms/signal_source/libs/fpga_switch.h index 1851b911f..c18de1520 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.h +++ b/src/algorithms/signal_source/libs/fpga_switch.h @@ -49,7 +49,7 @@ public: /*! * \brief Constructor */ - Fpga_Switch(const std::string& device_name); + explicit Fpga_Switch(const std::string& device_name); /*! * \brief Destructor diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc index 0f628cdd1..bd2ca1ca4 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc @@ -31,8 +31,8 @@ #include "viterbi_decoder.h" #include -#include // for memset -#include // for operator<<, basic_ostream, char_traits, endl +#include // for fill_n +#include // for operator<<, basic_ostream, char_traits, endl // logging #define EVENT 2 // logs important events which don't occur every block @@ -434,7 +434,6 @@ int Viterbi_Decoder::nsc_enc_bit(int state_out_p[], int input, int state_in, length: The highest bit position in the symbol This function is used by nsc_enc_bit(), rsc_enc_bit(), and rsc_tail() */ - int Viterbi_Decoder::parity_counter(int symbol, int length) { int counter; @@ -453,14 +452,13 @@ Viterbi_Decoder::Prev::Prev(int states, int t) { this->t = t; num_states = states; - state = new int[states]; - bit = new int[states]; - metric = new float[states]; - refcount = new int; - *refcount = 1; - memset(state, 0, sizeof(int) * num_states); - memset(bit, 0, sizeof(int) * num_states); - memset(metric, 0, sizeof(float) * num_states); + state.reserve(num_states); + bit.reserve(num_states); + metric.reserve(num_states); + refcount = 1; + std::fill_n(state.begin(), num_states, 0); + std::fill_n(bit.begin(), num_states, 0); + std::fill_n(metric.begin(), num_states, 0.0F); } @@ -468,7 +466,7 @@ Viterbi_Decoder::Prev::Prev(int states, int t) Viterbi_Decoder::Prev::Prev(const Prev& prev) { refcount = prev.refcount; - (*refcount)++; + refcount++; t = prev.t; state = prev.state; num_states = prev.num_states; @@ -477,7 +475,7 @@ Viterbi_Decoder::Prev::Prev(const Prev& prev) VLOG(LMORE) << "Prev(" << "?" << ", " << t << ")" - << " copy, new refcount = " << *refcount; + << " copy, new refcount = " << refcount; } @@ -491,21 +489,14 @@ Viterbi_Decoder::Prev& Viterbi_Decoder::Prev::operator=(const Prev& other) } // handle old resources - if (*refcount == 1) - { // if they are not used anymore -> unallocate them - delete[] state; - delete[] bit; - delete[] metric; - delete refcount; - } - else + if (refcount != 1) { // this object is not anymore using them - (*refcount)--; + refcount--; } // increase ref counter for this resource set refcount = other.refcount; - (*refcount)++; + refcount++; // take over resources t = other.t; @@ -516,28 +507,20 @@ Viterbi_Decoder::Prev& Viterbi_Decoder::Prev::operator=(const Prev& other) VLOG(LMORE) << "Prev(" << "?" << ", " << t << ")" - << " assignment, new refcount = " << *refcount; + << " assignment, new refcount = " << refcount; return *this; } Viterbi_Decoder::Prev::~Prev() { - if (*refcount == 1) + if (refcount != 1) { - delete[] state; - delete[] bit; - delete[] metric; - delete refcount; - // std::cout << "~Prev(" << "?" << ", " << t << ")" << " destructor with delete" << std::endl; - } - else - { - (*refcount)--; + refcount--; VLOG(LMORE) << "~Prev(" << "?" << ", " << t << ")" - << " destructor after copy, new refcount = " << *refcount; + << " destructor after copy, new refcount = " << refcount; } } diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.h b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.h index 3f7411b07..9ae7960a2 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.h +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.h @@ -79,10 +79,10 @@ private: private: int t; - int* state; - int* bit; - float* metric; - int* refcount; + std::vector state; + std::vector bit; + std::vector metric; + int refcount; }; // code properties diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h index 5dfd19842..df2d5319f 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -77,7 +77,7 @@ public: private: friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_); void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg); - dll_pll_veml_tracking(const Dll_Pll_Conf &conf_); + explicit dll_pll_veml_tracking(const Dll_Pll_Conf &conf_); bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 9e81e56ae..002ad191d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -108,7 +108,7 @@ public: private: friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg); - dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); + explicit dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); diff --git a/src/algorithms/tracking/libs/bayesian_estimation.h b/src/algorithms/tracking/libs/bayesian_estimation.h index 77d449b11..00cc3b8be 100644 --- a/src/algorithms/tracking/libs/bayesian_estimation.h +++ b/src/algorithms/tracking/libs/bayesian_estimation.h @@ -69,7 +69,7 @@ class Bayesian_estimator { public: Bayesian_estimator(); - Bayesian_estimator(int ny); + explicit Bayesian_estimator(int ny); Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0); ~Bayesian_estimator() = default; diff --git a/src/algorithms/tracking/libs/nonlinear_tracking.h b/src/algorithms/tracking/libs/nonlinear_tracking.h index ba8f511aa..05e0f3c08 100644 --- a/src/algorithms/tracking/libs/nonlinear_tracking.h +++ b/src/algorithms/tracking/libs/nonlinear_tracking.h @@ -64,7 +64,7 @@ class CubatureFilter public: // Constructors and destructors CubatureFilter(); - CubatureFilter(int nx); + explicit CubatureFilter(int nx); CubatureFilter(const arma::vec& x_pred_0, const arma::mat& P_x_pred_0); ~CubatureFilter() = default; @@ -93,7 +93,7 @@ class UnscentedFilter public: // Constructors and destructors UnscentedFilter(); - UnscentedFilter(int nx); + explicit UnscentedFilter(int nx); UnscentedFilter(const arma::vec& x_pred_0, const arma::mat& P_x_pred_0); ~UnscentedFilter() = default; diff --git a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h index f17b8f7ce..a19ecb1d3 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h +++ b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h @@ -52,7 +52,7 @@ public: void set_pdi(float pdi_code); //!< Set Summation interval for code [s] void initialize(); //!< Start tracking with acquisition information float get_code_nco(float DLL_discriminator); //!< Numerically controlled oscillator - Tracking_2nd_DLL_filter(float pdi_code); + explicit Tracking_2nd_DLL_filter(float pdi_code); Tracking_2nd_DLL_filter(); ~Tracking_2nd_DLL_filter() = default; diff --git a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h index 0afecbadf..28a2924d7 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h +++ b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h @@ -51,7 +51,7 @@ public: void set_pdi(float pdi_carr); //!< Set Summation interval for code [s] void initialize(); float get_carrier_nco(float PLL_discriminator); - Tracking_2nd_PLL_filter(float pdi_carr); + explicit Tracking_2nd_PLL_filter(float pdi_carr); Tracking_2nd_PLL_filter(); ~Tracking_2nd_PLL_filter() = default; diff --git a/src/core/libs/INIReader.h b/src/core/libs/INIReader.h index 1a9f0f3e5..64b47a59e 100644 --- a/src/core/libs/INIReader.h +++ b/src/core/libs/INIReader.h @@ -60,7 +60,7 @@ class INIReader { public: //! Construct INIReader and parse given filename. See ini.h for more info about the parsing. - INIReader(const std::string& filename); + explicit INIReader(const std::string& filename); //! Return the result of ini_parse(), i.e., 0 on success, line number of first error on parse error, or -1 on file open error. int ParseError(); diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index de3c3d631..300b9e9cf 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -77,7 +77,7 @@ public: * * \param[in] configuration Pointer to a ConfigurationInterface */ - ControlThread(std::shared_ptr configuration); + explicit ControlThread(std::shared_ptr configuration); /*! * \brief Destructor diff --git a/src/core/receiver/file_configuration.h b/src/core/receiver/file_configuration.h index 55c170d44..80fbf2303 100644 --- a/src/core/receiver/file_configuration.h +++ b/src/core/receiver/file_configuration.h @@ -57,7 +57,7 @@ class InMemoryConfiguration; class FileConfiguration : public ConfigurationInterface { public: - FileConfiguration(std::string filename); + explicit FileConfiguration(std::string filename); FileConfiguration(); //! Virtual destructor ~FileConfiguration(); diff --git a/src/core/system_parameters/gnss_signal.h b/src/core/system_parameters/gnss_signal.h index 297ed4a5d..8ef47008a 100644 --- a/src/core/system_parameters/gnss_signal.h +++ b/src/core/system_parameters/gnss_signal.h @@ -45,7 +45,7 @@ class Gnss_Signal { public: Gnss_Signal(); - Gnss_Signal(const std::string& signal_); + explicit Gnss_Signal(const std::string& signal_); Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_); ~Gnss_Signal() = default; std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a. diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index 0646e90c5..ee8c5a957 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -79,7 +79,7 @@ DEFINE_bool(show_plots, true, "Show plots on screen. Disable for non-interactive class GnuplotException : public std::runtime_error { public: - GnuplotException(const std::string &msg) : std::runtime_error(msg) {} + explicit GnuplotException(const std::string &msg) : std::runtime_error(msg) {} }; @@ -189,7 +189,7 @@ public: // ------------------------------------------------------------------------- //! set a style during construction - Gnuplot(const std::string &style = "points"); + explicit Gnuplot(const std::string &style = "points"); // plot a single std::vector at one go Gnuplot(const std::vector &x, diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc index d6cfda73a..64396d856 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc @@ -120,7 +120,7 @@ class AcqPerfTest_msg_rx : public gr::block private: friend AcqPerfTest_msg_rx_sptr AcqPerfTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - AcqPerfTest_msg_rx(Concurrent_Queue& queue); + explicit AcqPerfTest_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc index 3af5d993b..f0fa265b5 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc @@ -68,7 +68,7 @@ class GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block private: friend GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + explicit GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index 0b46edf0e..173414e4c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -67,7 +67,7 @@ class GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block private: friend GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + explicit GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc index 758b2e7ee..79385d54a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc @@ -76,7 +76,7 @@ class GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx : public gr::block private: friend GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(Concurrent_Queue& queue); + explicit GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index 6045a29d8..4237ea8a2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -69,7 +69,7 @@ class GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx : public gr::block private: friend GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(Concurrent_Queue& queue); + explicit GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index 2f8cb2ed0..4806dccb6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -75,7 +75,7 @@ class GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx : public gr: private: friend GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue); + explicit GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index 1025d3c4c..ce45f8f0a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -70,7 +70,7 @@ class GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::bloc private: friend GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + explicit GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index f01b2c5be..91f3f6687 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -66,7 +66,7 @@ class GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx : public gr::block private: friend GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_sptr GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(Concurrent_Queue& queue); + explicit GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc index ce7a45a28..93091773f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc @@ -72,7 +72,7 @@ class GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx : public gr::block private: friend GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_sptr GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(Concurrent_Queue& queue); + explicit GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc index bc96899a7..a087b3fdc 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc @@ -70,7 +70,7 @@ class GlonassL2CaPcpsAcquisitionTest_msg_rx : public gr::block private: friend GlonassL2CaPcpsAcquisitionTest_msg_rx_sptr GlonassL2CaPcpsAcquisitionTest_msg_rx_make(concurrent_queue& queue); void msg_handler_events(pmt::pmt_t msg); - GlonassL2CaPcpsAcquisitionTest_msg_rx(concurrent_queue& queue); + explicit GlonassL2CaPcpsAcquisitionTest_msg_rx(concurrent_queue& queue); concurrent_queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index cef79dd1a..cbbc2cc1c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -73,7 +73,7 @@ class GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx : public gr::block private: friend GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + explicit GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index f0fe72c1b..f511f5e7e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -68,7 +68,7 @@ class GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx : public gr::block private: friend GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + explicit GpsL1CaPcpsOpenClAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index 3e00b9c18..14014f914 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -73,7 +73,7 @@ class GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx : public gr::block private: friend GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_sptr GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue); + explicit GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index 6dbd8bc72..08933f1a9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -70,7 +70,7 @@ class GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx : public gr::block private: friend GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_sptr GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue& queue); void msg_handler_events(pmt::pmt_t msg); - GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); + explicit GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue& queue); Concurrent_Queue& channel_internal_queue; public: diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h index d23a50f8a..33e6ca2a9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.h @@ -39,7 +39,7 @@ class Observables_Dump_Reader { public: - Observables_Dump_Reader(int n_channels); + explicit Observables_Dump_Reader(int n_channels); ~Observables_Dump_Reader(); bool read_binary_obs(); bool restart();