From a8f58f503c11ae1b396f21da9760f50cdd8a50a1 Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 29 Sep 2021 11:40:29 +0200 Subject: [PATCH] - Fix arm compiler warning. GCC treats chars as unsigned in this arch. - Fix race condition in json metrics. --- lib/src/common/enb_events.cc | 3 ++- srsenb/hdr/metrics_json.h | 3 +-- srsenb/src/main.cc | 3 +-- srsenb/src/metrics_json.cc | 5 ----- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/src/common/enb_events.cc b/lib/src/common/enb_events.cc index 30f19ac33..54276527e 100644 --- a/lib/src/common/enb_events.cc +++ b/lib/src/common/enb_events.cc @@ -94,7 +94,8 @@ static std::string escape_string(const std::string& s) fmt::format_to(buff, "\\t"); break; default: - if ('\x00' <= c && c <= '\x1f') { + // Cast to signed char for machines that treat chars as an unsigned type. + if ((signed char)c >= '\x00' && (signed char)c <= '\x1f') { fmt::format_to(buff, "\\u{:04x}", c); } else { buff.push_back(c); diff --git a/srsenb/hdr/metrics_json.h b/srsenb/hdr/metrics_json.h index 4692de03b..5d9388413 100644 --- a/srsenb/hdr/metrics_json.h +++ b/srsenb/hdr/metrics_json.h @@ -26,10 +26,9 @@ namespace srsenb { class metrics_json : public srsran::metrics_listener { public: - metrics_json(srslog::log_channel& c) : log_c(c) {} + metrics_json(srslog::log_channel& c, enb_metrics_interface* enb_) : log_c(c), enb(enb_) {} void set_metrics(const enb_metrics_t& m, const uint32_t period_usec) override; - void set_handle(enb_metrics_interface* enb_); void stop() override {} private: diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index da428aba8..6c80cb8a0 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -607,10 +607,9 @@ int main(int argc, char* argv[]) metrics_file.set_handle(enb.get()); } - srsenb::metrics_json json_metrics(json_channel); + srsenb::metrics_json json_metrics(json_channel, enb.get()); if (args.general.report_json_enable) { metricshub.add_listener(&json_metrics); - json_metrics.set_handle(enb.get()); } // create input thread diff --git a/srsenb/src/metrics_json.cc b/srsenb/src/metrics_json.cc index b706836d6..b88027534 100644 --- a/srsenb/src/metrics_json.cc +++ b/srsenb/src/metrics_json.cc @@ -15,11 +15,6 @@ using namespace srsenb; -void metrics_json::set_handle(enb_metrics_interface* enb_) -{ - enb = enb_; -} - namespace { /// Bearer container metrics.