Merge branch 'fix-lintian2' into next

Make use of the C++20 standard if the environment allows for it
Fix warnings -Wrestrict raised when using c++20
Fix lintian warning hardening-no-fortify-functions
CI: Improve readability of yml files
CI: fix macos builds
This commit is contained in:
Carles Fernandez 2022-12-18 11:21:42 +01:00
commit bb963e8ed7
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
12 changed files with 96 additions and 76 deletions

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2020 Carles Fernandez-Prades <carles.fernandez@cttc.es>
# SPDX-FileCopyrightText: 2020-2022 Carles Fernandez-Prades <carles.fernandez@cttc.es>
name: Simple CI
on:
@ -40,7 +40,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: brew update && brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog gnuradio log4cpp openssl pugixml protobuf && pip3 install mako
run: |
brew update
brew install --overwrite python@3.10 python@3.11
python3.11 -m pip install mako
brew install ninja pkg-config hdf5 automake armadillo lapack \
gflags glog gnuradio log4cpp openssl pugixml protobuf
- name: configure
run: cd build && cmake -GNinja ..
- name: build
@ -55,15 +60,28 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: brew update && brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog gnuradio log4cpp openssl pugixml protobuf && pip3 install mako
run: |
brew update
brew install --overwrite python@3.10 python@3.11
python3.11 -m pip install mako
brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog \
gnuradio log4cpp openssl pugixml protobuf
- name: configure
run: cd build && cmake -GXcode ..
- name: build
run: cd build && xcodebuild -configuration Release
- name: check
run: cd build && xcodebuild -configuration Release -target check && ../install/volk_gnsssdr_profile && ../install/run_tests
run: |
cd build
xcodebuild -configuration Release -target check
../install/volk_gnsssdr_profile
../install/run_tests
- name: default position_test
run: cd build && cmake -DENABLE_SYSTEM_TESTING_EXTRA=ON .. && xcodebuild -configuration Release -target position_test && ../install/position_test
run: |
cd build
cmake -DENABLE_SYSTEM_TESTING_EXTRA=ON ..
xcodebuild -configuration Release -target position_test
../install/position_test
clang-format:
runs-on: macos-latest
@ -74,20 +92,36 @@ jobs:
- name: run clang-format
run: find . -iname \*.h -o -iname \*.c -o -iname \*.cc | xargs clang-format -style=file -i
- name: check
run: git diff > clang_format.patch && echo -e "if \n [ -s clang_format.patch ] \nthen \n echo "clang-format not applied:"; echo ""; more clang_format.patch; exit 1 \nfi \n" > detect && chmod +x ./detect && ./detect
run: |
git diff > clang_format.patch
echo -e "if \n [ -s clang_format.patch ] \nthen \n echo "clang-format not applied:"; echo ""; more clang_format.patch; exit 1 \nfi \n" > detect
chmod +x ./detect
./detect
clang-tidy:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: brew update && brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio log4cpp openssl pugixml protobuf && ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin && ln -s $(brew --prefix llvm)/bin/clang-apply-replacements /usr/local/bin && ln -s $(brew --prefix llvm)/bin/run-clang-tidy /usr/local/bin && pip3 install mako
run: |
brew update
brew install --overwrite python@3.10 python@3.11
python3.11 -m pip install mako
brew install llvm pkg-config hdf5 armadillo lapack gflags glog gnuradio libmatio \
log4cpp openssl pugixml protobuf
ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin
ln -s $(brew --prefix llvm)/bin/clang-apply-replacements /usr/local/bin
ln -s $(brew --prefix llvm)/bin/run-clang-tidy /usr/local/bin
- name: Prepare run
run: cd build && cmake .. && make volk_gnsssdr_module gtest-1.12.1 core_monitor core_libs pvt_libs
- name: run clang-tidy
run: cd build && run-clang-tidy -fix
- name: check
run: git diff > clang_tidy.patch && echo -e "if \n [ -s clang_tidy.patch ] \nthen \n echo "clang_tidy not applied:"; echo ""; more clang_tidy.patch; exit 1 \nfi \n" > detect && chmod +x ./detect && ./detect
run: |
git diff > clang_tidy.patch
echo -e "if \n [ -s clang_tidy.patch ] \nthen \n echo "clang_tidy not applied:"; echo ""; more clang_tidy.patch; exit 1 \nfi \n" > detect
chmod +x ./detect
./detect
cpplint:
runs-on: ubuntu-latest

