1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-10-30 22:56:22 +00:00

Clang Tidy fixes

This commit is contained in:
cesaaargm 2024-08-01 18:45:03 +02:00
parent eefa3b3aa7
commit 1dec33dbf5
7 changed files with 36 additions and 36 deletions

View File

@ -1013,7 +1013,6 @@ void osnma_msg_receiver::process_mack_message()
LOG(WARNING) << "Galileo OSNMA: MACK cannot be processed, " LOG(WARNING) << "Galileo OSNMA: MACK cannot be processed, "
<< "no Kroot nor TESLA key available."; << "no Kroot nor TESLA key available.";
return; // early return, cannot proceed further without one of the two verified. this equals to having Kroot but no TESLa key yet. return; // early return, cannot proceed further without one of the two verified. this equals to having Kroot but no TESLa key yet.
} }
// verify tesla key and add it to the container of verified keys if successful // verify tesla key and add it to the container of verified keys if successful
if (d_tesla_keys.find(d_osnma_data.d_nav_data.get_tow_sf0()) == d_tesla_keys.end()) // check if already available => no need to verify if (d_tesla_keys.find(d_osnma_data.d_nav_data.get_tow_sf0()) == d_tesla_keys.end()) // check if already available => no need to verify
@ -1925,9 +1924,9 @@ void osnma_msg_receiver::send_data_to_pvt(std::vector<OSNMA_NavData> data)
{ {
if (!data.empty()) if (!data.empty())
{ {
for (size_t i = 0; i < data.size(); i++) for (auto & i : data)
{ {
const auto tmp_obj = std::make_shared<OSNMA_NavData>(data[i]); const auto tmp_obj = std::make_shared<OSNMA_NavData>(i);
this->message_port_pub(pmt::mp("OSNMA_to_PVT"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("OSNMA_to_PVT"), pmt::make_any(tmp_obj));
} }
} }

View File

@ -897,8 +897,9 @@ void Gnss_Crypto::set_public_key(const std::vector<uint8_t>& publicKey)
param_bld = OSSL_PARAM_BLD_new(); param_bld = OSSL_PARAM_BLD_new();
if (param_bld != nullptr && if (param_bld != nullptr &&
OSSL_PARAM_BLD_push_utf8_string(param_bld, "group", (publicKey.size() == 33) ? "prime256v1" : "secp521r1", 0) && OSSL_PARAM_BLD_push_utf8_string(param_bld, "group", (publicKey.size() == 33) ? "prime256v1" : "secp521r1", 0) &&
OSSL_PARAM_BLD_push_octet_string(param_bld, "pub", publicKey.data(), publicKey.size())) OSSL_PARAM_BLD_push_octet_string(param_bld, "pub", publicKey.data(), publicKey.size())) {
params = OSSL_PARAM_BLD_to_param(param_bld); params = OSSL_PARAM_BLD_to_param(param_bld);
}
ctx = EVP_PKEY_CTX_new_from_name(nullptr, "EC", nullptr); ctx = EVP_PKEY_CTX_new_from_name(nullptr, "EC", nullptr);
if (ctx == nullptr || params == nullptr || EVP_PKEY_fromdata_init(ctx) <= 0 || EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_PUBLIC_KEY, params) <= 0) if (ctx == nullptr || params == nullptr || EVP_PKEY_fromdata_init(ctx) <= 0 || EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_PUBLIC_KEY, params) <= 0)
@ -1192,7 +1193,7 @@ bool Gnss_Crypto::readPublicKeyFromCRT(const std::string& crtFilePath)
// store the key type - needed for the Kroot in case no DSM-PKR available // store the key type - needed for the Kroot in case no DSM-PKR available
// TODO - only way I have found to find the curve type // TODO - only way I have found to find the curve type
auto ec_key = EVP_PKEY_get0_EC_KEY(pubkey); const auto ec_key = EVP_PKEY_get0_EC_KEY(pubkey);
const EC_GROUP *group = EC_KEY_get0_group(ec_key); const EC_GROUP *group = EC_KEY_get0_group(ec_key);
int nid = EC_GROUP_get_curve_name(group); int nid = EC_GROUP_get_curve_name(group);
if (nid == NID_X9_62_prime256v1) { if (nid == NID_X9_62_prime256v1) {

View File

@ -19,7 +19,7 @@
uint32_t Tag::id_counter = 0; uint32_t Tag::id_counter = 0;
uint32_t OSNMA_NavData::id_counter = 0; uint32_t OSNMA_NavData::id_counter = 0;
bool OSNMA_NavData::add_nav_data(std::string nav_data) bool OSNMA_NavData::add_nav_data(const std::string& nav_data)
{ {
if (nav_data.size() == 549) if (nav_data.size() == 549)
{ {

View File

@ -129,7 +129,7 @@ class OSNMA_NavData
public: public:
OSNMA_NavData(): nav_data_id(id_counter++){} OSNMA_NavData(): nav_data_id(id_counter++){}
bool have_this_bits(std::string nav_data); bool have_this_bits(std::string nav_data);
bool add_nav_data(std::string nav_data); bool add_nav_data(const std::string& nav_data);
void update_last_received_timestamp(uint32_t TOW); void update_last_received_timestamp(uint32_t TOW);
const uint32_t nav_data_id; const uint32_t nav_data_id;
uint32_t verified_bits{0}; uint32_t verified_bits{0};

View File

@ -39,7 +39,6 @@ public:
std::vector<uint8_t> convert_from_hex_string(const std::string& hex_string) const; // TODO remove similar function in gnss_crypto std::vector<uint8_t> convert_from_hex_string(const std::string& hex_string) const; // TODO remove similar function in gnss_crypto
std::tm GST_START_EPOCH = {0, 0, 0, 22, 8 - 1, 1999 - 1900, 0, 0, 0, 0, 0}; std::tm GST_START_EPOCH = {0, 0, 0, 22, 8 - 1, 1999 - 1900, 0, 0, 0, 0, 0};
}; };
#endif // GNSS_SDR_OSNMA_HELPER_H #endif // GNSS_SDR_OSNMA_HELPER_H

View File

@ -29,7 +29,7 @@
* @param PRNd The satellite ID. * @param PRNd The satellite ID.
* @param TOW The TOW of the received data. * @param TOW The TOW of the received data.
*/ */
void OSNMA_nav_data_Manager::add_navigation_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW) void OSNMA_nav_data_Manager::add_navigation_data(const std::string& nav_bits, uint32_t PRNd, uint32_t TOW)
{ {
if (not have_nav_data(nav_bits, PRNd, TOW)) if (not have_nav_data(nav_bits, PRNd, TOW))
{ {
@ -52,18 +52,18 @@ void OSNMA_nav_data_Manager::update_nav_data(const std::multimap<uint32_t, Tag>&
if (have_PRNd_nav_data(tag.second.PRN_d)) if (have_PRNd_nav_data(tag.second.PRN_d))
{ {
std::map<uint32_t, OSNMA_NavData> tow_map = _satellite_nav_data.find(tag.second.PRN_d)->second; std::map<uint32_t, OSNMA_NavData> tow_map = _satellite_nav_data.find(tag.second.PRN_d)->second;
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset for (auto & tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
{ {
std::string nav_data; std::string nav_data;
if (tag.second.ADKD == 0 || tag.second.ADKD == 12){ if (tag.second.ADKD == 0 || tag.second.ADKD == 12){
nav_data = tow_it->second.get_ephemeris_data(); nav_data = tow_it.second.get_ephemeris_data();
} }
else if (tag.second.ADKD == 4){ else if (tag.second.ADKD == 4){
nav_data = tow_it->second.get_utc_data(); nav_data = tow_it.second.get_utc_data();
} }
// find associated OSNMA_NavData // find associated OSNMA_NavData
if (tag.second.nav_data == nav_data){ if (tag.second.nav_data == nav_data){
_satellite_nav_data[tag.second.PRN_d][tow_it->first].verified_bits += tag_size; _satellite_nav_data[tag.second.PRN_d][tow_it.first].verified_bits += tag_size;
} }
} }
} }
@ -99,7 +99,7 @@ bool OSNMA_nav_data_Manager::have_nav_data(uint32_t PRNd, uint32_t TOW, uint8_t
if (it != _satellite_nav_data.cend()) if (it != _satellite_nav_data.cend())
{ {
const auto it2 = it->second.find(TOW); const auto it2 = it->second.find(TOW);
if (it2 != it->second.cend() && it->second[TOW].get_ephemeris_data() != "") if (it2 != it->second.cend() && !it->second[TOW].get_ephemeris_data().empty())
{ {
return true; return true;
} }
@ -111,7 +111,7 @@ bool OSNMA_nav_data_Manager::have_nav_data(uint32_t PRNd, uint32_t TOW, uint8_t
if (it != _satellite_nav_data.cend()) if (it != _satellite_nav_data.cend())
{ {
const auto it2 = it->second.find(TOW); const auto it2 = it->second.find(TOW);
if (it2 != it->second.cend() && it->second[TOW].get_utc_data() != "") if (it2 != it->second.cend() && !it->second[TOW].get_utc_data().empty())
{ {
return true; return true;
} }
@ -140,13 +140,13 @@ std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
{ {
if (tag.ADKD == 0 || tag.ADKD == 12) if (tag.ADKD == 0 || tag.ADKD == 12)
{ {
if (tow_it->second.get_ephemeris_data() != ""){ if (!tow_it->second.get_ephemeris_data().empty()){
return tow_it->second.get_ephemeris_data(); return tow_it->second.get_ephemeris_data();
} }
} }
else if(tag.ADKD == 4) else if(tag.ADKD == 4)
{ {
if (tow_it->second.get_utc_data() != ""){ if (!tow_it->second.get_utc_data().empty()){
return tow_it->second.get_utc_data(); return tow_it->second.get_utc_data();
} }
} }
@ -161,7 +161,7 @@ std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
* @param PRNd * @param PRNd
* @return * @return
*/ */
bool OSNMA_nav_data_Manager::have_nav_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW) bool OSNMA_nav_data_Manager::have_nav_data(const std::string& nav_bits, uint32_t PRNd, uint32_t TOW)
{ {
if (_satellite_nav_data.find(PRNd) != _satellite_nav_data.end()){ if (_satellite_nav_data.find(PRNd) != _satellite_nav_data.end()){
for (auto& data_timestamp : _satellite_nav_data[PRNd]) for (auto& data_timestamp : _satellite_nav_data[PRNd])
@ -202,13 +202,13 @@ bool OSNMA_nav_data_Manager::have_nav_data(const Tag& t) const
{ {
if (t.ADKD == 0 || t.ADKD == 12) if (t.ADKD == 0 || t.ADKD == 12)
{ {
if (tow_it->second.get_ephemeris_data() != ""){ if (!tow_it->second.get_ephemeris_data().empty()){
return true; return true;
} }
} }
else if (t.ADKD == 4) else if (t.ADKD == 4)
{ {
if (tow_it->second.get_utc_data() != ""){ if (!tow_it->second.get_utc_data().empty()){
return true; return true;
} }
} }
@ -220,8 +220,8 @@ void OSNMA_nav_data_Manager::print_status()
{ {
for (const auto& satellite : _satellite_nav_data){ for (const auto& satellite : _satellite_nav_data){
LOG(INFO) << "Galileo OSNMA: NavData status :: SVID=" << satellite.first; LOG(INFO) << "Galileo OSNMA: NavData status :: SVID=" << satellite.first;
auto& tow_data = satellite.second; const auto& tow_data = satellite.second;
for (const auto& nav_data : tow_data) for (const auto& nav_data : tow_data) {
LOG(INFO) << "Galileo OSNMA: IOD_nav=0b" << std::uppercase LOG(INFO) << "Galileo OSNMA: IOD_nav=0b" << std::uppercase
<< std::bitset<10>(nav_data.second.IOD_nav) << std::bitset<10>(nav_data.second.IOD_nav)
<< ", TOW_start=" << ", TOW_start="
@ -235,4 +235,5 @@ void OSNMA_nav_data_Manager::print_status()
<< ", verified=" << ", verified="
<< nav_data.second.verified; << nav_data.second.verified;
} }
}
} }

View File

@ -32,10 +32,10 @@
class OSNMA_nav_data_Manager{ class OSNMA_nav_data_Manager{
public: public:
OSNMA_nav_data_Manager() = default; OSNMA_nav_data_Manager() = default;
bool have_nav_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW); bool have_nav_data(const std::string& nav_bits, uint32_t PRNd, uint32_t TOW);
bool have_nav_data(uint32_t PRNd, uint32_t TOW, uint8_t ADKD); bool have_nav_data(uint32_t PRNd, uint32_t TOW, uint8_t ADKD);
bool have_nav_data(const Tag& t) const; bool have_nav_data(const Tag& t) const;
void add_navigation_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW); // gets the bits and adds them to the list void add_navigation_data(const std::string& nav_bits, uint32_t PRNd, uint32_t TOW); // gets the bits and adds them to the list
std::string get_navigation_data(const Tag& t); std::string get_navigation_data(const Tag& t);
void update_nav_data(const std::multimap<uint32_t, Tag>& tags_verified, const uint8_t tag_size); void update_nav_data(const std::multimap<uint32_t, Tag>& tags_verified, const uint8_t tag_size);