From 17430c3c56195f5eec2bbda57e8f20bfa5b4c2e2 Mon Sep 17 00:00:00 2001
From: Sasan Golchin <ahmad.golchin@mail.polimi.it>
Date: Thu, 26 May 2016 15:44:55 +0200
Subject: [PATCH] Fixed a bug in IntrusiveList<T>::iterator's ++ and --
 operators that did not return anything, but now they return the correct
 instance.

---
 miosix/kernel/intrusive.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/miosix/kernel/intrusive.h b/miosix/kernel/intrusive.h
index 36fa7c37..18c26560 100644
--- a/miosix/kernel/intrusive.h
+++ b/miosix/kernel/intrusive.h
@@ -669,10 +669,20 @@ public:
         T *cur;
     public:
         iterator(T *cur) : cur(cur) {}
-        iterator operator++() { cur = static_cast<T*>(cur->next); }
-        iterator operator--() { cur = static_cast<T*>(cur->prev); }
-        iterator operator++(int) { cur = static_cast<T*>(cur->next); }
-        iterator operator--(int) { cur = static_cast<T*>(cur->prev); }
+        iterator operator++() { cur = static_cast<T*>(cur->next); return *this; }
+        iterator operator--() { cur = static_cast<T*>(cur->prev); return *this; }
+        iterator operator++(int)
+        {
+            iterator result=*this;
+            cur = static_cast<T*>(cur->next);
+            return result;
+        }
+        iterator operator--(int)
+        {
+            iterator result=*this;
+            cur = static_cast<T*>(cur->prev);
+            return result;
+        }
         T* operator*() { return cur; }
         bool operator==(const iterator& rhs) { return cur==rhs.cur; }
         bool operator!=(const iterator& rhs) { return cur!=rhs.cur; }
-- 
GitLab