]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
all: add const to operator<< param
authorMichal Jarzabek <stiopa@gmail.com>
Sat, 4 Jun 2016 22:24:06 +0000 (23:24 +0100)
committerKefu Chai <kchai@redhat.com>
Wed, 2 Nov 2016 11:23:24 +0000 (19:23 +0800)
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
(cherry picked from commit 0a157e088b2e5eb66177421f19f559ca427240eb)

24 files changed:
src/client/Inode.cc
src/client/Inode.h
src/cls/cephfs/cls_cephfs.cc
src/common/TextTable.cc
src/common/TextTable.h
src/common/ceph_json.cc
src/common/ceph_json.h
src/mds/LogEvent.h
src/mds/MDSMap.h
src/mds/Mutation.h
src/mds/flock.h
src/mon/AuthMonitor.cc
src/mon/LogMonitor.cc
src/mon/MonMap.h
src/msg/Message.h
src/osdc/Journaler.cc
src/osdc/ObjectCacher.h
src/rbd_replay/ios.cc
src/rbd_replay/ios.hpp
src/rgw/rgw_xml.cc
src/rgw/rgw_xml.h
src/test/old/testbucket.cc
src/test/osd/TestOpStat.cc
src/test/osd/TestOpStat.h

index 51c9d6299018c556822016883764465e1ddef7ad..0dca7bdaae6611496b3340aa98fc1ebeb1fbc3c8 100644 (file)
@@ -9,7 +9,7 @@
 #include "ClientSnapRealm.h"
 #include "UserGroups.h"
 