View File

@ -26,28 +26,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.0
- uses: actions/checkout@v3
- name: Update repositories
run: sudo apt update
# All dependencies
- name: Install dependencies
run: sudo apt install -y cmake openjdk-11-jre-headless wget unzip make python3-mako
# Setup Android SDK, and auto-accept licenses
- name: Install Android SDK
run: wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip && mkdir android-sdk-linux && unzip -qq android-sdk.zip -d android-sdk-linux && export ANDROID_HOME=./android-sdk-linux && echo y | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux --update && (echo y; echo y; echo y; echo y; echo y; echo y; echo y; echo y) | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux --licenses
run: |
wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
mkdir android-sdk-linux
unzip -qq android-sdk.zip -d android-sdk-linux
export ANDROID_HOME=./android-sdk-linux
echo y | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux --update
(echo y; echo y; echo y; echo y; echo y; echo y; echo y; echo y) | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux --licenses
# Call SDKManager to install the Android NDK
- name: Install Android NDK
run: $GITHUB_WORKSPACE/android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=$GITHUB_WORKSPACE/android-sdk-linux --install "ndk;24.0.8215888" --channel=3
# Setup build directory
- name: Setup ${{ matrix.arch.name }}
shell: bash
run: cd $GITHUB_WORKSPACE/ && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/android-sdk-linux/ndk/24.0.8215888/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.arch.name }} -DANDROID_PLATFORM=android-24 ../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr
run: |
cd $GITHUB_WORKSPACE/
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/android-sdk-linux/ndk/24.0.8215888/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=${{ matrix.arch.name }} \
-DANDROID_PLATFORM=android-24 \
../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr
# Build
- name: Build ${{ matrix.arch.name }}
shell: bash

View File

@ -667,19 +667,17 @@ if(NOT (GNURADIO_VERSION VERSION_LESS 3.8) AND (LOG4CPP_READY_FOR_CXX17 OR GNURA
endif()
if(FILESYSTEM_FOUND)
set(CMAKE_CXX_STANDARD 17)
# if(CMAKE_VERSION VERSION_GREATER 3.13)
# UHD 3.15.0.0-5 does not support C++20
# GNU Radio 3.10.0.git does not support C++20
# if(((NOT UHD_FOUND) OR (UHD_FOUND AND ("${UHD_VERSION}" VERSION_LESS 3.14.99))) AND (GNURADIO_VERSION VERSION_LESS 3.9.99))
# set(CMAKE_CXX_STANDARD 20)
# if(CMAKE_VERSION VERSION_GREATER 3.20.99)
if(CMAKE_VERSION VERSION_GREATER 3.13)
if(((NOT UHD_FOUND) OR (UHD_FOUND AND ("${UHD_VERSION}" VERSION_GREATER 4.2.99))) AND (GNURADIO_VERSION VERSION_GREATER 3.10.3.99))
set(CMAKE_CXX_STANDARD 20)
# if(CMAKE_VERSION VERSION_GREATER 3.20.99)
# if(((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0.0")) OR
# ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")))
# set(CMAKE_CXX_STANDARD 23)
# endif()
# endif()
# endif()
# endif()
# endif()
endif()
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
endif()
@ -1109,9 +1107,9 @@ if(NOT VOLKGNSSSDR_FOUND)
set(STRIP_VOLK_GNSSSDR_PROFILE "")
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
set(STRIP_VOLK_GNSSSDR_PROFILE "-DENABLE_STRIP=${ENABLE_STRIP}")
set(STRIP_VOLK_GNSSSDR_PROFILE -DENABLE_STRIP=${ENABLE_STRIP})
if(ENABLE_PACKAGING)
set(STRIP_VOLK_GNSSSDR_PROFILE "${STRIP_VOLK_GNSSSDR_PROFILE} -DCMAKE_VERBOSE_MAKEFILE=ON")
set(STRIP_VOLK_GNSSSDR_PROFILE ${STRIP_VOLK_GNSSSDR_PROFILE} -DCMAKE_VERBOSE_MAKEFILE=ON)
endif()
endif()
@ -1157,6 +1155,12 @@ if(NOT VOLKGNSSSDR_FOUND)
${STRIP_VOLK_GNSSSDR_PROFILE}
${USE_THIS_PYTHON}
)
if(CMAKE_C_FLAGS) # Required by some packaging systems
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
endif()
if(CMAKE_CXX_FLAGS) # Required by some packaging systems
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS})
endif()
if(DEFINED ENV{OECORE_TARGET_SYSROOT})
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS}

