summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>2013-02-06 12:02:47 +0100
committerSage Weil <sage@inktank.com>2013-02-06 08:42:03 -0800
commit0327cbaa2ab48b8da8aad181f55ce4e48fe3946c (patch)
tree343f1e7b1ae430a87f31ae6cf1bccc9508fdb9a7
parentad526c0e442ce9b1069d90816e898ede36fb1066 (diff)
downloadceph-0327cbaa2ab48b8da8aad181f55ce4e48fe3946c.tar.gz
include/buffer.h: fix operator=
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>
-rw-r--r--src/include/buffer.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/include/buffer.h b/src/include/buffer.h
index 9a635bdb5d0..4f87ed7453b 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,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;
}