]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Build target 'common' without using namespace in headers
authorAdam C. Emerson <aemerson@redhat.com>
Sat, 7 Mar 2020 09:30:35 +0000 (04:30 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Sat, 7 Mar 2020 09:30:35 +0000 (04:30 -0500)
Part of a changeset to allow building all of 'common' without relying
on 'using namespace std' or 'using namespace ceph' at toplevel in
headers.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
48 files changed:
src/common/CommandTable.h
src/common/DecayCounter.cc
src/common/DecayCounter.h
src/common/Graylog.cc
src/common/HeartbeatMap.cc
src/common/LogClient.cc
src/common/LogEntry.cc
src/common/OutputDataSocket.cc
src/common/OutputDataSocket.h
src/common/PluginRegistry.cc
src/common/Readahead.cc
src/common/SloppyCRCMap.cc
src/common/SloppyCRCMap.h
src/common/Throttle.cc
src/common/Timer.cc
src/common/TrackedOp.cc
src/common/WorkQueue.cc
src/common/address_helper.cc
src/common/admin_socket.cc
src/common/admin_socket.h
src/common/assert.cc
src/common/blkdev.cc
src/common/bloom_filter.cc
src/common/buffer.cc
src/common/ceph_argparse.cc
src/common/ceph_context.cc
src/common/ceph_json.cc
src/common/ceph_time.cc
src/common/cmdparse.cc
src/common/common_init.cc
src/common/config.cc
src/common/dns_resolve.cc
src/common/fs_types.cc
src/common/histogram.cc
src/common/hobject.cc
src/common/ipaddr.cc
src/common/lockdep.cc
src/common/numa.cc
src/common/options.cc
src/common/perf_counters.cc
src/common/pick_address.cc
src/common/rabin.cc
src/common/rabin.h
src/common/scrub_types.cc
src/common/signal.cc
src/common/snap_types.cc
src/common/types.cc
src/common/util.cc

index 419988f7748b8c6463e82a29a87761175989c0d6..53218d65351fc0ead299cb16afe0af6396e1db57 100644 (file)
@@ -34,13 +34,13 @@ class CommandOp
                         bool mgr=false) const
   {
     if (mgr) {
-      auto m = make_message<MMgrCommand>(fsid);
+      auto m = ceph::make_message<MMgrCommand>(fsid);
       m->cmd = cmd;
       m->set_data(inbl);
       m->set_tid(tid);
       return m;
     } else {
-      auto m = make_message<MCommand>(fsid);
+      auto m = ceph::make_message<MCommand>(fsid);
       m->cmd = cmd;
       m->set_data(inbl);
       m->set_tid(tid);
index f34a6eba386e96624b3a3d0b54eb7390cd26743d..4e9e68cc1525dd200cabc1d5be3345b45bc62427 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "include/encoding.h"
 
-void DecayCounter::encode(bufferlist& bl) const
+void DecayCounter::encode(ceph::buffer::list& bl) const
 {
   decay();
   ENCODE_START(5, 4, bl);
@@ -25,7 +25,7 @@ void DecayCounter::encode(bufferlist& bl) const
   ENCODE_FINISH(bl);
 }
 
-void DecayCounter::decode(bufferlist::const_iterator &p)
+void DecayCounter::decode(ceph::buffer::list::const_iterator &p)
 {
   DECODE_START_LEGACY_COMPAT_LEN(5, 4, 4, p);
   if (struct_v < 2) {
@@ -47,7 +47,7 @@ void DecayCounter::decode(bufferlist::const_iterator &p)
   DECODE_FINISH(p);
 }
 
-void DecayCounter::dump(Formatter *f) const
+void DecayCounter::dump(ceph::Formatter *f) const
 {
   decay();
   f->dump_float("value", val);
index b9545b1516194d118d10023f24605fbb11a9cf0a..2202b596e2adc02b8396659a556cc18600d762b1 100644 (file)
@@ -60,9 +60,9 @@ public:
   DecayCounter() : DecayCounter(DecayRate()) {}
   explicit DecayCounter(const DecayRate &rate) : last_decay(clock::now()), rate(rate) {}
 
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::const_iterator& p);
-  void dump(Formatter *f) const;
+  void encode(ceph::buffer::list& bl) const;
+  void decode(ceph::buffer::list::const_iterator& p);
+  void dump(ceph::Formatter *f) const;
   static void generate_test_instances(std::list<DecayCounter*>& ls);
 
   /**
@@ -117,10 +117,10 @@ private:
   DecayRate rate;
 };
 
-inline void encode(const DecayCounter &c, bufferlist &bl) {
+inline void encode(const DecayCounter &c, ceph::buffer::list &bl) {
   c.encode(bl);
 }
-inline void decode(DecayCounter &c, bufferlist::const_iterator &p) {
+inline void decode(DecayCounter &c, ceph::buffer::list::const_iterator &p) {
   c.decode(p);
 }
 
index 79a537eeddeea6e397b4593a209815d485134358..accde0900a50e042f418f80e5499a7d923a61f52 100644 (file)
@@ -7,8 +7,9 @@
 #include "log/Entry.h"
 #include "log/SubsystemMap.h"
 
-namespace ceph {
-namespace logging {
+using std::cerr;
+
+namespace ceph::logging {
 
 Graylog::Graylog(const SubsystemMap * const s, const std::string &logger)
     : m_subs(s),
@@ -166,5 +167,4 @@ void Graylog::log_log_entry(LogEntry const * const e)
   }
 }
 
-} // ceph::logging::
-} // ceph::
+} // name ceph::logging
index 165fdbb3fac3aae9d65c4c9ed102d5b4cb6e159c..7e5b8140632756ea2bd344dc125ce21578a13ee2 100644 (file)
 #undef dout_prefix
 #define dout_prefix *_dout << "heartbeat_map "
 
+using std::chrono::duration_cast;
+using std::chrono::seconds;
+using std::string;
+
 namespace ceph {
 
 HeartbeatMap::HeartbeatMap(CephContext *cct)
@@ -88,8 +92,8 @@ void HeartbeatMap::reset_timeout(heartbeat_handle_d *h,
 {
   ldout(m_cct, 20) << "reset_timeout '" << h->name << "' grace " << grace
                   << " suicide " << suicide_grace << dendl;
-  auto now = chrono::duration_cast<chrono::seconds>(
-              ceph::coarse_mono_clock::now().time_since_epoch()).count();
+  auto now = duration_cast<seconds>(coarse_mono_clock::now()
+                                   .time_since_epoch()).count();
   _check(h, "reset_timeout", now);
 
   h->timeout = now + grace;
@@ -105,8 +109,8 @@ void HeartbeatMap::reset_timeout(heartbeat_handle_d *h,
 void HeartbeatMap::clear_timeout(heartbeat_handle_d *h)
 {
   ldout(m_cct, 20) << "clear_timeout '" << h->name << "'" << dendl;
-  auto now = chrono::duration_cast<std::chrono::seconds>(
-              ceph::coarse_mono_clock::now().time_since_epoch()).count();
+  auto now = duration_cast<seconds>(coarse_mono_clock::now()
+                                   .time_since_epoch()).count();
   _check(h, "clear_timeout", now);
   h->timeout = 0;
   h->suicide_timeout = 0;
@@ -132,11 +136,11 @@ bool HeartbeatMap::is_healthy()
     healthy = false;
   }
 
-  for (list<heartbeat_handle_d*>::iterator p = m_workers.begin();
+  for (auto p = m_workers.begin();
        p != m_workers.end();
        ++p) {
     heartbeat_handle_d *h = *p;
-    auto epoch = chrono::duration_cast<chrono::seconds>(now.time_since_epoch()).count();
+    auto epoch = duration_cast<seconds>(now.time_since_epoch()).count();
     if (!_check(h, "is_healthy", epoch)) {
       healthy = false;
       unhealthy++;
index b941bd47e3974c3f535b6e1915181b0630032f85..05e7101559b68f4b479252caaaf1d57b1fac85b5 100644 (file)
 
 #define dout_subsys ceph_subsys_monc
 
+using std::map;
+using std::ostream;
+using std::ostringstream;
+using std::string;
+
 int parse_log_client_options(CephContext *cct,
                             map<string,string> &log_to_monitors,
                             map<string,string> &log_to_syslog,
@@ -351,7 +356,7 @@ bool LogClient::handle_log_ack(MLogAck *m)
 
   version_t last = m->last;
 
-  deque<LogEntry>::iterator q = log_queue.begin();
+  auto q = log_queue.begin();
   while (q != log_queue.end()) {
     const LogEntry &entry(*q);
     if (entry.seq > last)
@@ -361,4 +366,3 @@ bool LogClient::handle_log_ack(MLogAck *m)
   }
   return true;
 }
-
index 993bf444dc3937946e7ea5ea5e9f9d581944f4d4..dfa1ab2fa1dfd569638f49cca535be0d02672133 100644 (file)
@@ -8,6 +8,17 @@
 #include "Formatter.h"
 #include "include/stringify.h"
 
+using std::list;
+using std::map;
+using std::make_pair;
+using std::pair;
+using std::string;
+
+using ceph::bufferlist;
+using ceph::decode;
+using ceph::encode;
+using ceph::Formatter;
+
 // ----
 // LogEntryKey
 
@@ -372,4 +383,3 @@ void LogSummary::generate_test_instances(list<LogSummary*>& o)
   o.push_back(new LogSummary);
   // more!
 }
-
index 33b27e6da76bf69b4fb4b6879696c2686fbcffc6..2221de6462f37bac4b664cc5e4823e09bee9c75a 100644 (file)
@@ -255,7 +255,7 @@ bool OutputDataSocket::do_accept()
 
 void OutputDataSocket::handle_connection(int fd)
 {
-  bufferlist bl;
+  ceph::buffer::list bl;
 
   m_lock.lock();
   init_connection(bl);
@@ -294,13 +294,13 @@ void OutputDataSocket::handle_connection(int fd)
 int OutputDataSocket::dump_data(int fd)
 {
   m_lock.lock();
-  vector<buffer::list> l = std::move(data);
+  auto l = std::move(data);
   data.clear();
   data_size = 0;
   m_lock.unlock();
 
   for (auto iter = l.begin(); iter != l.end(); ++iter) {
-    bufferlist& bl = *iter;
+    ceph::buffer::list& bl = *iter;
     int ret = safe_write(fd, bl.c_str(), bl.length());
     if (ret >= 0) {
       ret = safe_write(fd, delim.c_str(), delim.length());
@@ -308,7 +308,7 @@ int OutputDataSocket::dump_data(int fd)
     if (ret < 0) {
       std::scoped_lock lock(m_lock);
       for (; iter != l.end(); ++iter) {
-        bufferlist& bl = *iter;
+        ceph::buffer::list& bl = *iter;
        data.push_back(bl);
        data_size += bl.length();
       }
@@ -384,7 +384,7 @@ void OutputDataSocket::shutdown()
   m_path.clear();
 }
 
-void OutputDataSocket::append_output(bufferlist& bl)
+void OutputDataSocket::append_output(ceph::buffer::list& bl)
 {
   std::lock_guard l(m_lock);
 
index 5a6bc4ff9fca81fbc51426cc82613f57a63abb26..397d93f16f85f186157b166a2c604b2176665f74 100644 (file)
@@ -29,10 +29,10 @@ public:
 
   bool init(const std::string &path);
   
-  void append_output(bufferlist& bl);
+  void append_output(ceph::buffer::list& bl);
 
 protected:
-  virtual void init_connection(bufferlist& bl) {}
+  virtual void init_connection(ceph::buffer::list& bl) {}
   void shutdown();
 
   std::string create_shutdown_pipe(int *pipe_rd, int *pipe_wr);
@@ -57,11 +57,11 @@ protected:
   uint64_t data_size;
   uint32_t skipped;
 
-  std::vector<buffer::list> data;
+  std::vector<ceph::buffer::list> data;
 
   ceph::mutex m_lock = ceph::make_mutex("OutputDataSocket::m_lock");
   ceph::condition_variable cond;
-  buffer::list delim;
+  ceph::buffer::list delim;
 };
 
 #endif
index 2cb7fcee8db2809dead618e7d10ffa319e4d90b4..c697aaa17f00628b38838847d3b6d1c91987f4d1 100644 (file)
 
 #define dout_subsys ceph_subsys_context
 
+using std::map;
+using std::string;
+
+namespace ceph {
+
 PluginRegistry::PluginRegistry(CephContext *cct) :
   cct(cct),
   loading(false),
@@ -211,6 +216,7 @@ int PluginRegistry::load(const std::string &type,
                << " loaded and registered" << dendl;
   return 0;
 }
+}
 
 /*
 int ErasureCodePluginRegistry::preload(const std::string &plugins,
index 2d2b35ff781f2d4f0f933054462f24b9be9da004..5ce820fedeee7062eb22264bf3f78cb9f3f6e05e 100644 (file)
@@ -4,6 +4,8 @@
 #include "common/Readahead.h"
 #include "common/Cond.h"
 
+using std::vector;
+
 Readahead::Readahead()
   : m_trigger_requests(10),
     m_readahead_min_bytes(0),
@@ -30,7 +32,7 @@ Readahead::extent_t Readahead::update(const vector<extent_t>& extents, uint64_t
     m_lock.unlock();
     return extent_t(0, 0);
   }
-  pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
+  std::pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
   m_lock.unlock();
   return extent;
 }
index 102a6399765d1c68ca78de35249c1f6d0b0d7004..ec9cbdf53a6a7d485649408cc75f1d815c719fdc 100644 (file)
@@ -5,6 +5,7 @@
 #include "common/Formatter.h"
 
 using namespace std;
+using ceph::bufferlist;
 
 void SloppyCRCMap::write(uint64_t offset, uint64_t len, const bufferlist& bl,
                         std::ostream *out)
index 0c2d646fa8c57583658aea1620bd0c834d95ad95..6bbfe978a4c0f9ad15f00e4abc61b3d3c90e5bcc 100644 (file)
@@ -33,7 +33,7 @@ public:
     block_size = b;
     //zero_crc = ceph_crc32c(0xffffffff, NULL, block_size);
     if (b) {
-      bufferlist bl;
+      ceph::buffer::list bl;
       bl.append_zero(block_size);
       zero_crc = bl.crc32c(crc_iv);
     } else {
@@ -42,7 +42,7 @@ public:
   }
 
   /// update based on a write
-  void write(uint64_t offset, uint64_t len, const bufferlist& bl,
+  void write(uint64_t offset, uint64_t len, const ceph::buffer::list& bl,
             std::ostream *out = NULL);
 
   /// update based on a truncate
@@ -64,10 +64,10 @@ public:
    * @param err option ostream to describe errors in detail
    * @returns error count, 0 for success
    */
-  int read(uint64_t offset, uint64_t len, const bufferlist& bl, std::ostream *err);
+  int read(uint64_t offset, uint64_t len, const ceph::buffer::list& bl, std::ostream *err);
 
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::const_iterator& bl);
+  void encode(ceph::buffer::list& bl) const;
+  void decode(ceph::buffer::list::const_iterator& bl);
   void dump(ceph::Formatter *f) const;
   static void generate_test_instances(std::list<SloppyCRCMap*>& ls);
 };
index 69d0f1086b0107c785c30d32c1916715a7757a32..e483e154c9eaabb1b9e25459c8e43c3d53756c42 100644 (file)
 #undef dout_prefix
 #define dout_prefix *_dout << "throttle(" << name << " " << (void*)this << ") "
 
+using std::list;
+using std::ostream;
+using std::string;
+
 using ceph::mono_clock;
 using ceph::mono_time;
+using ceph::timespan;
 
 enum {
   l_throttle_first = 532430,
index dceee9b0c0b199a514258a6ad37d5bcdf05fa198..39ad4531915826f3b1831eb3f0ef8c0fecf8b7a4 100644 (file)
@@ -20,7 +20,9 @@
 #undef dout_prefix
 #define dout_prefix *_dout << "timer(" << this << ")."
 
+using std::pair;
 
+using ceph::operator <<;
 
 class SafeTimerThread : public Thread {
   SafeTimer *parent;
index 494cfcdf686e5981b20090061beb0512a5022b5d..f1b35e7e57aa5080810778ecca6411176aa8b38b 100644 (file)
 #undef dout_prefix
 #define dout_prefix _prefix(_dout)
 
+using std::list;
+using std::make_pair;
+using std::ostream;
+using std::pair;
+using std::set;
+using std::string;
+using std::stringstream;
+
+using ceph::Formatter;
+
 static ostream& _prefix(std::ostream* _dout)
 {
   return *_dout << "-- op tracker -- ";
index 93b2aadd8a887f495650d6e34fac99923b3a6561..c1b8c18e0972995578d2c668718161f771a932ed 100644 (file)
@@ -20,8 +20,7 @@
 #undef dout_prefix
 #define dout_prefix *_dout << name << " "
 
-
-ThreadPool::ThreadPool(CephContext *cct_, string nm, string tn, int n, const char *option)
+ThreadPool::ThreadPool(CephContext *cct_, std::string nm, std::string tn, int n, const char *option)
   : cct(cct_), name(std::move(nm)), thread_name(std::move(tn)),
     lockname(name + "::lock"),
     _lock(ceph::make_mutex(lockname)),  // this should be safe due to declaration order
@@ -83,10 +82,10 @@ void ThreadPool::worker(WorkThread *wt)
 {
   std::unique_lock ul(_lock);
   ldout(cct,10) << "worker start" << dendl;
-  
+
   std::stringstream ss;
   ss << name << " thread " << (void *)pthread_self();
-  heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
+  auto hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
 
   while (!_stop) {
 
@@ -197,9 +196,7 @@ void ThreadPool::stop(bool clear_after)
   _cond.notify_all();
   join_old_threads();
   _lock.unlock();
-  for (set<WorkThread*>::iterator p = _threads.begin();
-       p != _threads.end();
-       ++p) {
+  for (auto p = _threads.begin(); p != _threads.end(); ++p) {
     (*p)->join();
     delete *p;
   }
@@ -252,8 +249,8 @@ void ThreadPool::drain(WorkQueue_* wq)
   _draining--;
 }
 
-ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, string tn,
-  uint32_t pnum_threads):
+ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, std::string nm, std::string tn,
+                                    uint32_t pnum_threads):
   cct(pcct_),
   name(std::move(nm)),
   thread_name(std::move(tn)),
@@ -271,7 +268,7 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index)
 
   std::stringstream ss;
   ss << name << " thread " << (void *)pthread_self();
-  heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
+  auto hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
 
   while (!stop_threads) {
     if (pause_threads) {
@@ -348,7 +345,7 @@ void ShardedThreadPool::stop()
   stop_threads = true;
   ceph_assert(wq != NULL);
   wq->return_waiting_threads();
-  for (vector<WorkThreadSharded*>::iterator p = threads_shardedpool.begin();
+  for (auto p = threads_shardedpool.begin();
        p != threads_shardedpool.end();
        ++p) {
     (*p)->join();
index cdb8591f17a760abc33d72a008da40d3ed57ba9a..29f99a8cd5e6283c29bcaa635e26676c7a3c425a 100644 (file)
@@ -19,8 +19,8 @@ int entity_addr_from_url(entity_addr_t *addr /* out */, const char *url)
        std::cmatch m;
 
        if (std::regex_match(url, m, expr)) {
-               string host(m[2].first, m[2].second);
-               string port(m[3].first, m[3].second);
+               std::string host(m[2].first, m[2].second);
+               std::string port(m[3].first, m[3].second);
                addrinfo hints;
                // FIPS zeroization audit 20191115: this memset is fine.
                memset(&hints, 0, sizeof(hints));
@@ -36,4 +36,3 @@ int entity_addr_from_url(entity_addr_t *addr /* out */, const char *url)
 
        return 1;
 }
-
index 1f57ca0832f1f637dd800cb8ea5c32d616892705..f7c042e5d14f2cdc4c603daeed088b4e41ec4039 100644 (file)
 #undef dout_prefix
 #define dout_prefix *_dout << "asok(" << (void*)m_cct << ") "
 
+using namespace std::literals;
 
 using std::ostringstream;
+using std::string;
+using std::stringstream;
+
 using namespace TOPNSPC::common;
 
+using ceph::bufferlist;
+using ceph::cref_t;
+using ceph::Formatter;
+
+
 /*
  * UNIX domain sockets created by an application persist even after that
  * application closes, unless they're explicitly unlinked. This is because the
@@ -490,7 +499,7 @@ void AdminSocket::execute_command(
                     empty);
   }
 
-  Formatter *f = Formatter::create(format, "json-pretty", "json-pretty");
+  auto f = Formatter::create(format, "json-pretty", "json-pretty");
 
   std::unique_lock l(lock);
   decltype(hooks)::iterator p;
@@ -651,7 +660,7 @@ public:
       // do what you'd expect. GCC 7 does not.
       (void)command;
       ostringstream secname;
-      secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
+      secname << "cmd" << std::setfill('0') << std::setw(3) << cmdnum;
       dump_cmd_and_help_to_json(f,
                                 CEPH_FEATURES_ALL,
                                secname.str().c_str(),
index 2105097bbeeb618fd52f13b9ccd84d31ffb1f2cf..429b69e00394c605f5a1c85c3ac97bf09573ec94 100644 (file)
 #include "common/ref.h"
 #include "common/cmdparse.h"
 
-class AdminSocket;
 class MCommand;
 class MMonCommand;
 
-using namespace std::literals;
-
-inline constexpr auto CEPH_ADMIN_SOCK_VERSION = "2"sv;
+inline constexpr auto CEPH_ADMIN_SOCK_VERSION = std::string_view("2");
 
 class AdminSocketHook {
 public:
@@ -63,7 +60,7 @@ public:
   virtual int call(
     std::string_view command,
     const cmdmap_t& cmdmap,
-    Formatter *f,
+    ceph::Formatter *f,
     std::ostream& errss,
     ceph::buffer::list& out) = 0;
 
@@ -93,11 +90,11 @@ public:
   virtual void call_async(
     std::string_view command,
     const cmdmap_t& cmdmap,
-    Formatter *f,
-    const bufferlist& inbl,
-    std::function<void(int,const std::string&,bufferlist&)> on_finish) {
+    ceph::Formatter *f,
+    const ceph::buffer::list& inbl,
+    std::function<void(int,const std::string&,ceph::buffer::list&)> on_finish) {
     // by default, call the synchronous handler and then finish
-    bufferlist out;
+    ceph::buffer::list out;
     std::ostringstream errss;
     int r = call(command, cmdmap, f, errss, out);
     on_finish(r, errss.str(), out);
@@ -152,18 +149,18 @@ public:
   /// execute (async)
   void execute_command(
     const std::vector<std::string>& cmd,
-    const bufferlist& inbl,
-    std::function<void(int,const std::string&,bufferlist&)> on_fin);
+    const ceph::buffer::list& inbl,
+    std::function<void(int,const std::string&,ceph::buffer::list&)> on_fin);
 
   /// execute (blocking)
   int execute_command(
     const std::vector<std::string>& cmd,
-    const bufferlist& inbl,
+    const ceph::buffer::list& inbl,
     std::ostream& errss,
-    bufferlist *outbl);
+    ceph::buffer::list *outbl);
 
-  void queue_tell_command(cref_t<MCommand> m);
-  void queue_tell_command(cref_t<MMonCommand> m); // for compat
+  void queue_tell_command(ceph::cref_t<MCommand> m);
+  void queue_tell_command(ceph::cref_t<MMonCommand> m); // for compat
 
 private:
 
@@ -194,8 +191,8 @@ private:
   std::unique_ptr<AdminSocketHook> getdescs_hook;
 
   std::mutex tell_lock;
-  std::list<cref_t<MCommand>> tell_queue;
-  std::list<cref_t<MMonCommand>> tell_legacy_queue;
+  std::list<ceph::cref_t<MCommand>> tell_queue;
+  std::list<ceph::cref_t<MMonCommand>> tell_legacy_queue;
 
   struct hook_info {
     AdminSocketHook* hook;
index 6fb50014f4399b93ce1c541379b7c5993116e7fe..a663c16e907d1395f4c3908dda9e88dcf282537b 100644 (file)
@@ -15,6 +15,8 @@
 #include "include/compat.h"
 #include "common/debug.h"
 
+using std::ostringstream;
+
 namespace ceph {
   static CephContext *g_assert_context = NULL;
 
@@ -156,7 +158,7 @@ namespace ceph {
   }
 
   [[gnu::cold]] void __ceph_abort(const char *file, int line,
-                                 const char *func, const string& msg)
+                                 const char *func, const std::string& msg)
   {
     ostringstream tss;
     tss << ceph_clock_now();
index 0260a69e470d2360572fc4e227ebed9862816f93..8c76a90b6bb8d82fdd9c0ca1de309d47f1722b77 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "json_spirit/json_spirit_reader.h"
 
+
 int get_device_by_path(const char *path, char* partition, char* device,
                       size_t max)
 {
@@ -77,6 +78,12 @@ int get_device_by_path(const char *path, char* partition, char* device,
 
 #endif
 
+using namespace std::literals;
+
+using std::string;
+
+using ceph::bufferlist;
+
 
 BlkDev::BlkDev(int f)
   : fd(f)
index 789e8ba685d38e2ece31a7063ca21e9bd3c1b2cf..9033f04544464b00720506b4f331ab5da51fc663 100644 (file)
@@ -5,6 +5,10 @@
 
 MEMPOOL_DEFINE_FACTORY(unsigned char, byte, bloom_filter);
 
+using ceph::bufferlist;
+using ceph::bufferptr;
+using ceph::Formatter;
+
 void bloom_filter::encode(bufferlist& bl) const
 {
   ENCODE_START(2, 2, bl);
index 3204db6e6362814dd712517f963eddb5ca9556c6..4e276743b57d43b609ac56740eca4c45d23ace26 100644 (file)
 #include "include/spinlock.h"
 #include "include/scope_guard.h"
 
+using std::cerr;
+using std::make_pair;
+using std::pair;
+using std::string;
+
 using namespace ceph;
 
 #define CEPH_BUFFER_ALLOC_UNIT  4096u
index 631bc7c54704368f57df510ce40021156e737429..85705982c164c7007be6ad1ab85bed275dd1c134 100644 (file)
@@ -55,9 +55,9 @@ struct strict_str_convert {
 
 void string_to_vec(std::vector<std::string>& args, std::string argstr)
 {
-  istringstream iss(argstr);
+  std::istringstream iss(argstr);
   while(iss) {
-    string sub;
+    std::string sub;
     iss >> sub;
     if (sub == "") break;
     args.push_back(sub);
@@ -79,7 +79,7 @@ split_dashdash(const std::vector<const char*>& args) {
 }
 
 static std::mutex g_str_vec_lock;
-static vector<string> g_str_vec;
+static std::vector<std::string> g_str_vec;
 
 void clear_g_str_vec()
 {
@@ -138,7 +138,7 @@ void vec_to_argv(const char *argv0, std::vector<const char*>& args,
 {
   *argv = (const char**)malloc(sizeof(char*) * (args.size() + 1));
   if (!*argv)
-    throw bad_alloc();
+    throw std::bad_alloc();
   *argc = 1;
   (*argv)[0] = argv0;
 
@@ -191,10 +191,10 @@ void ceph_arg_value_type(const char * nextargstr, bool *bool_option, bool *bool_
 }
 
 
-bool parse_ip_port_vec(const char *s, vector<entity_addrvec_t>& vec, int type)
+bool parse_ip_port_vec(const char *s, std::vector<entity_addrvec_t>& vec, int type)
 {
   // first split by [ ;], which are not valid for an addrvec
-  list<string> items;
+  std::list<std::string> items;
   get_str_list(s, " ;", items);
 
   for (auto& i : items) {
@@ -480,7 +480,7 @@ bool ceph_argparse_witharg(std::vector<const char*> &args,
   int r;
   va_list ap;
   va_start(ap, ret);
-  r = va_ceph_argparse_witharg(args, i, ret, cerr, ap);
+  r = va_ceph_argparse_witharg(args, i, ret, std::cerr, ap);
   va_end(ap);
   if (r < 0)
     _exit(1);
@@ -494,7 +494,7 @@ CephInitParameters ceph_argparse_early_args
   CephInitParameters iparams(module_type);
   std::string val;
 
-  vector<const char *> orig_args = args;
+  auto orig_args = args;
 
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (strcmp(*i, "--") == 0) {
@@ -504,7 +504,7 @@ CephInitParameters ceph_argparse_early_args
       break;
     }
     else if (ceph_argparse_flag(args, i, "--version", "-v", (char*)NULL)) {
-      cout << pretty_version_to_str() << std::endl;
+      std::cout << pretty_version_to_str() << std::endl;
       _exit(0);
     }
     else if (ceph_argparse_witharg(args, i, &val, "--conf", "-c", (char*)NULL)) {
@@ -525,20 +525,20 @@ CephInitParameters ceph_argparse_early_args
     }
     else if (ceph_argparse_witharg(args, i, &val, "--name", "-n", (char*)NULL)) {
       if (!iparams.name.from_str(val)) {
-       cerr << "error parsing '" << val << "': expected string of the form TYPE.ID, "
-            << "valid types are: " << EntityName::get_valid_types_as_str()
-            << std::endl;
+       std::cerr << "error parsing '" << val << "': expected string of the form TYPE.ID, "
+                 << "valid types are: " << EntityName::get_valid_types_as_str()
+                 << std::endl;
        _exit(1);
       }
     }
     else if (ceph_argparse_flag(args, i, "--show_args", (char*)NULL)) {
-      cout << "args: ";
+      std::cout << "args: ";
       for (std::vector<const char *>::iterator ci = orig_args.begin(); ci != orig_args.end(); ++ci) {
-        if (ci != orig_args.begin())
-          cout << " ";
-        cout << *ci;
+       if (ci != orig_args.begin())
+         std::cout << " ";
+       std::cout << *ci;
       }
-      cout << std::endl;
+      std::cout << std::endl;
     }
     else {
       // ignore
@@ -550,7 +550,7 @@ CephInitParameters ceph_argparse_early_args
 
 static void generic_usage(bool is_server)
 {
-  cout <<
+  std::cout <<
     "  --conf/-c FILE    read configuration from the given configuration file" << std::endl <<
     (is_server ?
     "  --id/-i ID        set ID portion of my name" :
@@ -563,14 +563,14 @@ static void generic_usage(bool is_server)
     << std::endl;
 
   if (is_server) {
-    cout <<
+    std::cout <<
       "  -d                run in foreground, log to stderr" << std::endl <<
       "  -f                run in foreground, log to usual location" << std::endl <<
       std::endl <<
       "  --debug_ms N      set message debug level (e.g. 1)" << std::endl;
   }
 
-  cout.flush();
+  std::cout.flush();
 }
 
 bool ceph_argparse_need_usage(const std::vector<const char*>& args)
index e7116e38875cd91e19e2791df8e0b2cd75b506e3..d4248d9e9b1d9d288547a72f7710013dc91b4c7f 100644 (file)
 #include "common/valgrind.h"
 #include "include/spinlock.h"
 
-using ceph::bufferlist;
-using ceph::HeartbeatMap;
-
 // for CINIT_FLAGS
 #include "common/common_init.h"
 
 #include <iostream>
 #include <pthread.h>
 
+using namespace std::literals;
+
+using ceph::bufferlist;
+using ceph::HeartbeatMap;
+
+
 #if defined(WITH_SEASTAR) && !defined(WITH_ALIEN)
 namespace crimson::common {
 CephContext::CephContext()
@@ -171,7 +174,7 @@ public:
 
   // AdminSocketHook
   int call(std::string_view command, const cmdmap_t& cmdmap,
-          Formatter *f,
+          ceph::Formatter *f,
           std::ostream& errss,
           bufferlist& out) override {
     if (command == "dump_mempools") {
@@ -316,7 +319,7 @@ public:
     }
 
     if (changed.count("log_stderr_prefix")) {
-      log->set_log_stderr_prefix(conf.get_val<string>("log_stderr_prefix"));
+      log->set_log_stderr_prefix(conf.get_val<std::string>("log_stderr_prefix"));
     }
 
     if (changed.count("log_max_new")) {
@@ -426,7 +429,7 @@ public:
 
 bool CephContext::check_experimental_feature_enabled(const std::string& feat)
 {
-  stringstream message;
+  std::stringstream message;
   bool enabled = check_experimental_feature_enabled(feat, &message);
   lderr(this) << message.str() << dendl;
   return enabled;
@@ -562,13 +565,13 @@ int CephContext::_do_command(
        r = -EINVAL;
       } else {
        // val may be multiple words
-       string valstr = str_join(val, " ");
+       auto valstr = str_join(val, " ");
         r = _conf.set_val(var.c_str(), valstr.c_str());
         if (r < 0) {
           ss << "error setting '" << var << "' to '" << valstr << "': "
             << cpp_strerror(r);
         } else {
-         stringstream ss;
+         std::stringstream ss;
           _conf.apply_changes(&ss);
          f->dump_string("success", ss.str());
         }
@@ -620,12 +623,10 @@ int CephContext::_do_command(
       f->close_section(); // unknown
     }
     else if (command == "injectargs") {
-      vector<string> argsvec;
+      std::vector<std::string> argsvec;
       cmd_getval(cmdmap, "injected_args", argsvec);
       if (!argsvec.empty()) {
-       string args = joinify<std::string>(argsvec.begin(),
-                                          argsvec.end(),
-                                          " ");
+       auto args = joinify<std::string>(argsvec.begin(), argsvec.end(), " ");
        r = _conf.injectargs(args, &ss);
       }
     }
@@ -890,13 +891,13 @@ void CephContext::_enable_perf_counter()
   _mempool_perf_names.reserve(mempool::num_pools * 2);
   _mempool_perf_descriptions.reserve(mempool::num_pools * 2);
   for (unsigned i = 0; i < mempool::num_pools; ++i) {
-    string n = mempool::get_pool_name(mempool::pool_index_t(i));
-    _mempool_perf_names.push_back(n + "_bytes");
+    std::string n = mempool::get_pool_name(mempool::pool_index_t(i));
+    _mempool_perf_names.push_back(n + "_bytes"s);
     _mempool_perf_descriptions.push_back(
-      string("mempool ") + n + " total bytes");
-    _mempool_perf_names.push_back(n + "_items");
+      "mempool "s + n + " total bytes");
+    _mempool_perf_names.push_back(n + "_items"s);
     _mempool_perf_descriptions.push_back(
-      string("mempool ") + n + " total items");
+      "mempool "s + n + " total items"s);
   }
 
   PerfCountersBuilder plb2(this, "mempool", l_mempool_first,
index 8b79a969fa9663ffa0c6ac2ec210530c490dc6b4..50906a42e6d9d05978c4722f27bf02b7e34d1adc 100644 (file)
 
 using namespace json_spirit;
 
-#define dout_subsys ceph_subsys_rgw
+using std::ifstream;
+using std::pair;
+using std::ostream;
+using std::string;
+using std::vector;
 
+using ceph::bufferlist;
+using ceph::Formatter;
 
-static JSONFormattable default_formattable;
+#define dout_subsys ceph_subsys_rgw
 
+static JSONFormattable default_formattable;
 
 void encode_json(const char *name, const JSONObj::data_val& v, Formatter *f)
 {
@@ -61,8 +68,7 @@ ostream& operator<<(ostream &out, const JSONObj &obj) {
 
 JSONObj::~JSONObj()
 {
-  multimap<string, JSONObj *>::iterator iter;
-  for (iter = children.begin(); iter != children.end(); ++iter) {
+  for (auto iter = children.begin(); iter != children.end(); ++iter) {
     JSONObj *obj = iter->second;
     delete obj;
   }
@@ -86,11 +92,9 @@ bool JSONObj::get_attr(string name, data_val& attr)
 JSONObjIter JSONObj::find(const string& name)
 {
   JSONObjIter iter;
-  map<string, JSONObj *>::iterator first;
-  map<string, JSONObj *>::iterator last;
-  first = children.find(name);
+  auto first = children.find(name);
   if (first != children.end()) {
-    last = children.upper_bound(name);
+    auto last = children.upper_bound(name);
     iter.set(first, last);
   }
   return iter;
@@ -106,8 +110,7 @@ JSONObjIter JSONObj::find_first()
 JSONObjIter JSONObj::find_first(const string& name)
 {
   JSONObjIter iter;
-  map<string, JSONObj *>::iterator first;
-  first = children.find(name);
+  auto first = children.find(name);
   iter.set(first, children.end());
   return iter;
 }
@@ -457,7 +460,7 @@ void decode_json_obj(bufferlist& val, JSONObj *obj)
   bl.append(s.c_str(), s.size());
   try {
     val.decode_base64(bl);
-  } catch (buffer::error& err) {
+  } catch (ceph::buffer::error& err) {
    throw JSONDecoder::err("failed to decode base64");
   }
 }
index bb708bb4675646d467ff0fe4ab5033997c63901f..1d3b0e1d6b7448412d29d249e4e438acadea152b 100644 (file)
@@ -52,6 +52,8 @@ int clock_gettime(int clk_id, struct timespec *tp)
 }
 #endif
 
+using namespace std::literals;
+
 namespace ceph {
   namespace time_detail {
     void real_clock::to_ceph_timespec(const time_point& t,
@@ -155,7 +157,7 @@ namespace ceph {
     // FIXME: somebody pretty please make a version of this function
     // that isn't as lame as this one!
     uint64_t nsec = std::chrono::nanoseconds(t).count();
-    ostringstream ss;
+    std::ostringstream ss;
     if (nsec < 2000000000) {
       ss << ((float)nsec / 1000000000) << "s";
       return ss.str();
@@ -201,7 +203,7 @@ namespace ceph {
     uint64_t sec = nsec / 1000000000;
     nsec %= 1000000000;
     uint64_t yr = sec / (60 * 60 * 24 * 365);
-    ostringstream ss;
+    std::ostringstream ss;
     if (yr) {
       ss << yr << "y";
       sec -= yr * (60 * 60 * 24 * 365);
@@ -245,7 +247,7 @@ namespace ceph {
 
   std::chrono::seconds parse_timespan(const std::string& s)
   {
-    static std::map<string,int> units = {
+    static std::map<std::string,int> units = {
       { "s", 1 },
       { "sec", 1 },
       { "second", 1 },
@@ -291,13 +293,13 @@ namespace ceph {
        ++pos;
       }
       if (val_start == pos) {
-       throw invalid_argument("expected digit");
+       throw std::invalid_argument("expected digit");
       }
-      string n = s.substr(val_start, pos - val_start);
-      string err;
+      auto n = s.substr(val_start, pos - val_start);
+      std::string err;
       auto val = strict_strtoll(n.c_str(), 10, &err);
       if (err.size()) {
-       throw invalid_argument(err);
+       throw std::invalid_argument(err);
       }
 
       // skip whitespace
@@ -311,16 +313,16 @@ namespace ceph {
        ++pos;
       }
       if (unit_start != pos) {
-       string unit = s.substr(unit_start, pos - unit_start);
+       auto unit = s.substr(unit_start, pos - unit_start);
        auto p = units.find(unit);
        if (p == units.end()) {
-         throw invalid_argument("unrecogized unit '"s + unit + "'");
+         throw std::invalid_argument("unrecogized unit '"s + unit + "'");
        }
        val *= p->second;
       } else if (pos < s.size()) {
-       throw invalid_argument("unexpected trailing '"s + s.substr(pos) + "'");
+       throw std::invalid_argument("unexpected trailing '"s + s.substr(pos) + "'");
       }
-      r += chrono::seconds(val);
+      r += std::chrono::seconds(val);
     }
     return r;
   }
index a19041845e1fe352dc7a572be01c762ea8bc4581..6dbbb3925dd2b45d2e1bcf1e20839897651da685 100644 (file)
 #include "common/strtol.h"
 #include "json_spirit/json_spirit.h"
 
+using std::is_same_v;
+using std::ostringstream;
+using std::string;
+using std::stringstream;
+using std::string_view;
+using std::vector;
+
 /**
  * Given a cmddesc like "foo baz name=bar,type=CephString",
  * return the prefix "foo baz".
@@ -293,15 +300,14 @@ cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
 
   try {
     if (!json_spirit::read(fullcmd, v))
-      throw runtime_error("unparseable JSON " + fullcmd);
+      throw std::runtime_error("unparseable JSON " + fullcmd);
     if (v.type() != json_spirit::obj_type)
-      throw(runtime_error("not JSON object " + fullcmd));
+      throw std::runtime_error("not JSON object " + fullcmd);
 
     // allocate new mObject (map) to return
     // make sure all contents are simple types (not arrays or objects)
     json_spirit::mObject o = v.get_obj();
-    for (map<string, json_spirit::mValue>::iterator it = o.begin();
-        it != o.end(); ++it) {
+    for (auto it = o.begin(); it != o.end(); ++it) {
 
       // ok, marshal it into our string->cmd_vartype map, or throw an
       // exception if it's not a simple datatype.  This is kind of
@@ -312,7 +318,7 @@ cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
 
       case json_spirit::obj_type:
       default:
-       throw(runtime_error("JSON array/object not allowed " + fullcmd));
+       throw std::runtime_error("JSON array/object not allowed " + fullcmd);
         break;
 
       case json_spirit::array_type:
@@ -329,7 +335,7 @@ cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
            vector<string> outv;
            for (const auto& sv : spvals) {
              if (sv.type() != json_spirit::str_type) {
-               throw(runtime_error("Can't handle arrays of multiple types"));
+               throw std::runtime_error("Can't handle arrays of multiple types");
              }
              outv.push_back(sv.get_str());
            }
@@ -338,7 +344,7 @@ cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
            vector<int64_t> outv;
            for (const auto& sv : spvals) {
              if (spvals.front().type() != json_spirit::int_type) {
-               throw(runtime_error("Can't handle arrays of multiple types"));
+               throw std::runtime_error("Can't handle arrays of multiple types");
              }
              outv.push_back(sv.get_int64());
            }
@@ -347,14 +353,14 @@ cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
            vector<double> outv;
            for (const auto& sv : spvals) {
              if (spvals.front().type() != json_spirit::real_type) {
-               throw(runtime_error("Can't handle arrays of multiple types"));
+               throw std::runtime_error("Can't handle arrays of multiple types");
              }
              outv.push_back(sv.get_real());
            }
            (*mapp)[it->first] = std::move(outv);
          } else {
-           throw(runtime_error("Can't handle arrays of types other than "
-                               "int, string, or double"));
+           throw std::runtime_error("Can't handle arrays of types other than "
+                                    "int, string, or double");
          }
        }
        break;
@@ -376,7 +382,7 @@ cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
       }
     }
     return true;
-  } catch (runtime_error &e) {
+  } catch (const std::runtime_error &e) {
     ss << e.what();
     return false;
   }
@@ -502,7 +508,7 @@ bool arg_in_range(T value, const arg_desc_t& desc, std::ostream& os) {
   }
   auto min_max = get_str_list(string(range->second), "|");
   auto min = str_to_num<T>(min_max.front());
-  auto max = numeric_limits<T>::max();
+  auto max = std::numeric_limits<T>::max();
   if (min_max.size() > 1) {
     max = str_to_num<T>(min_max.back());
   }
@@ -546,9 +552,9 @@ bool validate_str_arg(std::string_view value,
 
 template<bool is_vector,
         typename T,
-        typename Value = conditional_t<is_vector,
-                                       vector<T>,
-                                       T>>
+        typename Value = std::conditional_t<is_vector,
+                                            vector<T>,
+                                            T>>
 bool validate_arg(CephContext* cct,
                  const cmdmap_t& cmdmap,
                  const arg_desc_t& desc,
index 2ad93a958c488a18ba306c312deb524d18c98403..6e6a7ecf8100eec9b4df7ffeafbf5fcaf08095c3 100644 (file)
@@ -71,7 +71,7 @@ CephContext *common_preinit(const CephInitParameters &iparams,
 #endif // #ifndef WITH_SEASTAR
 
 void complain_about_parse_error(CephContext *cct,
-                               const string& parse_error)
+                               const std::string& parse_error)
 {
   if (parse_error.empty())
     return;
index eb6b721e12e39f4c57437104be1fe30d6d073ded..792cf5fa68cb4d6059a2efe262ea340c22abe745 100644 (file)
 // set set_mon_vals()
 #define dout_subsys ceph_subsys_monc
 
+using std::cerr;
+using std::cout;
 using std::map;
+using std::less;
 using std::list;
+using std::ostream;
 using std::ostringstream;
 using std::pair;
 using std::string;
+using std::string_view;
+using std::vector;
+
+using ceph::bufferlist;
+using ceph::decode;
+using ceph::encode;
+using ceph::Formatter;
 
 static const char *CEPH_CONF_FILE_DEFAULT = "$data_dir/config, /etc/ceph/$cluster.conf, $home/.ceph/$cluster.conf, $cluster.conf"
 #if defined(__FreeBSD__)
index 5b74ea065b495626255b39d8b0b558981de4709e..a44510d6deab31b520b1222b4f2d021346686838 100644 (file)
@@ -20,6 +20,8 @@
 
 #define dout_subsys ceph_subsys_
 
+using std::map;
+using std::string;
 
 namespace ceph {
 
@@ -52,8 +54,7 @@ int ResolvHWrapper::res_search(const char *hostname, int cls,
 DNSResolver::~DNSResolver()
 {
 #ifdef HAVE_RES_NQUERY
-  list<res_state>::iterator iter;
-  for (iter = states.begin(); iter != states.end(); ++iter) {
+  for (auto iter = states.begin(); iter != states.end(); ++iter) {
     struct __res_state *s = *iter;
     delete s;
   }
index feb9167264fb83bde2d4bd61b4496dc19d6eae2b..0dd5528eaa2e68c9e4fea3e3ba2b1737c9faeda6 100644 (file)
@@ -1,9 +1,11 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
 
 #include "include/fs_types.h"
 #include "common/Formatter.h"
 #include "include/ceph_features.h"
 
-void dump(const ceph_file_layout& l, Formatter *f)
+void dump(const ceph_file_layout& l, ceph::Formatter *f)
 {
   f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
   f->dump_unsigned("stripe_count", l.fl_stripe_count);
@@ -16,7 +18,7 @@ void dump(const ceph_file_layout& l, Formatter *f)
     f->dump_unsigned("pg_pool", l.fl_pg_pool);
 }
 
-void dump(const ceph_dir_layout& l, Formatter *f)
+void dump(const ceph_dir_layout& l, ceph::Formatter *f)
 {
   f->dump_unsigned("dir_hash", l.dl_dir_hash);
   f->dump_unsigned("unused1", l.dl_unused1);
@@ -71,7 +73,7 @@ void file_layout_t::to_legacy(ceph_file_layout *fl) const
     fl->fl_pg_pool = 0;
 }
 
-void file_layout_t::encode(bufferlist& bl, uint64_t features) const
+void file_layout_t::encode(ceph::buffer::list& bl, uint64_t features) const
 {
   using ceph::encode;
   if ((features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) == 0) {
@@ -91,7 +93,7 @@ void file_layout_t::encode(bufferlist& bl, uint64_t features) const
   ENCODE_FINISH(bl);
 }
 
-void file_layout_t::decode(bufferlist::const_iterator& p)
+void file_layout_t::decode(ceph::buffer::list::const_iterator& p)
 {
   using ceph::decode;
   if (*p == 0) {
@@ -109,7 +111,7 @@ void file_layout_t::decode(bufferlist::const_iterator& p)
   DECODE_FINISH(p);
 }
 
-void file_layout_t::dump(Formatter *f) const
+void file_layout_t::dump(ceph::Formatter *f) const
 {
   f->dump_unsigned("stripe_unit", stripe_unit);
   f->dump_unsigned("stripe_count", stripe_count);
@@ -118,7 +120,7 @@ void file_layout_t::dump(Formatter *f) const
   f->dump_string("pool_ns", pool_ns);
 }
 
-void file_layout_t::generate_test_instances(list<file_layout_t*>& o)
+void file_layout_t::generate_test_instances(std::list<file_layout_t*>& o)
 {
   o.push_back(new file_layout_t);
   o.push_back(new file_layout_t);
@@ -129,11 +131,10 @@ void file_layout_t::generate_test_instances(list<file_layout_t*>& o)
   o.back()->pool_ns = "myns";
 }
 
-ostream& operator<<(ostream& out, const file_layout_t &layout)
+std::ostream& operator<<(std::ostream& out, const file_layout_t &layout)
 {
-  JSONFormatter f;
+  ceph::JSONFormatter f;
   layout.dump(&f);
   f.flush(out);
   return out;
 }
-
index b8a71b67e1a3813d2335c00f40c1cc0e6f056b0b..62a7f44926bdcc453cfe7acf73503fd9f61bea0a 100644 (file)
@@ -16,7 +16,7 @@
 #include "common/Formatter.h"
 
 // -- pow2_hist_t --
-void pow2_hist_t::dump(Formatter *f) const
+void pow2_hist_t::dump(ceph::Formatter *f) const
 {
   f->open_array_section("histogram");
   for (std::vector<int32_t>::const_iterator p = h.begin(); p != h.end(); ++p)
@@ -25,14 +25,14 @@ void pow2_hist_t::dump(Formatter *f) const
   f->dump_int("upper_bound", upper_bound());
 }
 
-void pow2_hist_t::encode(bufferlist& bl) const
+void pow2_hist_t::encode(ceph::buffer::list& bl) const
 {
   ENCODE_START(1, 1, bl);
   encode(h, bl);
   ENCODE_FINISH(bl);
 }
 
-void pow2_hist_t::decode(bufferlist::const_iterator& p)
+void pow2_hist_t::decode(ceph::buffer::list::const_iterator& p)
 {
   DECODE_START(1, p);
   decode(h, p);
index e5da4a35d86b0855eba5e4f7da20ddfb36976075..85d4237dcd58cc49f151ef056cb2e1d2d0c1c829 100644 (file)
@@ -4,6 +4,14 @@
 #include "hobject.h"
 #include "common/Formatter.h"
 
+using std::list;
+using std::ostream;
+using std::set;
+using std::string;
+
+using ceph::bufferlist;
+using ceph::Formatter;
+
 static void append_escaped(const string &in, string *out)
 {
   for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
index a899df697856abeead56a81454425a1708549acd..d166dc8b41205dc8e76ec9fd71b7125eb88428f9 100644 (file)
@@ -1,3 +1,5 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
 
 #include <arpa/inet.h>
 #include <ifaddrs.h>
@@ -14,6 +16,8 @@
 #include "msg/msg_types.h"
 #include "common/pick_address.h"
 
+using std::string;
+
 void netmask_ipv4(const struct in_addr *addr,
                         unsigned int prefix_len,
                         struct in_addr *out) {
index cd87adce325b00c727a55fa274df55e561d51266..c62332c0cfc20600f6dd68d5d2f2cd037127e975 100644 (file)
@@ -29,16 +29,18 @@ struct lockdep_stopper_t {
     g_lockdep = 0;
   }
 };
+
+
 static pthread_mutex_t lockdep_mutex = PTHREAD_MUTEX_INITIALIZER;
 static CephContext *g_lockdep_ceph_ctx = NULL;
 static lockdep_stopper_t lockdep_stopper;
 static ceph::unordered_map<std::string, int> lock_ids;
-static map<int, std::string> lock_names;
-static map<int, int> lock_refs;
+static std::map<int, std::string> lock_names;
+static std::map<int, int> lock_refs;
 static char free_ids[MAX_LOCKS/8]; // bit set = free
-static ceph::unordered_map<pthread_t, map<int,BackTrace*> > held;
+static ceph::unordered_map<pthread_t, std::map<int,ceph::BackTrace*> > held;
 static char follows[MAX_LOCKS][MAX_LOCKS/8]; // follows[a][b] means b taken after a
-static BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS];
+static ceph::BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS];
 unsigned current_maxid;
 int last_freed_id = -1;
 static bool free_ids_inited;
@@ -93,7 +95,7 @@ void lockdep_unregister_ceph_context(CephContext *cct)
     lock_ids.clear();
     // FIPS zeroization audit 20191115: these memsets are not security related.
     memset((void*)&follows[0][0], 0, current_maxid * MAX_LOCKS/8);
-    memset((void*)&follows_bt[0][0], 0, sizeof(BackTrace*) * current_maxid * MAX_LOCKS);
+    memset((void*)&follows_bt[0][0], 0, sizeof(ceph::BackTrace*) * current_maxid * MAX_LOCKS);
   }
   pthread_mutex_unlock(&lockdep_mutex);
 }
@@ -104,11 +106,9 @@ int lockdep_dump_locks()
   if (!g_lockdep)
     goto out;
 
-  for (ceph::unordered_map<pthread_t, map<int,BackTrace*> >::iterator p = held.begin();
-       p != held.end();
-       ++p) {
+  for (auto p = held.begin(); p != held.end(); ++p) {
     lockdep_dout(0) << "--- thread " << p->first << " ---" << dendl;
-    for (map<int,BackTrace*>::iterator q = p->second.begin();
+    for (auto q = p->second.begin();
         q != p->second.end();
         ++q) {
       lockdep_dout(0) << "  * " << lock_names[q->first] << "\n";
@@ -205,7 +205,7 @@ void lockdep_unregister(int id)
   pthread_mutex_lock(&lockdep_mutex);
 
   std::string name;
-  map<int, std::string>::iterator p = lock_names.find(id);
+  auto p = lock_names.find(id);
   if (p == lock_names.end())
     name = "unknown" ;
   else
@@ -289,15 +289,13 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace,
   lockdep_dout(20) << "_will_lock " << name << " (" << id << ")" << dendl;
 
   // check dependency graph
-  map<int, BackTrace *> &m = held[p];
-  for (map<int, BackTrace *>::iterator p = m.begin();
-       p != m.end();
-       ++p) {
+  auto& m = held[p];
+  for (auto p = m.begin(); p != m.end(); ++p) {
     if (p->first == id) {
       if (!recursive) {
        lockdep_dout(0) << "\n";
        *_dout << "recursive lock of " << name << " (" << id << ")\n";
-       BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
+       auto bt = new ceph::BackTrace(BACKTRACE_SKIP);
        bt->print(*_dout);
        if (p->second) {
          *_dout << "\npreviously locked at\n";
@@ -313,7 +311,7 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace,
 
       // did we just create a cycle?
       if (does_follow(id, p->first)) {
-        BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
+        auto bt = new ceph::BackTrace(BACKTRACE_SKIP);
        lockdep_dout(0) << "new dependency " << lock_names[p->first]
                << " (" << p->first << ") -> " << name << " (" << id << ")"
                << " creates a cycle at\n";
@@ -321,9 +319,7 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace,
        *_dout << dendl;
 
        lockdep_dout(0) << "btw, i am holding these locks:" << dendl;
-       for (map<int, BackTrace *>::iterator q = m.begin();
-            q != m.end();
-            ++q) {
+       for (auto q = m.begin(); q != m.end(); ++q) {
          lockdep_dout(0) << "  " << lock_names[q->first] << " (" << q->first << ")" << dendl;
          if (q->second) {
            lockdep_dout(0) << " ";
@@ -339,9 +335,9 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace,
 
        ceph_abort();  // actually, we should just die here.
       } else {
-        BackTrace *bt = NULL;
+       ceph::BackTrace* bt = NULL;
         if (force_backtrace || lockdep_force_backtrace()) {
-          bt = new BackTrace(BACKTRACE_SKIP);
+          bt = new ceph::BackTrace(BACKTRACE_SKIP);
         }
         follows[p->first][id/8] |= 1 << (id % 8);
         follows_bt[p->first][id] = bt;
@@ -366,7 +362,7 @@ int lockdep_locked(const char *name, int id, bool force_backtrace)
 
   lockdep_dout(20) << "_locked " << name << dendl;
   if (force_backtrace || lockdep_force_backtrace())
-    held[p][id] = new BackTrace(BACKTRACE_SKIP);
+    held[p][id] = new ceph::BackTrace(BACKTRACE_SKIP);
   else
     held[p][id] = 0;
 out:
index dc80d0f33bde85aefad01c78a50fdd2c57b4bdf6..89368bd4005f317c54ee8a8f0e0588e9cdf5f673 100644 (file)
 #include "include/stringify.h"
 #include "common/safe_io.h"
 
+using namespace std::literals;
+
+using std::set;
+
 
 // list
 #if defined(__linux__)
index 449e5ea585c456866be03a5a8defcfc6457e5e80..581f9da0e284bd6b9c0c71514a5418022c4e6238 100644 (file)
 // rbd feature validation
 #include "librbd/Features.h"
 
+using std::ostream;
+using std::ostringstream;
+
+using ceph::Formatter;
+using ceph::parse_timespan;
+
 namespace {
 class printer : public boost::static_visitor<> {
   ostream& out;
@@ -198,7 +204,7 @@ int Option::parse_value(
   } else if (type == Option::TYPE_SECS) {
     try {
       *out = parse_timespan(val);
-    } catch (const invalid_argument& e) {
+    } catch (const std::invalid_argument& e) {
       *error_message = e.what();
       return -EINVAL;
     }
index 80c96413eb16b998ea69dd56c7c543270197cecc..420ff928c06cad1ed37c029a2c343a1ebe26e65b 100644 (file)
@@ -19,6 +19,8 @@
 #include "include/common_fwd.h"
 
 using std::ostringstream;
+using std::make_pair;
+using std::pair;
 
 namespace TOPNSPC::common {
 PerfCountersCollectionImpl::PerfCountersCollectionImpl()
@@ -544,13 +546,13 @@ void PerfCountersBuilder::add_u64_counter_histogram(
 {
   add_impl(idx, name, description, nick, prio,
           PERFCOUNTER_U64 | PERFCOUNTER_HISTOGRAM | PERFCOUNTER_COUNTER, unit,
-           unique_ptr<PerfHistogram<>>{new PerfHistogram<>{x_axis_config, y_axis_config}});
+           std::unique_ptr<PerfHistogram<>>{new PerfHistogram<>{x_axis_config, y_axis_config}});
 }
 
 void PerfCountersBuilder::add_impl(
   int idx, const char *name,
   const char *description, const char *nick, int prio, int ty, int unit,
-  unique_ptr<PerfHistogram<>> histogram)
+  std::unique_ptr<PerfHistogram<>> histogram)
 {
   ceph_assert(idx > m_perf_counters->m_lower_bound);
   ceph_assert(idx < m_perf_counters->m_upper_bound);
index ec464c1b8e165119c20e8c227525456c2d2f125b..a2b72371eec2a5ec039bfddc5eda7dda9279adf8 100644 (file)
@@ -34,6 +34,9 @@
 
 #define dout_subsys ceph_subsys_
 
+using std::string;
+using std::vector;
+
 const struct sockaddr *find_ip_in_subnet_list(
   CephContext *cct,
   const struct ifaddrs *ifa,
@@ -465,7 +468,7 @@ std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network)
     return {};
   }
 
-  const unsigned int prefix_len = max(sizeof(in_addr::s_addr), sizeof(in6_addr::s6_addr)) * CHAR_BIT;
+  const unsigned int prefix_len = std::max(sizeof(in_addr::s_addr), sizeof(in6_addr::s6_addr)) * CHAR_BIT;
   const struct ifaddrs *found = find_ip_in_subnet(
     ifa,
     (const struct sockaddr *) &network, prefix_len);
@@ -481,7 +484,7 @@ std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network)
 }
 
 
-bool have_local_addr(CephContext *cct, const list<entity_addr_t>& ls, entity_addr_t *match)
+bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match)
 {
   struct ifaddrs *ifa;
   int r = getifaddrs(&ifa);
@@ -518,7 +521,7 @@ int get_iface_numa_node(
     PHY_PORT,
     BOND_PORT
   } ifatype = iface_t::PHY_PORT;
-  string_view ifa{iface};
+  std::string_view ifa{iface};
   if (auto pos = ifa.find(":"); pos != ifa.npos) {
     ifa.remove_suffix(ifa.size() - pos);
   }
index 794627a09aa76ebc37a6f660e5f4713bc61b8cf4..658ab37243877d5361184025a831b49bec2d7b20 100644 (file)
@@ -1,9 +1,10 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
+#include <cstring>
+
 #include "include/types.h"
 #include "rabin.h"
-#include <string.h>
 
 
 uint64_t RabinChunk::gen_rabin_hash(char* chunk_data, uint64_t off, uint64_t len) {
@@ -35,8 +36,8 @@ bool RabinChunk::end_of_chunk(const uint64_t fp , int numbits) {
  *   output_chunks split by Rabin
  */
 
-int RabinChunk::do_rabin_chunks(bufferlist & inputdata, 
-                               vector<pair<uint64_t, uint64_t>> & chunks, 
+int RabinChunk::do_rabin_chunks(ceph::buffer::list& inputdata,
+                               std::vector<std::pair<uint64_t, uint64_t>>& chunks,
                                uint64_t min_val = 0, uint64_t max_val = 0)
 {
   char *ptr = inputdata.c_str();
@@ -56,7 +57,7 @@ int RabinChunk::do_rabin_chunks(bufferlist & inputdata,
   }
 
   if (data_size < min) {
-    chunks.push_back(make_pair(0, data_size));
+    chunks.push_back(std::make_pair(0, data_size));
     return 0;
   }
 
@@ -113,7 +114,7 @@ int RabinChunk::do_rabin_chunks(bufferlist & inputdata,
     }
 
     if (store_chunk) {
-      chunks.push_back(make_pair(c_start, c_size));
+      chunks.push_back(std::make_pair(c_start, c_size));
       c_start += c_size;
       c_offset = c_start;
       start_new_chunk = true;
@@ -127,7 +128,7 @@ int RabinChunk::do_rabin_chunks(bufferlist & inputdata,
 
   if (c_start < data_size) {
     c_size = data_size - c_start;
-    chunks.push_back(make_pair(c_start, c_size));
+    chunks.push_back(std::make_pair(c_start, c_size));
   }
 
   return 0;
index 30148fea8444d7859d9f39de55727f1cc3e3667d..6ffaa2bcf92b60b87b356564cf4ca0c8836959be 100644 (file)
 #ifndef CEPH_COMMON_RABIN_H_
 #define CEPH_COMMON_RABIN_H_
 
+#include <cstdint>
+#include <utility>
+#include <vector>
+
+#include "include/buffer_fwd.h"
+
 class RabinChunk {
 public:
-  RabinChunk(uint32_t window_size, uint32_t rabin_prime, 
-            uint64_t mod_prime, uint64_t pow, vector<uint64_t> rabin_mask, uint64_t min,
-            uint64_t max, uint32_t num_bits):
-             window_size(window_size), rabin_prime(rabin_prime), mod_prime(mod_prime),
-             pow(pow), rabin_mask(rabin_mask), min(min), max(max), num_bits(num_bits) {}
+  RabinChunk(uint32_t window_size, uint32_t rabin_prime,
+            uint64_t mod_prime, uint64_t pow, std::vector<uint64_t> rabin_mask,
+            uint64_t min, uint64_t max, uint32_t num_bits):
+             window_size(window_size), rabin_prime(rabin_prime),
+             mod_prime(mod_prime), pow(pow), rabin_mask(rabin_mask), min(min),
+             max(max), num_bits(num_bits) {}
   RabinChunk() {
     default_init_rabin_options();
   }
 
   void default_init_rabin_options() {
-    vector<uint64_t> _rabin_mask = {0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
+    std::vector<uint64_t> _rabin_mask = {0,1,3,7,15,31,63,127,255,511,1023,2047,
+                                        4095,8191,16383,32767,65535};
     window_size = 48;
     rabin_prime = 3;
     mod_prime = 6148914691236517051;
@@ -38,8 +46,8 @@ public:
     rabin_mask = _rabin_mask;
   }
 
-  int do_rabin_chunks(bufferlist & inputdata, 
-                     vector<pair<uint64_t, uint64_t>> & chunks, 
+  int do_rabin_chunks(ceph::buffer::list& inputdata,
+                     std::vector<std::pair<uint64_t, uint64_t>>& chunks,
                      uint64_t min, uint64_t max);
   uint64_t gen_rabin_hash(char* chunk_data, uint64_t off, uint64_t len = 0);
   bool end_of_chunk(const uint64_t fp , int numbits);
@@ -47,10 +55,10 @@ public:
   void set_rabin_prime(uint32_t r_prime) { rabin_prime = r_prime; }
   void set_mod_prime(uint64_t m_prime) { mod_prime = m_prime; }
   void set_pow(uint64_t p) { pow = p; }
-  void set_rabin_mask(vector<uint64_t> & mask) { rabin_mask = mask; }
+  void set_rabin_mask(std::vector<uint64_t> & mask) { rabin_mask = mask; }
   void set_min_chunk(uint32_t c_min) { min = c_min; }
   void set_max_chunk(uint32_t c_max) { max = c_max; }
-  int add_rabin_mask(uint64_t mask) { 
+  int add_rabin_mask(uint64_t mask) {
     rabin_mask.push_back(mask);
     for (int i = 0; rabin_mask.size(); i++) {
       if (rabin_mask[i] == mask) {
@@ -66,8 +74,8 @@ private:
   uint32_t window_size;
   uint32_t rabin_prime;
   uint64_t mod_prime;
-  uint64_t pow; 
-  vector<uint64_t> rabin_mask;
+  uint64_t pow;
+  std::vector<uint64_t> rabin_mask;
   uint64_t min;
   uint64_t max;
   uint32_t num_bits;
index d0385138bbdba26f0d7ba08911f242a93085b2db..4b2cfa613d66f52d0d5eda42cb0c0d61c55d4f1c 100644 (file)
@@ -1,5 +1,7 @@
 #include "scrub_types.h"
 
+using std::map;
+
 using namespace librados;
 
 void object_id_wrapper::encode(bufferlist& bl) const
index 31e33d46771306d6b19ca23c6f7a62856818a960..edb6aa17aa6db1dbdfa530c4c155d048cb6e81d0 100644 (file)
  *
  */
 
+#include <cstdlib>
+#include <sstream>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <signal.h>
+
 #include "common/BackTrace.h"
-#include "common/perf_counters.h"
-#include "global/pidfile.h"
+#include "common/config.h"
 #include "common/debug.h"
 #include "common/signal.h"
-#include "common/config.h"
+#include "common/perf_counters.h"
 
-#include <signal.h>
-#include <sstream>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include "global/pidfile.h"
+
+using namespace std::literals;
 
 std::string signal_mask_to_str()
 {
@@ -32,9 +37,9 @@ std::string signal_mask_to_str()
     return "(pthread_signmask failed)";
   }
 
-  ostringstream oss;
+  std::ostringstream oss;
   oss << "show_signal_mask: { ";
-  string sep("");
+  auto sep = ""s;
   for (int signum = 0; signum < NSIG; ++signum) {
     if (sigismember(&old_sigset, signum) == 1) {
       oss << sep << signum;
index 3e33583db16fd20718f1a5faf757dc059af8caf3..521404ca2b5b028b22128c224e3d65f5428026f6 100644 (file)
@@ -1,26 +1,28 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
 
 #include "snap_types.h"
 #include "common/Formatter.h"
 
-void SnapRealmInfo::encode(bufferlist& bl) const
+void SnapRealmInfo::encode(ceph::buffer::list& bl) const
 {
   h.num_snaps = my_snaps.size();
   h.num_prior_parent_snaps = prior_parent_snaps.size();
   using ceph::encode;
   encode(h, bl);
-  encode_nohead(my_snaps, bl);
-  encode_nohead(prior_parent_snaps, bl);
+  ceph::encode_nohead(my_snaps, bl);
+  ceph::encode_nohead(prior_parent_snaps, bl);
 }
 
-void SnapRealmInfo::decode(bufferlist::const_iterator& bl)
+void SnapRealmInfo::decode(ceph::buffer::list::const_iterator& bl)
 {
   using ceph::decode;
   decode(h, bl);
-  decode_nohead(h.num_snaps, my_snaps, bl);
-  decode_nohead(h.num_prior_parent_snaps, prior_parent_snaps, bl);
+  ceph::decode_nohead(h.num_snaps, my_snaps, bl);
+  ceph::decode_nohead(h.num_prior_parent_snaps, prior_parent_snaps, bl);
 }
 
-void SnapRealmInfo::dump(Formatter *f) const
+void SnapRealmInfo::dump(ceph::Formatter *f) const
 {
   f->dump_unsigned("ino", ino());
   f->dump_unsigned("parent", parent());
@@ -29,17 +31,17 @@ void SnapRealmInfo::dump(Formatter *f) const
   f->dump_unsigned("created", created());
 
   f->open_array_section("snaps");
-  for (vector<snapid_t>::const_iterator p = my_snaps.begin(); p != my_snaps.end(); ++p)
+  for (auto p = my_snaps.begin(); p != my_snaps.end(); ++p)
     f->dump_unsigned("snap", *p);
   f->close_section();
 
   f->open_array_section("prior_parent_snaps");
-  for (vector<snapid_t>::const_iterator p = prior_parent_snaps.begin(); p != prior_parent_snaps.end(); ++p)
+  for (auto p = prior_parent_snaps.begin(); p != prior_parent_snaps.end(); ++p)
     f->dump_unsigned("snap", *p);
-  f->close_section();  
+  f->close_section();
 }
 
-void SnapRealmInfo::generate_test_instances(list<SnapRealmInfo*>& o)
+void SnapRealmInfo::generate_test_instances(std::list<SnapRealmInfo*>& o)
 {
   o.push_back(new SnapRealmInfo);
   o.push_back(new SnapRealmInfo(1, 10, 10, 0));
@@ -74,19 +76,19 @@ bool SnapContext::is_valid() const
   return true;
 }
 
-void SnapContext::dump(Formatter *f) const
+void SnapContext::dump(ceph::Formatter *f) const
 {
   f->dump_unsigned("seq", seq);
   f->open_array_section("snaps");
-  for (vector<snapid_t>::const_iterator p = snaps.begin(); p != snaps.end(); ++p)
+  for (auto p = snaps.cbegin(); p != snaps.cend(); ++p)
     f->dump_unsigned("snap", *p);
   f->close_section();
 }
 
-void SnapContext::generate_test_instances(list<SnapContext*>& o)
+void SnapContext::generate_test_instances(std::list<SnapContext*>& o)
 {
   o.push_back(new SnapContext);
-  vector<snapid_t> v;
+  std::vector<snapid_t> v;
   o.push_back(new SnapContext(10, v));
   v.push_back(18);
   v.push_back(3);
index 3686132924216b6dadb30caa359730d55b1b18b7..7f11cd798fb34ee4604e1988fdfd76712679828a 100644 (file)
@@ -24,7 +24,7 @@
 
 const shard_id_t shard_id_t::NO_SHARD(-1);
 
-ostream &operator<<(ostream &lhs, const shard_id_t &rhs)
+std::ostream& operator<<(std::ostream& lhs, const shard_id_t& rhs)
 {
   return lhs << (unsigned)(uint8_t)rhs.id;
 }
index f816ff41db0bd9a3f023e12fc055825880bae9af..b4846328ce132542c1e212de8d4fe8ae7388e13e 100644 (file)
 
 #include <stdio.h>
 
+using std::list;
+using std::map;
+using std::string;
+
+using ceph::bufferlist;
+using ceph::Formatter;
+
 int get_fs_stats(ceph_data_stats_t &stats, const char *path)
 {
   if (!path)
@@ -72,7 +79,7 @@ static char* value_sanitize(char *value)
 }
 
 static bool value_set(char *buf, const char *prefix,
-                           map<string, string> *pm, const char *key)
+                     map<string, string> *pm, const char *key)
 {
   if (strncmp(buf, prefix, strlen(prefix))) {
     return false;
@@ -287,12 +294,12 @@ void dump_services(Formatter* f, const map<string, list<int> >& services, const
   ceph_assert(f);
 
   f->open_object_section(type);
-  for (map<string, list<int> >::const_iterator host = services.begin();
+  for (auto host = services.begin();
        host != services.end(); ++host) {
     f->open_array_section(host->first.c_str());
     const list<int>& hosted = host->second;
-    for (list<int>::const_iterator s = hosted.begin();
-        s != hosted.end(); ++s) {
+    for (auto s = hosted.cbegin();
+        s != hosted.cend(); ++s) {
       f->dump_int(type, *s);
     }
     f->close_section();