View File

@ -1147,7 +1147,7 @@ rtklib_pvt_gs::~rtklib_pvt_gs()
}
}
}
catch (std::length_error& e)
catch (const std::exception& e)
{
LOG(WARNING) << e.what();
}

View File

@ -5602,29 +5602,9 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map<int32_t, Gal
E5B_HS = "11";
}
if (E1B_HS == "11")
{
LOG(WARNING) << "Signal Component currently in Test";
}
if (E1B_HS == "10")
{
LOG(WARNING) << "Signal will be out of service";
}
if (E1B_HS == "01")
{
LOG(WARNING) << "Signal out of service";
}
E1B_HS = "00"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID
std::string E1B_DVS = std::to_string(galileo_ephemeris_iter->second.E1B_DVS);
if (E1B_DVS == "1")
{
LOG(WARNING) << "Navigation data without guarantee";
}
E1B_DVS = "0"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID
std::string SVhealth_str = E5B_HS + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::string(E1B_DVS) + std::string(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS);
SVhealth_str = "000000000"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID
int32_t SVhealth = Rinex_Printer::toInt(SVhealth_str, 9);
line += Rinex_Printer::doub2for(static_cast<double>(SVhealth), 18, 2);
line += std::string(1, ' ');

View File

@ -3103,7 +3103,7 @@ void readpos(const char *file, const char *rcv, double *pos)
continue;
}
auto sta = stas[np++]; // NOLINT(readability-qualified-auto)
std::strncpy(sta, str, 16);
strncpy_no_trunc(sta, 16, str, 256);
sta[15] = '\0';
}
fclose(fp);

View File

