diff options
author | Vincent JARDIN <vincent.jardin@6wind.com> | 2017-10-09 10:51:03 +0200 |
---|---|---|
committer | Vincent JARDIN <vincent.jardin@6wind.com> | 2017-10-09 10:51:03 +0200 |
commit | 67533c11d2069bcf65a08a84e26fba900448f4ea (patch) | |
tree | e17c57ab03cf9fc7760d8c832b58d9229f4e8448 /lib/linklist.h | |
parent | Merge pull request #1307 from vjardin6WIND/clean (diff) | |
download | frr-67533c11d2069bcf65a08a84e26fba900448f4ea.tar.xz frr-67533c11d2069bcf65a08a84e26fba900448f4ea.zip |
lib: linklist avoid access NULL->data
Let's assert(NULL) if the datastructure is not set.
The code assumes that the pointer is always non NULL. So, let's enforce
this semantic.
Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
Diffstat (limited to 'lib/linklist.h')
-rw-r--r-- | lib/linklist.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/linklist.h b/lib/linklist.h index 4a65fead8..8a43fbe64 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -56,7 +56,8 @@ struct list { #define listtail(X) ((X) ? ((X)->tail) : NULL) #define listcount(X) ((X)->count) #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL) -#define listgetdata(X) (assert((X)->data != NULL), (X)->data) +/* return X->data only if X and X->data are not NULL */ +#define listgetdata(X) (assert(X), assert((X)->data != NULL), (X)->data) /* Prototypes. */ extern struct list * |