-ostream& operator<<(ostream &out, Inode &in)
+ostream& operator<<(ostream &out, const Inode &in)
 {
   out << in.vino() << "("
       << "faked_ino=" << in.faked_ino
@@ -23,7 +23,7 @@ ostream& operator<<(ostream &out, Inode &in)
       << " caps=" << ccap_string(in.caps_issued());
   if (!in.caps.empty()) {
     out << "(";
-    for (map<mds_rank_t,Cap*>::iterator p = in.caps.begin(); p != in.caps.end(); ++p) {
+    for (auto p = in.caps.begin(); p != in.caps.end(); ++p) {
       if (p != in.caps.begin())
         out << ',';
       out << p->first << '=' << ccap_string(p->second->issued);
@@ -147,7 +147,7 @@ bool Inode::is_any_caps()
   return !caps.empty() || snap_caps;
 }
 
-bool Inode::cap_is_valid(Cap* cap)
+bool Inode::cap_is_valid(Cap* cap) const
 {
   /*cout << "cap_gen     " << cap->session-> cap_gen << std::endl
     << "session gen " << cap->gen << std::endl
@@ -160,11 +160,11 @@ bool Inode::cap_is_valid(Cap* cap)
   return false;
 }
 
-int Inode::caps_issued(int *implemented)
+int Inode::caps_issued(int *implemented) const
 {
   int c = snap_caps;
   int i = 0;
-  for (map<mds_rank_t,Cap*>::iterator it = caps.begin();
+  for (map<mds_rank_t,Cap*>::const_iterator it = caps.begin();
        it != caps.end();
        ++it)
     if (cap_is_valid(it->second)) {
index 884443de1963dae5ed1861b0bcf0adbe89c2fa69..c54dcc4078e68f9cd176708ce991388e46e84cf4 100644 (file)
@@ -244,7 +244,7 @@ struct Inode {
   }
   ~Inode() { }
 
-  vinodeno_t vino() { return vinodeno_t(ino, snapid); }
+  vinodeno_t vino() const { return vinodeno_t(ino, snapid); }
 
   struct Compare {
     bool operator() (Inode* const & left, Inode* const & right) {
@@ -264,8 +264,8 @@ struct Inode {
   void get_cap_ref(int cap);
   int put_cap_ref(int cap);
   bool is_any_caps();
-  bool cap_is_valid(Cap* cap);
-  int caps_issued(int *implemented = 0);
+  bool cap_is_valid(Cap* cap) const;
+  int caps_issued(int *implemented = 0) const;
   void touch_cap(Cap *cap);
   void try_touch_cap(mds_rank_t mds);
   bool caps_issued_mask(unsigned mask);
@@ -283,6 +283,6 @@ struct Inode {
   void dump(Formatter *f) const;
 };
 
-ostream& operator<<(ostream &out, Inode &in);
+ostream& operator<<(ostream &out, const Inode &in);
 
 #endif
index 8f54e3a69732cd64b4d34135e15cb2f61210825c..6e81a53e98666b6bd62da49a73afd3a43c40e294 100644 (file)
@@ -29,7 +29,7 @@ cls_method_handle_t h_accumulate_inode_metadata;
 
 
 
-std::ostream &operator<<(std::ostream &out, ObjCeiling &in)
+std::ostream &operator<<(std::ostream &out, const ObjCeiling &in)
 {
   out << "id: " << in.id << " size: " << in.size;
   return out;
index 4aef2f94ea7d6ad4dbc3a0f881bb979fd3e28a40..3c09fded605bb9560653b7c2f25f4e7dfa480813 100644 (file)
@@ -62,7 +62,7 @@ pad(string s, int width, TextTable::Align align)
   return string(lpad, ' ') + s + string(rpad, ' ');
 }
 
-std::ostream &operator<<(std::ostream& out, TextTable &t)
+std::ostream &operator<<(std::ostream &out, const TextTable &t)
 {
   for (unsigned int i = 0; i < t.col.size(); i++) {
     TextTable::TextTableColumn col = t.col[i];
index 4a9825a7f0ec5f7d018202ac751b1bfc5dfbde7e..102e16fe4824647d607e5ea3c90f0a06e18c85c4 100644 (file)
@@ -149,7 +149,7 @@ public:
    * Render table to ostream (i.e. cout << table)
    */
 
-  friend std::ostream &operator<<(std::ostream& out, TextTable &t);
+  friend std::ostream &operator<<(std::ostream &out, const TextTable &t);
 
   /**
    * clear: Reset everything in a TextTable except column defs
index d1d33a91c00797f279e18969c79c3cd477bae24d..52be8421bb9fda2e81458a96964f288e4922054d 100644 (file)
@@ -40,7 +40,7 @@ JSONObj *JSONObjIter::operator*()
 }
 
 // does not work, FIXME
-ostream& operator<<(ostream& out, JSONObj& obj) {
+ostream& operator<<(ostream &out, const JSONObj &obj) {
    out << obj.name << ": " << obj.data_string;
    return out;
 }
index a812d7af1a267d25d49af92386144cab00357f54..67483490f34668b5791b9b14209d125d83debd4c 100644 (file)
@@ -73,7 +73,8 @@ public:
   JSONObjIter find_first(const string& name);
   JSONObj *find_obj(const string& name);
 
-  friend ostream& operator<<(ostream& out, JSONObj& obj); // does not work, FIXME
+  friend ostream& operator<<(ostream &out,
+                            const JSONObj &obj); // does not work, FIXME
 
   bool is_array();
   bool is_object();
index 8c1cd1b07f5acf56c73bbbd7de84db6337bc1e91..ecea57ca3ce57b2a1d70513793a53be49af34185 100644 (file)
@@ -118,7 +118,7 @@ public:
   virtual EMetaBlob *get_metablob() { return NULL; }
 };
 
-inline ostream& operator<<(ostream& out, LogEvent& le) {
+inline ostream& operator<<(ostream& out, const LogEvent &le) {
   le.print(out);
   return out;
 }
index 60aaf001070cb9a156616e9f000febf36e1b0df9..9dc9b5853668ce79d654dc361a41326dca9bff18 100644 (file)
@@ -632,7 +632,7 @@ public:
 WRITE_CLASS_ENCODER_FEATURES(MDSMap::mds_info_t)
 WRITE_CLASS_ENCODER_FEATURES(MDSMap)
 
-inline ostream& operator<<(ostream& out, MDSMap& m) {
+inline ostream& operator<<(ostream &out, const MDSMap &m) {
   m.print_summary(NULL, &out);
   return out;
 }
index f43d6609bacbdb8e6cb01c1dd412e6af895befb6..91e68db899a09697b7668200cec4535ba96a1f01 100644 (file)
@@ -158,14 +158,14 @@ public:
   void apply();
   void cleanup();
 
-  virtual void print(ostream &out) {
+  virtual void print(ostream &out) const {
     out << "mutation(" << this << ")";
   }
 
   virtual void dump(Formatter *f) const {}
 };
 
-inline ostream& operator<<(ostream& out, MutationImpl &mut)
+inline ostream& operator<<(ostream &out, const MutationImpl &mut)
 {
   mut.print(out);
   return out;
index fade1a88e3229432e1556b010fe8e83be34b6eb1..2cf9f0a3927b1350bb583abeceab90cffeaf7cd4 100644 (file)
@@ -277,18 +277,18 @@ public:
 WRITE_CLASS_ENCODER(ceph_lock_state_t)
 
 
-inline ostream& operator<<(ostream& out, ceph_lock_state_t& l) {
+inline ostream& operator<<(ostream &out, const ceph_lock_state_t &l) {
   out << "ceph_lock_state_t. held_locks.size()=" << l.held_locks.size()
       << ", waiting_locks.size()=" << l.waiting_locks.size()
       << ", client_held_lock_counts -- " << l.client_held_lock_counts
       << "\n client_waiting_lock_counts -- " << l.client_waiting_lock_counts
       << "\n held_locks -- ";
-    for (multimap<uint64_t, ceph_filelock>::iterator iter = l.held_locks.begin();
+    for (auto iter = l.held_locks.begin();
          iter != l.held_locks.end();
          ++iter)
       out << iter->second;
     out << "\n waiting_locks -- ";
-    for (multimap<uint64_t, ceph_filelock>::iterator iter =l.waiting_locks.begin();
+    for (auto iter =l.waiting_locks.begin();
          iter != l.waiting_locks.end();
          ++iter)
       out << iter->second << "\n";
index 10003a10afe177c2f7755223d136232369e7fee0..fff9f0d3f38fbfd8d668a1c77eba0d9f7d9cf886 100644 (file)
@@ -44,7 +44,7 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) {
                << ").auth v" << v << " ";
 }
 
-ostream& operator<<(ostream& out, AuthMonitor& pm)
+ostream& operator<<(ostream &out, const AuthMonitor &pm)
 {
   return out << "auth";
 }
index 391a3380b79ba8d89233336aa16b2bbd996a0323..aee3e5998a20e480b1e336661c5db8bee0945d59 100644 (file)
@@ -46,7 +46,7 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) {
                << ").log v" << v << " ";
 }
 
-ostream& operator<<(ostream& out, LogMonitor& pm)
+ostream& operator<<(ostream &out, const LogMonitor &pm)
 {
   /*
   std::stringstream ss;
index 390d88a7ca2e15a1a5aad911fda166b95a23070b..5704ee5629e87dadc38c0ce4a70cb517ad2faba3 100644 (file)
@@ -240,7 +240,7 @@ class MonMap {
 };
 WRITE_CLASS_ENCODER_FEATURES(MonMap)
 
-inline ostream& operator<<(ostream& out, MonMap& m) {
+inline ostream& operator<<(ostream &out, const MonMap &m) {
   m.print_summary(out);
   return out;
 }
index 25b03722bcfd154d9b0279109079fb77d8c84658..856f30b3e64854e43a04308dc3a2115ba1daffd5 100644 (file)
@@ -470,7 +470,7 @@ extern Message *decode_message(CephContext *cct, int crcflags,
                               ceph_msg_header &header,
                               ceph_msg_footer& footer, bufferlist& front,
                               bufferlist& middle, bufferlist& data);
-inline ostream& operator<<(ostream& out, Message& m) {
+inline ostream& operator<<(ostream &out, const Message &m) {
   m.print(out);
   if (m.get_header().version)
     out << " v" << m.get_header().version;
index 3e20aa93e151684618e13780e654452d44be99d5..2d6f85e5d7e3e4161f208d5d0e359b827f93dfd5 100644 (file)
@@ -89,7 +89,7 @@ void Journaler::_set_layout(file_layout_t const *l)
 
 /***************** HEADER *******************/
 
-ostream& operator<<(ostream& out, Journaler::Header &h)
+ostream& operator<<(ostream &out, const Journaler::Header &h)
 {
   return out << "loghead(trim " << h.trimmed_pos
             << ", expire " << h.expire_pos
index d136c392850cb466092d55dd558013c55c53350b..b34a5de0139a34a3d71c9a05defdf71b834f0c73 100644 (file)
@@ -165,13 +165,13 @@ class ObjectCacher {
       journal_tid = _journal_tid;
     }
 
-    bool is_missing() { return state == STATE_MISSING; }
-    bool is_dirty() { return state == STATE_DIRTY; }
-    bool is_clean() { return state == STATE_CLEAN; }
-    bool is_zero() { return state == STATE_ZERO; }
-    bool is_tx() { return state == STATE_TX; }
-    bool is_rx() { return state == STATE_RX; }
-    bool is_error() { return state == STATE_ERROR; }
+    bool is_missing() const { return state == STATE_MISSING; }
+    bool is_dirty() const { return state == STATE_DIRTY; }
+    bool is_clean() const { return state == STATE_CLEAN; }
+    bool is_zero() const { return state == STATE_ZERO; }
+    bool is_tx() const { return state == STATE_TX; }
+    bool is_rx() const { return state == STATE_RX; }
+    bool is_error() const { return state == STATE_ERROR; }
 
     // reference counting
     int get() {
@@ -275,14 +275,14 @@ class ObjectCacher {
       set_item.remove_myself();
     }
 
-    sobject_t get_soid() { return oid; }
+    sobject_t get_soid() const { return oid; }
     object_t get_oid() { return oid.oid; }
     snapid_t get_snap() { return oid.snap; }
-    ObjectSet *get_object_set() { return oset; }
+    ObjectSet *get_object_set() const { return oset; }
     string get_namespace() { return oloc.nspace; }
     uint64_t get_object_number() const { return object_no; }
 
-    object_locator_t& get_oloc() { return oloc; }
+    const object_locator_t& get_oloc() const { return oloc; }
     void set_object_locator(object_locator_t& l) { oloc = l; }
 
     bool can_close() {
@@ -777,7 +777,7 @@ public:
 };
 
 
-inline ostream& operator<<(ostream& out, ObjectCacher::BufferHead &bh)
+inline ostream& operator<<(ostream &out, const ObjectCacher::BufferHead &bh)
 {
   out << "bh[ " << &bh << " "
       << bh.start() << "~" << bh.length()
@@ -811,7 +811,7 @@ inline ostream& operator<<(ostream& out, ObjectCacher::BufferHead &bh)
   return out;
 }
 
-inline ostream& operator<<(ostream& out, ObjectCacher::ObjectSet &os)
+inline ostream& operator<<(ostream &out, const ObjectCacher::ObjectSet &os)
 {
   return out << "objectset[" << os.ino
             << " ts " << os.truncate_seq << "/" << os.truncate_size
@@ -820,7 +820,7 @@ inline ostream& operator<<(ostream& out, ObjectCacher::ObjectSet &os)
             << "]";
 }
 
-inline ostream& operator<<(ostream& out, ObjectCacher::Object &ob)
+inline ostream& operator<<(ostream &out, const ObjectCacher::Object &ob)
 {
   out << "object["
       << ob.get_soid() << " oset " << ob.oset << dec
index 7bbc9abb3c73e350b51661822e1b5c547bebc948..db8470e9cf424100b8997d14ce0568a48d26bc8e 100644 (file)
@@ -62,7 +62,7 @@ void IO::write_debug_base(ostream& out, string type) const {
 }
 
 
-ostream& operator<<(ostream& out, IO::ptr io) {
+ostream& operator<<(ostream &out, const IO::ptr &io) {
   io->write_debug(out);
   return out;
 }
index b4ab76de1ca05a61fe6fa5cd762a8e37d1444633..5f19648b9e64b1e7a631fc5dd2784bd2457cfc7d 100644 (file)
@@ -106,7 +106,7 @@ private:
 
 /// Used for dumping debug info.
 /// @related IO
-std::ostream& operator<<(std::ostream& out, IO::ptr io);
+std::ostream& operator<<(std::ostream &out, const IO::ptr &io);
 
 
 class StartThreadIO : public IO {
index df555f800ac2aeb91417f74d96ca8d7e65566002..ff067a4f1da155bd069614cca37beaa3fa45f6da 100644 (file)
@@ -45,7 +45,7 @@ get_next()
   return obj;
 }
 
-ostream& operator<<(ostream& out, XMLObj& obj) {
+ostream& operator<<(ostream &out, const XMLObj &obj) {
    out << obj.obj_type << ": " << obj.data;
    return out;
 }
index 257a15665abaa1d1d012f67de1bb60410bb8148f..49b1fb8655260f593a6780b7d86741f661a9a5dc 100644 (file)
@@ -56,7 +56,7 @@ public:
   XMLObjIter find(string name);
   XMLObj *find_first(string name);
 
-  friend ostream& operator<<(ostream& out, XMLObj& obj);
+  friend ostream& operator<<(ostream &out, const XMLObj &obj);
 };
 
 struct XML_ParserStruct;
index d8676da18faba7446e294627b843e2e5c1115079..cf1b095b50b4a23a0774da7da7461eb94a5951bb 100644 (file)
@@ -8,7 +8,7 @@ using namespace crush;
 using namespace std;
 
 
-ostream& operator<<(ostream& out, vector<int>& v)
+ostream& operator<<(ostream &out, const vector<int> &v)
 {
   out << "[";
   for (int i=0; i<v.size(); i++) {
index db6a82e22816026a0400001ebee16970db81f6a0..e8045fa43fbef34b692e538c7b37ff5a6644823f 100644 (file)
@@ -34,10 +34,10 @@ void TestOpStat::TypeStatus::export_latencies(map<double,uint64_t> &in) const
   }
 }
   
-std::ostream & operator<<(std::ostream &out, TestOpStat &rhs)
+std::ostream & operator<<(std::ostream &out, const TestOpStat &rhs)
 {
   rhs.stat_lock.Lock();
-  for (map<string,TestOpStat::TypeStatus>::iterator i = rhs.stats.begin();
+  for (auto i = rhs.stats.begin();
        i != rhs.stats.end();
        ++i) {
     map<double,uint64_t> latency;
index 3d70ece719e7465da64e7611f40232dce6c25a53..5bf4fc9595c359c44fc0a3c4a916cf11a8927df3 100644 (file)
@@ -10,7 +10,7 @@ class TestOp;
 
 class TestOpStat {
 public:
-  Mutex stat_lock;
+  mutable Mutex stat_lock;
 
   TestOpStat() : stat_lock("TestOpStat lock") {}
     
@@ -45,9 +45,9 @@ public:
 
   void begin(TestOp *in);
   void end(TestOp *in);
-  friend std::ostream & operator<<(std::ostream &, TestOpStat&);
+  friend std::ostream & operator<<(std::ostream &, const TestOpStat &);
 };
 
-std::ostream & operator<<(std::ostream &out, TestOpStat &rhs);
+std::ostream & operator<<(std::ostream &out, const TestOpStat &rhs);
 
 #endif