]> git.puffer.fish Git - mirror/frr.git/commitdiff
[lib/linklist] Enforce "nodes must have data" invariant more rigorously
authorPaul Jakma <paul.jakma@sun.com>
Thu, 28 Feb 2008 00:09:04 +0000 (00:09 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Thu, 28 Feb 2008 00:09:04 +0000 (00:09 +0000)
2008-02-28 Paul Jakma <paul.jakma@sun.com>

* linklist.c: This implementation expects that the data pointer not
  be null, e.g. listgetdata() asserts this. The list add methods
  don't apply the same sanity check.

  Noted by Jim Carlson in bug #437.

lib/ChangeLog
lib/linklist.c

index 2263c03cccdc26323f5ac754724f6c0e49740ec7..613a6fcb6dcb4726dcca042627fc6bafb68b3085 100644 (file)
@@ -1,3 +1,11 @@
+2008-02-28 Paul Jakma <paul.jakma@sun.com>
+
+       * linklist.c: This implementation expects that the data pointer not
+         be null, e.g. listgetdata() asserts this. The list add methods
+         don't apply the same sanity check.
+
+         Noted by Jim Carlson in bug #437.
+
 2008-01-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
        * zebra.h: Revert previous change, no need to include <net/if_media.h>
index 983da2d155b637a71ae8b408a117bfa19d8b6568..a16e9e189d4e66c2cb6a48678afdd891dff4b932 100644 (file)
@@ -65,7 +65,9 @@ void
 listnode_add (struct list *list, void *val)
 {
   struct listnode *node;
-
+  
+  assert (val != NULL);
+  
   node = listnode_new ();
 
   node->prev = list->tail;
@@ -91,7 +93,9 @@ listnode_add_sort (struct list *list, void *val)
 {
   struct listnode *n;
   struct listnode *new;
-
+  
+  assert (val != NULL);
+  
   new = listnode_new ();
   new->data = val;
 
@@ -130,7 +134,9 @@ void
 listnode_add_after (struct list *list, struct listnode *pp, void *val)
 {
   struct listnode *nn;
-
+  
+  assert (val != NULL);
+  
   nn = listnode_new ();
   nn->data = val;
 
@@ -266,7 +272,9 @@ void
 list_add_node_prev (struct list *list, struct listnode *current, void *val)
 {
   struct listnode *node;
-
+  
+  assert (val != NULL);
+  
   node = listnode_new ();
   node->next = current;
   node->data = val;
@@ -287,7 +295,9 @@ void
 list_add_node_next (struct list *list, struct listnode *current, void *val)
 {
   struct listnode *node;
-
+  
+  assert (val != NULL);
+  
   node = listnode_new ();
   node->prev = current;
   node->data = val;