]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/buffer.h: fix operator=
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 6 Feb 2013 11:02:47 +0000 (12:02 +0100)
committerSage Weil <sage@inktank.com>
Wed, 6 Feb 2013 16:42:03 +0000 (08:42 -0800)
Fix operator=: return "iterator&" instead of 'iterator'. Check if 'this'
equals 'other' before set anything.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/include/buffer.h

index 9a635bdb5d0f7f11aa989b5bbc8bb847f13379db..4f87ed7453b8637fb7d360a4b0d8f662466af4e1 100644 (file)
@@ -248,7 +248,7 @@ public:
                                        p(other.p),
                                        p_off(other.p_off) {}
 
-      iterator operator=(const iterator& other) {
+      iterator& operator=(const iterator& other) {
        if (this != &other) {
          bl = other.bl;
          ls = other.ls;
@@ -305,8 +305,10 @@ public:
     
     list(const list& other) : _buffers(other._buffers), _len(other._len), last_p(this) { }
     list& operator= (const list& other) {
-      _buffers = other._buffers;
-      _len = other._len;
+      if (this != &other) {
+        _buffers = other._buffers;
+        _len = other._len;
+      }
       return *this;
     }