@ -590,11 +590,7 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode)))
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC $<INSTALL_INTERFACE:include>
)
if(UNIX)
target_compile_definitions(volk_gnsssdr
PUBLIC $<$<CONFIG:Release>:_FORTIFY_SOURCE=2>$<$<CONFIG:RelWithDebInfo>:_FORTIFY_SOURCE=2>
)
endif()
if(USE_CPU_FEATURES)
if(CPUFEATURES_FOUND)
target_include_directories(volk_gnsssdr
@ -665,11 +661,6 @@ if(ENABLE_STATIC_LIBS)
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
if(UNIX)
target_compile_definitions(volk_gnsssdr_static
PUBLIC $<$<CONFIG:Release>:_FORTIFY_SOURCE=2>$<$<CONFIG:RelWithDebInfo>:_FORTIFY_SOURCE=2>
)
endif()
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
install(TARGETS volk_gnsssdr_static

View File

@ -31,10 +31,10 @@ FifoSignalSource::FifoSignalSource(ConfigurationInterface const* configuration,
[[maybe_unused]] Concurrent_Queue<pmt::pmt_t>* queue)
: SignalSourceBase(configuration, role, "Fifo_Signal_Source"s),
item_size_(sizeof(gr_complex)), // currenty output item size is always gr_complex
fifo_reader_(FifoReader::make(configuration->property(role + ".filename"s, "../data/example_capture.dat"s),
configuration->property(role + ".sample_type"s, "ishort"s))),
fifo_reader_(FifoReader::make(configuration->property(role + ".filename", "../data/example_capture.dat"s),
configuration->property(role + ".sample_type", "ishort"s))),
dump_(configuration->property(role + ".dump", false)),
dump_filename_(configuration->property(role + ".dump_filename"s, "./data/signal_source.dat"s))
dump_filename_(configuration->property(role + ".dump_filename", "./data/signal_source.dat"s))
{
if (dump_)
{

View File

@ -27,9 +27,9 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration,
unsigned int /* out_stream [[maybe_unused]] */,
Concurrent_Queue<pmt::pmt_t>* /* queue [[maybe_unused]] */)
: SignalSourceBase(configuration, role, "ZMQ_Signal_Source"s),
d_item_size(decode_item_type(configuration->property(role + ".item_type"s, "gr_complex"s), nullptr, true)),
d_dump_filename(configuration->property(role + ".dump_filename"s, "data/zmq_dump.dat"s)),
d_dump(configuration->property(role + ".dump"s, false))
d_item_size(decode_item_type(configuration->property(role + ".item_type", "gr_complex"s), nullptr, true)),
d_dump_filename(configuration->property(role + ".dump_filename", "data/zmq_dump.dat"s)),
d_dump(configuration->property(role + ".dump", false))
{
auto vlen = configuration->property(role + ".vlen"s, 1);
auto pass_tags = configuration->property(role + ".pass_tags"s, false);

View File

@ -681,6 +681,8 @@ void galileo_e6_has_msg_receiver::read_MT1_body(const std::string& message_body)
d_HAS_data.satellite_submask = std::vector<uint64_t>(d_HAS_data.Nsys_sub);
d_HAS_data.delta_clock_correction_clock_subset = std::vector<std::vector<int16_t>>(d_HAS_data.Nsys_sub, std::vector<int16_t>());
const std::string str_one("1");
const std::string str_zero("0");
for (uint8_t i = 0; i < d_HAS_data.Nsys_sub; i++)
{
d_HAS_data.gnss_id_clock_subset[i] = read_has_message_body_uint8(message.substr(0, HAS_MSG_ID_CLOCK_SUBSET_LENGTH));
@ -711,11 +713,11 @@ void galileo_e6_has_msg_receiver::read_MT1_body(const std::string& message_body)
{
if ((aux & mask_value) >= 1)
{
binary.insert(0, "1");
binary.insert(0, str_one);
}
else
{
binary.insert(0, "0");
binary.insert(0, str_zero);
}
aux <<= 1;
}

View File

@ -76,16 +76,20 @@ std::vector<int> Galileo_HAS_data::get_PRNs_in_submask(uint8_t nsys) const
uint64_t sat_submask = satellite_submask[nsys];
// convert into string
std::string sat_submask_str("");
sat_submask_str.reserve(number_sats_this_gnss_id);
uint64_t aux = 1;
const std::string one_str("1");
const std::string zero_str("0");
for (int k = 0; k < number_sats_this_gnss_id - 1; k++)
{
if ((aux & sat_submask) >= 1)
{
sat_submask_str.insert(0, "1");
sat_submask_str.insert(0, one_str);
}
else
{
sat_submask_str.insert(0, "0");
sat_submask_str.insert(0, zero_str);
}
aux <<= 1;
}

View File

@ -30,9 +30,9 @@ Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_)
void Gnss_Satellite::reset()
{
PRN = 0;
system = std::string("");
block = std::string("");
PRN = 0;
rf_link = 0;
}
@ -43,11 +43,11 @@ std::ostream& operator<<(std::ostream& out, const Gnss_Satellite& sat) // outpu
std::string tag2;
if (sat.get_system() == "Galileo")
{
tag = "E";
tag = std::string("E");
}
if (sat.get_PRN() < 10)
{
tag2 = "0";
tag2 = std::string("0");
}
out << sat.get_system() << " PRN " << tag << tag2 << sat.get_PRN() << " (Block " << sat.get_block() << ")";
return out;
@ -85,8 +85,8 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs)
if (this != &rhs)
{
this->system = rhs.system;
this->PRN = rhs.PRN;
this->block = rhs.block;
this->PRN = rhs.PRN;
this->rf_link = rhs.rf_link;
}
return *this;
@ -106,8 +106,8 @@ Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other) noexcept
if (this != &other)
{
this->system = other.get_system();
this->PRN = other.get_PRN();
this->block = other.get_block();
this->PRN = other.get_PRN();
this->rf_link = other.get_rf_link();
}
return *this;