All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
To: ceph-devel@vger.kernel.org
Cc: Danny Al-Gaaf <dalgaaf@suse.de>, Sage Weil <sage@inktank.com>
Subject: [PATCH 4/8] include/buffer.h: fix operator=
Date: Tue,  5 Feb 2013 23:52:26 +0100	[thread overview]
Message-ID: <1360104750-16098-5-git-send-email-danny.al-gaaf@bisect.de> (raw)
In-Reply-To: <1360104750-16098-1-git-send-email-danny.al-gaaf@bisect.de>

Fix operator=: return "iterator&" instead of 'iterator'. Also set last_p and
other.append_buffer and check if 'this' equals 'other' before set anything.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
---
 src/include/buffer.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/include/buffer.h b/src/include/buffer.h
index 9a635bd..448d947 100644
--- a/src/include/buffer.h
+++ b/src/include/buffer.h
@@ -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,12 @@ 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;
+        last_p = other.last_p;
+	append_buffer = other.append_buffer;
+      }
       return *this;
     }
 
-- 
1.8.1.2


  parent reply	other threads:[~2013-02-05 22:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-05 22:52 [PATCH 0/8] fix some issues from cppchecker/clang++ Danny Al-Gaaf
2013-02-05 22:52 ` [PATCH 1/8] WorkQueue.h: fix cast Danny Al-Gaaf
2013-02-05 22:52 ` [PATCH 2/8] ceph_crypto.cc: remove unused shutdown() outside crypto ifdef's Danny Al-Gaaf
2013-02-05 22:52 ` [PATCH 3/8] obj_bencher.cc: use vector instead of VLA's Danny Al-Gaaf
2013-02-05 22:52 ` Danny Al-Gaaf [this message]
2013-02-06  5:47   ` [PATCH 4/8] include/buffer.h: fix operator= Sage Weil
2013-02-05 22:52 ` [PATCH 5/8] include/types.h: change operator<< function parameter Danny Al-Gaaf
2013-02-05 22:52 ` [PATCH 6/8] include/xlist.h: fix C-style pointer casting Danny Al-Gaaf
2013-02-05 22:52 ` [PATCH 7/8] messages/MOSDRepScrub.h: initialize member variable in constructor Danny Al-Gaaf
2013-02-06  5:50   ` Sage Weil
2013-02-05 22:52 ` [PATCH 8/8] msg/Message.h: fix C-style pointer casting Danny Al-Gaaf
2013-02-06  3:50 ` [PATCH 0/8] fix some issues from cppchecker/clang++ Gary Lowell
2013-02-06  5:51 ` Sage Weil
2013-02-06 11:02 [PATCH v2 " Danny Al-Gaaf
2013-02-06 11:02 ` [PATCH 4/8] include/buffer.h: fix operator= Danny Al-Gaaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360104750-16098-5-git-send-email-danny.al-gaaf@bisect.de \
    --to=danny.al-gaaf@bisect.de \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dalgaaf@suse.de \
    --cc=sage@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.