aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/utils/eeprom_utils.hpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-03-02 15:25:13 -0800
committeratrnati <54334261+atrnati@users.noreply.github.com>2020-03-03 08:51:32 -0600
commit876d4150aa3da531ddd687b48afada6e43f79146 (patch)
treefd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/include/uhdlib/utils/eeprom_utils.hpp
parent1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff)
downloaduhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz
uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2
uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip
uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of files that clang-format gets applied against.
Diffstat (limited to 'host/lib/include/uhdlib/utils/eeprom_utils.hpp')
-rw-r--r--host/lib/include/uhdlib/utils/eeprom_utils.hpp54
1 files changed, 23 insertions, 31 deletions
diff --git a/host/lib/include/uhdlib/utils/eeprom_utils.hpp b/host/lib/include/uhdlib/utils/eeprom_utils.hpp
index 5104e1530..53390b200 100644
--- a/host/lib/include/uhdlib/utils/eeprom_utils.hpp
+++ b/host/lib/include/uhdlib/utils/eeprom_utils.hpp
@@ -7,19 +7,19 @@
#include <uhd/types/byte_vector.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/mac_addr.hpp>
-#include <boost/asio/ip/address_v4.hpp>
#include <uhd/utils/log.hpp>
+#include <boost/asio/ip/address_v4.hpp>
#include <string>
#include <vector>
-static const size_t SERIAL_LEN = 9;
+static const size_t SERIAL_LEN = 9;
static const size_t NAME_MAX_LEN = 32 - SERIAL_LEN;
//! convert a string to a byte vector to write to eeprom
-uhd::byte_vector_t string_to_uint16_bytes(const std::string &num_str);
+uhd::byte_vector_t string_to_uint16_bytes(const std::string& num_str);
//! convert a byte vector read from eeprom to a string
-std::string uint16_bytes_to_string(const uhd::byte_vector_t &bytes);
+std::string uint16_bytes_to_string(const uhd::byte_vector_t& bytes);
/*!
* Check for duplicate values within a given set of keys. Assumes the desire
@@ -37,21 +37,18 @@ std::string uint16_bytes_to_string(const uhd::byte_vector_t &bytes);
* \return true if duplicates are found, false if not
*/
template <typename field_type>
-bool check_for_duplicates(
- const std::string& error_label,
+bool check_for_duplicates(const std::string& error_label,
const uhd::dict<std::string, std::string>& new_eeprom,
const uhd::dict<std::string, std::string>& curr_eeprom,
const std::string& category,
- const std::vector<std::string>& keys
-) {
+ const std::vector<std::string>& keys)
+{
bool has_duplicates = false;
- for (size_t i = 0; i < keys.size(); i++)
- {
+ for (size_t i = 0; i < keys.size(); i++) {
bool found_duplicate = false;
- auto key = keys[i];
+ auto key = keys[i];
- if (not new_eeprom.has_key(key))
- {
+ if (not new_eeprom.has_key(key)) {
continue;
}
@@ -59,38 +56,33 @@ bool check_for_duplicates(
// Check other values in new_eeprom for duplicate
// Starting at key index i+1 so the same duplicate is not found twice
- for (size_t j = i+1; j < keys.size(); j++)
- {
+ for (size_t j = i + 1; j < keys.size(); j++) {
auto other_key = keys[j];
- if (not new_eeprom.has_key(other_key))
- {
+ if (not new_eeprom.has_key(other_key)) {
continue;
}
auto other_value = field_type::from_string(new_eeprom[other_key]).to_string();
- if (value == other_value)
- {
+ if (value == other_value) {
// Value is a duplicate of another supplied value
- UHD_LOG_ERROR(error_label, "Duplicate " << category << " "
- << new_eeprom[key] << " is supplied for both " << key
- << " and " << other_key);
+ UHD_LOG_ERROR(error_label,
+ "Duplicate " << category << " " << new_eeprom[key]
+ << " is supplied for both " << key << " and "
+ << other_key);
found_duplicate = true;
}
}
// Check all keys in curr_eeprom for duplicate value
- for (auto other_key: keys)
- {
+ for (auto other_key : keys) {
// Skip any keys in new_eeprom
- if (new_eeprom.has_key(other_key))
- {
+ if (new_eeprom.has_key(other_key)) {
continue;
}
- if (value == curr_eeprom[other_key])
- {
+ if (value == curr_eeprom[other_key]) {
// Value is duplicate of one in the EEPROM
- UHD_LOG_ERROR(error_label, "Duplicate " << category << " "
- << new_eeprom[key] << " is already in use for "
- << other_key);
+ UHD_LOG_ERROR(error_label,
+ "Duplicate " << category << " " << new_eeprom[key]
+ << " is already in use for " << other_key);
found_duplicate = true;
}
}