diff mbox

[ovs-dev] lib/util.h: change definition of LIST_FOR_EACH_CONTINUE macro

Message ID CAPwdgqgBpKDtGDcMLvqSRH3aLW5GzeNEm7nEWCM3owdfOx0LsQ@mail.gmail.com
State Accepted
Headers show

Commit Message

Mauricio Vásquez Oct. 2, 2015, 11:23 a.m. UTC
The definition of the INIT_CONTAINER macro initializes ITER to NULL,
it will cause a segmentation fault when it is deferenced on
(ITER)->MEMBER.next, then, I changed it to the ASSIGN_CONTAINER macro that
does not initialize ITER.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it
>

---
 lib/list.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--

Comments

Ben Pfaff Oct. 2, 2015, 1:25 p.m. UTC | #1
On Fri, Oct 02, 2015 at 01:23:31PM +0200, Mauricio Vásquez wrote:
> The definition of the INIT_CONTAINER macro initializes ITER to NULL,
> it will cause a segmentation fault when it is deferenced on
> (ITER)->MEMBER.next, then, I changed it to the ASSIGN_CONTAINER macro that
> does not initialize ITER.
> 
> Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it
> >

Applied, thanks!
diff mbox

Patch

diff --git a/lib/list.h b/lib/list.h
index 5ad54b8..db4a613 100644
--- a/lib/list.h
+++ b/lib/list.h
@@ -62,7 +62,7 @@  static inline bool list_is_short(const struct ovs_list *);
          &(ITER)->MEMBER != (LIST);                                     \
          ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.next, MEMBER))
 #define LIST_FOR_EACH_CONTINUE(ITER, MEMBER, LIST)                      \
-    for (INIT_CONTAINER(ITER, (ITER)->MEMBER.next, MEMBER);             \
+    for (ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.next, MEMBER);             \
          &(ITER)->MEMBER != (LIST);                                     \
          ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.next, MEMBER))
 #define LIST_FOR_EACH_REVERSE(ITER, MEMBER, LIST)                       \