Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78ac09cd authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Gd+RootCanal: Fix errors found in cppcoreguidelines-pro-type-member-init"

parents 4fd7be86 68048748
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ static_assert(sizeof(Address) == 6, "Address must be 6 bytes long!");
const Address Address::kAny{{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
const Address Address::kEmpty{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};

// Address cannot initialize member variables as it is a POD type
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
Address::Address(const uint8_t (&addr)[6]) {
  std::copy(addr, addr + kLength, address);
};
@@ -46,7 +48,7 @@ std::string Address::ToString() const {
}

bool Address::FromString(const std::string& from, Address& to) {
  Address new_addr;
  Address new_addr{};
  if (from.length() != 17) {
    return false;
  }
@@ -86,7 +88,7 @@ size_t Address::FromOctets(const uint8_t* from) {
};

bool Address::IsValidAddress(const std::string& address) {
  Address tmp;
  Address tmp{};
  return Address::FromString(address, tmp);
}

+4 −2
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ namespace hci {

static_assert(sizeof(ClassOfDevice) == ClassOfDevice::kLength, "ClassOfDevice must be 3 bytes long!");

// ClassOfDevice cannot initialize member variables as it is a POD type
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
ClassOfDevice::ClassOfDevice(const uint8_t (&class_of_device)[kLength]) {
  std::copy(class_of_device, class_of_device + kLength, cod);
};
@@ -43,7 +45,7 @@ std::string ClassOfDevice::ToString() const {
}

bool ClassOfDevice::FromString(const std::string& from, ClassOfDevice& to) {
  ClassOfDevice new_cod;
  ClassOfDevice new_cod{};
  if (from.length() != 8) return false;

  std::istringstream stream(from);
@@ -90,7 +92,7 @@ size_t ClassOfDevice::FromOctets(const uint8_t* from) {
};

bool ClassOfDevice::IsValid(const std::string& cod) {
  ClassOfDevice tmp;
  ClassOfDevice tmp{};
  return ClassOfDevice::FromString(cod, tmp);
}
}  // namespace hci
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ class ClassOfDevice final {

  ClassOfDevice() = default;
  ClassOfDevice(const uint8_t (&class_of_device)[kLength]);

  bool operator==(const ClassOfDevice& rhs) const {
    return (std::memcmp(cod, rhs.cod, sizeof(cod)) == 0);
  }
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class Iterator : public std::iterator<std::random_access_iterator_tag, uint8_t>
  template <typename FixedWidthPODType>
  FixedWidthPODType extract() {
    static_assert(std::is_pod<FixedWidthPODType>::value, "Iterator::extract requires a fixed-width type.");
    FixedWidthPODType extracted_value;
    FixedWidthPODType extracted_value{};
    uint8_t* value_ptr = (uint8_t*)&extracted_value;

    for (size_t i = 0; i < sizeof(FixedWidthPODType); i++) {
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ void ArrayField::GenGetter(std::ostream& s, Size start_offset, Size end_offset)
  s << "auto to_bound = begin();";

  int num_leading_bits = GenBounds(s, start_offset, end_offset, GetSize());
  s << GetDataType() << " " << GetName() << "_value;";
  s << GetDataType() << " " << GetName() << "_value{};";
  s << GetDataType() << "* " << GetName() << "_ptr = &" << GetName() << "_value;";
  GenExtractor(s, num_leading_bits, false);

Loading