diff options
author | Alexei Frolov <frolv@google.com> | 2021-02-23 08:15:54 -0800 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2021-02-23 18:06:30 +0000 |
commit | da401abdfd5fd526a5a479ab2159cae579d65a63 (patch) | |
tree | 337ec2b1296669cc4f40e75492893952c005c3a5 | |
parent | 3c81ec2e9da5e817b29a4462202485b65372c122 (diff) | |
download | pigweed-da401abdfd5fd526a5a479ab2159cae579d65a63.tar.gz |
pw_router: Remove logging
This removes all log statements from the static router. This is done as
there is no guarantee for what pw_log backend is used. In some systems,
logs may flow directly through the router, resulting in recursive calls
that cause a crash.
The user of the router can choose to check and log its return values if
the operation is safe.
Change-Id: I3a94d9245fde8fd5d27a23ddd1713aba1e880bd8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/33621
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Alexei Frolov <frolv@google.com>
-rw-r--r-- | pw_router/BUILD.gn | 1 | ||||
-rw-r--r-- | pw_router/static_router.cc | 13 |
2 files changed, 0 insertions, 14 deletions
diff --git a/pw_router/BUILD.gn b/pw_router/BUILD.gn index 867f871aa..a30eb7a8d 100644 --- a/pw_router/BUILD.gn +++ b/pw_router/BUILD.gn @@ -35,7 +35,6 @@ pw_source_set("static_router") { ] public = [ "public/pw_router/static_router.h" ] sources = [ "static_router.cc" ] - deps = [ dir_pw_log ] } pw_source_set("egress") { diff --git a/pw_router/static_router.cc b/pw_router/static_router.cc index 72c72427d..a32e74a82 100644 --- a/pw_router/static_router.cc +++ b/pw_router/static_router.cc @@ -17,8 +17,6 @@ #include <algorithm> #include <mutex> -#include "pw_log/log.h" - namespace pw::router { Status StaticRouter::RoutePacket(ConstByteSpan packet) { @@ -30,14 +28,12 @@ Status StaticRouter::RoutePacket(ConstByteSpan packet) { std::lock_guard lock(mutex_); if (!parser_.Parse(packet)) { - PW_LOG_ERROR("StaticRouter failed to parse packet; dropping"); parser_errors_.Increment(); return Status::DataLoss(); } std::optional<uint32_t> result = parser_.GetDestinationAddress(); if (!result.has_value()) { - PW_LOG_ERROR("StaticRouter packet does not have address; dropping"); parser_errors_.Increment(); return Status::DataLoss(); } @@ -49,20 +45,11 @@ Status StaticRouter::RoutePacket(ConstByteSpan packet) { return r.address == address; }); if (route == routes_.end()) { - PW_LOG_ERROR("StaticRouter no route for address %u; dropping packet", - static_cast<unsigned>(address)); route_errors_.Increment(); return Status::NotFound(); } - PW_LOG_DEBUG("StaticRouter routing %u-byte packet to address %u", - static_cast<unsigned>(packet.size()), - static_cast<unsigned>(address)); - if (Status status = route->egress.SendPacket(packet); !status.ok()) { - PW_LOG_ERROR("StaticRouter egress error for address %u: %s", - static_cast<unsigned>(address), - status.str()); egress_errors_.Increment(); return Status::Unavailable(); } |