From 6ebcac4f88d4d009eb82689f08b7b967d8ef06c4 Mon Sep 17 00:00:00 2001 From: bernie Date: Sun, 10 Aug 2008 12:20:10 +0000 Subject: [PATCH] list: Check pointers with ASSERT_VALID_PTR() rather than just ASSERT() This fixes gcc 4.3 warnings when pointers to global variables were passed to list macros. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1594 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/mware/list.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bertos/mware/list.h b/bertos/mware/list.h index de5b0658..bd93ba2e 100644 --- a/bertos/mware/list.h +++ b/bertos/mware/list.h @@ -42,7 +42,7 @@ #define MWARE_LIST_H #include /* INLINE */ -#include /* ASSERT() */ +#include /* ASSERT_VALID_PTR() */ /** * This structure represents a node for bidirectional lists. @@ -214,8 +214,8 @@ typedef struct _PriNode /** Add node to list head. */ #define ADDHEAD(l,n) \ do { \ - ASSERT(l); \ - ASSERT(n); \ + ASSERT_VALID_PTR(l); \ + ASSERT_VALID_PTR(n); \ (n)->succ = (l)->head.succ; \ (n)->pred = (l)->head.succ->pred; \ (n)->succ->pred = (n); \ @@ -225,8 +225,8 @@ typedef struct _PriNode /** Add node to list tail. */ #define ADDTAIL(l,n) \ do { \ - ASSERT(l); \ - ASSERT(n); \ + ASSERT_VALID_PTR(l); \ + ASSERT_VALID_PTR(n); \ (n)->succ = &(l)->tail; \ (n)->pred = (l)->tail.pred; \ (n)->pred->succ = (n); \ @@ -241,6 +241,8 @@ typedef struct _PriNode */ #define INSERT_BEFORE(n,ln) \ do { \ + ASSERT_VALID_PTR(n); \ + ASSERT_VALID_PTR(ln); \ (n)->succ = (ln); \ (n)->pred = (ln)->pred; \ (ln)->pred->succ = (n); \ @@ -255,6 +257,7 @@ typedef struct _PriNode */ #define REMOVE(n) \ do { \ + ASSERT_VALID_PTR(n); \ (n)->pred->succ = (n)->succ; \ (n)->succ->pred = (n)->pred; \ INVALIDATE_NODE(n); \ @@ -273,6 +276,8 @@ typedef struct _PriNode #define LIST_ENQUEUE(list, node) \ do { \ PriNode *ln; \ + ASSERT_VALID_PTR(list); \ + ASSERT_VALID_PTR(node); \ FOREACH_NODE(ln, (list)) \ if (ln->pri < (node)->pri) \ break; \ @@ -289,6 +294,8 @@ INLINE Node *list_remHead(List *l) { Node *n; + ASSERT_VALID_PTR(l); + if (LIST_EMPTY(l)) return (Node *)0; @@ -309,8 +316,10 @@ INLINE Node *list_remTail(List *l) { Node *n; + ASSERT_VALID_PTR(l); + if (LIST_EMPTY(l)) - return (Node *)0; + return NULL; n = l->tail.pred; /* Get last node. */ l->tail.pred = n->pred; /* Link list tail to second last node. */ -- 2.25.1