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

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

Merge "Inline ToLoggableStr as this is always applied" into main

parents d5b627fa 24c5b49c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -73,12 +73,12 @@ void FixedChannelImpl::Acquire() {
  log::assert_that(user_handler_ != nullptr,
                   "Must register OnCloseCallback before calling any methods");
  if (closed_) {
    log::warn("{} is already closed", ToLoggableStr(*this));
    log::warn("{} is already closed", ToRedactedStringForLogging());
    log::assert_that(!acquired_, "assert failed: !acquired_");
    return;
  }
  if (acquired_) {
    log::info("{} was already acquired", ToLoggableStr(*this));
    log::info("{} was already acquired", ToRedactedStringForLogging());
    return;
  }
  acquired_ = true;
@@ -89,12 +89,12 @@ void FixedChannelImpl::Release() {
  log::assert_that(user_handler_ != nullptr,
                   "Must register OnCloseCallback before calling any methods");
  if (closed_) {
    log::warn("{} is already closed", ToLoggableStr(*this));
    log::warn("{} is already closed", ToRedactedStringForLogging());
    log::assert_that(!acquired_, "assert failed: !acquired_");
    return;
  }
  if (!acquired_) {
    log::info("{} was already released", ToLoggableStr(*this));
    log::info("{} was already released", ToRedactedStringForLogging());
    return;
  }
  acquired_ = false;
+4 −4
Original line number Diff line number Diff line
@@ -52,14 +52,14 @@ public:
  // object is still owned by the channel allocator, NOT the client.
  virtual std::shared_ptr<FixedChannelImplType> AllocateChannel(Cid cid) {
    log::assert_that(!IsChannelAllocated(cid), "Cid 0x{:x} for link {} is already in use", cid,
                     ToLoggableStr(*link_));
                     link_->ToRedactedStringForLogging());

    log::assert_that(cid >= kFirstFixedChannel && cid <= kLastFixedChannel, "Cid {} out of bound",
                     cid);
    auto elem = channels_.try_emplace(
            cid, std::make_shared<FixedChannelImplType>(cid, link_, l2cap_handler_));
    log::assert_that(elem.second, "Failed to create channel for cid 0x{:x} link {}", cid,
                     ToLoggableStr(*link_));  // TODO RENAME ADDRESS_TO_LOGGABLE_CSTR
                     link_->ToRedactedStringForLogging());
    log::assert_that(elem.first->second != nullptr, "assert failed: elem.first->second != nullptr");
    return elem.first->second;
  }
@@ -67,7 +67,7 @@ public:
  // Frees a channel. If cid doesn't exist, it will crash
  virtual void FreeChannel(Cid cid) {
    log::assert_that(IsChannelAllocated(cid), "Channel is not in use: cid {}, link {}", cid,
                     ToLoggableStr(*link_));
                     link_->ToRedactedStringForLogging());

    channels_.erase(cid);
  }
@@ -76,7 +76,7 @@ public:

  virtual std::shared_ptr<FixedChannelImplType> FindChannel(Cid cid) {
    log::assert_that(IsChannelAllocated(cid), "Channel is not in use: cid {}, link {}", cid,
                     ToLoggableStr(*link_));
                     link_->ToRedactedStringForLogging());

    return channels_.find(cid)->second;
  }
+4 −4
Original line number Diff line number Diff line
@@ -80,12 +80,12 @@ void FixedChannelImpl::Acquire() {
  log::assert_that(user_handler_ != nullptr,
                   "Must register OnCloseCallback before calling any methods");
  if (closed_) {
    log::warn("{} is already closed", ToLoggableStr(*this));
    log::warn("{} is already closed", ToRedactedStringForLogging());
    log::assert_that(!acquired_, "assert failed: !acquired_");
    return;
  }
  if (acquired_) {
    log::info("{} was already acquired", ToLoggableStr(*this));
    log::info("{} was already acquired", ToRedactedStringForLogging());
    return;
  }
  acquired_ = true;
@@ -96,12 +96,12 @@ void FixedChannelImpl::Release() {
  log::assert_that(user_handler_ != nullptr,
                   "Must register OnCloseCallback before calling any methods");
  if (closed_) {
    log::warn("{} is already closed", ToLoggableStr(*this));
    log::warn("{} is already closed", ToRedactedStringForLogging());
    log::assert_that(!acquired_, "assert failed: !acquired_");
    return;
  }
  if (!acquired_) {
    log::info("{} was already released", ToLoggableStr(*this));
    log::info("{} was already released", ToRedactedStringForLogging());
    return;
  }
  acquired_ = false;
+1 −10
Original line number Diff line number Diff line
@@ -20,16 +20,7 @@

#include <string>

// as RawAddress does not implement IRedactableLoggable
// here we use a template function as a tricky workaround.
// in the future. we want to convert it into a function
// that takes a reference to IRedactableLoggable
template <typename Loggable>
std::string ToLoggableStr(const Loggable& loggable) {
  return loggable.ToRedactedStringForLogging();
}

#define ADDRESS_TO_LOGGABLE_STR(addr) ToLoggableStr(addr)
#define ADDRESS_TO_LOGGABLE_STR(addr) (addr).ToRedactedStringForLogging()
#define ADDRESS_TO_LOGGABLE_CSTR(addr) ADDRESS_TO_LOGGABLE_STR(addr).c_str()

#define PRIVATE_CELL(number)                                        \