From 13302a16aa32ba63bcceb2e2994f942cc38bab76 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Aug 2021 11:46:41 +0800 Subject: [PATCH] messages: build without "using namespace std" * add "std::" prefix in headers * add "using" declarations in .cc files. so we don't rely on "using namespace std" in one or more included headers. Signed-off-by: Kefu Chai --- src/messages/MClientMetrics.h | 2 +- src/messages/MMDSMetrics.h | 2 +- src/messages/MMDSPing.h | 2 +- src/messages/MMDSResolve.h | 2 +- src/messages/MMDSScrubStats.h | 2 +- src/messages/MMonCommand.h | 6 +++--- src/messages/MMonCommandAck.h | 6 +++--- src/messages/MMonJoin.h | 5 +++-- src/messages/MMonPing.h | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/messages/MClientMetrics.h b/src/messages/MClientMetrics.h index 0745f4eaaab..5db391fe7ac 100644 --- a/src/messages/MClientMetrics.h +++ b/src/messages/MClientMetrics.h @@ -28,7 +28,7 @@ public: return "client_metrics"; } - void print(ostream &out) const override { + void print(std::ostream &out) const override { out << "client_metrics "; for (auto &i : updates) { i.print(&out); diff --git a/src/messages/MMDSMetrics.h b/src/messages/MMDSMetrics.h index 4812e89bc30..4a8e036eb0a 100644 --- a/src/messages/MMDSMetrics.h +++ b/src/messages/MMDSMetrics.h @@ -29,7 +29,7 @@ public: return "mds_metrics"; } - void print(ostream &out) const override { + void print(std::ostream &out) const override { out << "mds_metrics from rank=" << metrics_message.rank << " carrying " << metrics_message.client_metrics_map.size() << " metric updates"; } diff --git a/src/messages/MMDSPing.h b/src/messages/MMDSPing.h index cf209baf69e..586ca91c1bc 100644 --- a/src/messages/MMDSPing.h +++ b/src/messages/MMDSPing.h @@ -27,7 +27,7 @@ public: return "mdsping"; } - void print(ostream &out) const override { + void print(std::ostream &out) const override { out << "mdsping"; } diff --git a/src/messages/MMDSResolve.h b/src/messages/MMDSResolve.h index 6a6ff2771db..7b4f7c123e5 100644 --- a/src/messages/MMDSResolve.h +++ b/src/messages/MMDSResolve.h @@ -32,7 +32,7 @@ public: inodeno_t ino; std::map cap_exports; peer_inode_cap() {} - peer_inode_cap(inodeno_t a, map b) : ino(a), cap_exports(b) {} + peer_inode_cap(inodeno_t a, std::map b) : ino(a), cap_exports(b) {} void encode(ceph::buffer::list &bl) const { ENCODE_START(1, 1, bl); diff --git a/src/messages/MMDSScrubStats.h b/src/messages/MMDSScrubStats.h index ab4268ec52b..c60981be590 100644 --- a/src/messages/MMDSScrubStats.h +++ b/src/messages/MMDSScrubStats.h @@ -23,7 +23,7 @@ class MMDSScrubStats : public MMDSOp { public: std::string_view get_type_name() const override { return "mds_scrub_stats"; } - void print(ostream& o) const override { + void print(std::ostream& o) const override { o << "mds_scrub_stats(e" << epoch; if (update_scrubbing) o << " [" << scrubbing_tags << "]"; diff --git a/src/messages/MMonCommand.h b/src/messages/MMonCommand.h index 494d5cf5606..29e4269e878 100644 --- a/src/messages/MMonCommand.h +++ b/src/messages/MMonCommand.h @@ -46,17 +46,17 @@ public: void print(std::ostream& o) const override { cmdmap_t cmdmap; std::ostringstream ss; - string prefix; + std::string prefix; cmdmap_from_json(cmd, &cmdmap, ss); cmd_getval(cmdmap, "prefix", prefix); // Some config values contain sensitive data, so don't log them o << "mon_command("; if (prefix == "config set") { - string name; + std::string name; cmd_getval(cmdmap, "name", name); o << "[{prefix=" << prefix << ", name=" << name << "}]"; } else if (prefix == "config-key set") { - string key; + std::string key; cmd_getval(cmdmap, "key", key); o << "[{prefix=" << prefix << ", key=" << key << "}]"; } else { diff --git a/src/messages/MMonCommandAck.h b/src/messages/MMonCommandAck.h index b49e8bcffdb..d452035dbfc 100644 --- a/src/messages/MMonCommandAck.h +++ b/src/messages/MMonCommandAck.h @@ -38,19 +38,19 @@ public: void print(std::ostream& o) const override { cmdmap_t cmdmap; std::ostringstream ss; - string prefix; + std::string prefix; cmdmap_from_json(cmd, &cmdmap, ss); cmd_getval(cmdmap, "prefix", prefix); // Some config values contain sensitive data, so don't log them o << "mon_command_ack("; if (prefix == "config set") { - string name; + std::string name; cmd_getval(cmdmap, "name", name); o << "[{prefix=" << prefix << ", name=" << name << "}]" << "=" << r << " " << rs << " v" << version << ")"; } else if (prefix == "config-key set") { - string key; + std::string key; cmd_getval(cmdmap, "key", key); o << "[{prefix=" << prefix << ", key=" << key << "}]" << "=" << r << " " << rs << " v" << version << ")"; diff --git a/src/messages/MMonJoin.h b/src/messages/MMonJoin.h index 008617c555d..d047cc3d920 100644 --- a/src/messages/MMonJoin.h +++ b/src/messages/MMonJoin.h @@ -31,7 +31,7 @@ public: * location. Generally the monitor will force an update if it's given a * location from the CLI on boot-up, and then never force again (so that it * can be moved/updated via the ceph tool from elsewhere). */ - map crush_loc; + std::map crush_loc; bool force_loc{false}; MMonJoin() : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION} {} @@ -39,7 +39,8 @@ public: : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION}, fsid(f), name(n), addrs(av) { } - MMonJoin(uuid_d &f, std::string n, const entity_addrvec_t& av, const map& cloc, bool force) + MMonJoin(uuid_d &f, std::string n, const entity_addrvec_t& av, + const std::map& cloc, bool force) : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION}, fsid(f), name(n), addrs(av), crush_loc(cloc), force_loc(force) { } diff --git a/src/messages/MMonPing.h b/src/messages/MMonPing.h index 682094958b4..c6f697e501d 100644 --- a/src/messages/MMonPing.h +++ b/src/messages/MMonPing.h @@ -96,7 +96,7 @@ public: } std::string_view get_type_name() const override { return "mon_ping"; } - void print(ostream& out) const override { + void print(std::ostream& out) const override { out << "mon_ping(" << get_op_name(op) << " stamp " << stamp << ")"; -- 2.39.5