]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
stupid compiler checks
authorAlan T. DeKok <aland@freeradius.org>
Fri, 5 May 2017 13:38:46 +0000 (09:38 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 5 May 2017 14:42:08 +0000 (10:42 -0400)
src/lib/io/time.h

index 05431fb785ebb104ebd2820ef089f66533eb5011..7d1d573ef3f98d32e0c98a10a37fbcfd3d3a32c6 100644 (file)
@@ -29,6 +29,7 @@ RCSIDH(time_h, "$Id$")
  *     For sys/time.h and time.h
  */
 #include <freeradius-devel/missing.h>
+#include <freeradius-devel/rad_assert.h>
 #include <stdint.h>
 #include <stdio.h>
 
@@ -84,14 +85,20 @@ typedef struct fr_time_tracking_t {
 #define FR_DLIST_INIT(head) do { head.prev = head.next = &head; } while (0)
 static inline void fr_dlist_insert_head(fr_dlist_t *head, fr_dlist_t *entry)
 {
+       if (!rad_cond_assert(head->next != NULL)) return;
+       if (!rad_cond_assert(head->prev != NULL)) return;
+
        entry->prev = head;
        entry->next = head->next;
-       if (head->next) head->next->prev = entry; /* Head may be the only node in the list */
+       head->next->prev = entry;
        head->next = entry;
 }
 
 static inline void fr_dlist_insert_tail(fr_dlist_t *head, fr_dlist_t *entry)
 {
+       if (!rad_cond_assert(head->next != NULL)) return;
+       if (!rad_cond_assert(head->prev != NULL)) return;
+
        entry->next = head;
        entry->prev = head->prev;
        head->prev->next = entry;
@@ -100,6 +107,9 @@ static inline void fr_dlist_insert_tail(fr_dlist_t *head, fr_dlist_t *entry)
 
 static inline void fr_dlist_remove(fr_dlist_t *entry)
 {
+       if (!rad_cond_assert(entry->next != NULL)) return;
+       if (!rad_cond_assert(entry->prev != NULL)) return;
+
        entry->prev->next = entry->next;
        entry->next->prev = entry->prev;
        entry->prev = entry->next = entry;