From: Kefu Chai Date: Wed, 11 Aug 2021 03:46:41 +0000 (+0800) Subject: messages: build without "using namespace std" X-Git-Tag: v17.1.0~1121^2~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=13302a16aa32ba63bcceb2e2994f942cc38bab76;p=ceph.git 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 --- diff --git a/src/messages/MClientMetrics.h b/src/messages/MClientMetrics.h index 0745f4eaaab5..5db391fe7ac8 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 4812e89bc307..4a8e036eb0a7 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 cf209baf69e7..586ca91c1bcb 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 6a6ff2771db7..7b4f7c123e5e 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 ab4268ec52b8..c60981be5907 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 494d5cf5606b..29e4269e8782 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 b49e8bcffdbb..d452035dbfc1 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 008617c555d6..d047cc3d920f 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 682094958b43..c6f697e501d3 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 << ")";