]> jfr.im git - solanum.git/blobdiff - libratbox/src/patricia.c
Spring cleaning redux:
[solanum.git] / libratbox / src / patricia.c
index 33484f8f9a354bc73865421dcc1892fa97d31a1e..cf0dd31e5700ea53c42e23771ce8e1a2b300c273 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Yanked out of Net::Patricia by Aaron Sethman <androsyn@ratbox.org>
- * 
+ *
  * This was then yanked out of the ratbox/devel/src tree and stuffed into
  * libratbox and had function names changed, but otherwise not really altered.
  *
@@ -8,7 +8,7 @@
  * Dave Plonka <plonka@doit.wisc.edu>
  *
  * This product includes software developed by the University of Michigan,
- * Merit Network, Inc., and their contributors. 
+ * Merit Network, Inc., and their contributors.
  *
  * This file had been called "radix.c" in the MRT sources.
  *
@@ -72,7 +72,7 @@ prefix_toa2x(rb_prefix_t *prefix, char *buf, int buf_len, int with_len)
        static char tmp[6];
        if(prefix == NULL)
        {
-               strcpy(buf, "(NULL)");
+               rb_strlcpy(buf, "(NULL)", buf_len);
                return (buf);
        }
        inet_ntop(prefix->family, &prefix->add.sin, buf, buf_len);
@@ -263,7 +263,7 @@ Deref_Prefix(rb_prefix_t *prefix)
 
 /* } */
 
-// #define PATRICIA_DEBUG 1 
+// #define PATRICIA_DEBUG 1
 
 static int num_active_patricia = 0;
 
@@ -399,7 +399,7 @@ rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
                                        prefix_toa(node->prefix), node->prefix->bitlen);
                        else
                                fprintf(stderr,
-                                       "patricia_search_exact: take right at %d\n", node->bit);
+                                       "patricia_search_exact: take right at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
                        node = node->r;
                }
@@ -412,7 +412,7 @@ rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
                                        prefix_toa(node->prefix), node->prefix->bitlen);
                        else
                                fprintf(stderr,
-                                       "patricia_search_exact: take left at %d\n", node->bit);
+                                       "patricia_search_exact: take left at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
                        node = node->l;
                }
@@ -423,10 +423,10 @@ rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
 
 #ifdef PATRICIA_DEBUG
        if(node->prefix)
-               fprintf(stderr, "patricia_search_exact: stop at %s/%d %d\n",
+               fprintf(stderr, "patricia_search_exact: stop at %s/%d %u\n",
                        prefix_toa(node->prefix), node->prefix->bitlen, node->bit);
        else
-               fprintf(stderr, "patricia_search_exact: stop at %d\n", node->bit);
+               fprintf(stderr, "patricia_search_exact: stop at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
        if(node->bit > bitlen || node->prefix == NULL)
                return (NULL);
@@ -486,7 +486,7 @@ rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int
                                        prefix_toa(node->prefix), node->prefix->bitlen);
                        else
                                fprintf(stderr,
-                                       "patricia_search_best: take right at %d\n", node->bit);
+                                       "patricia_search_best: take right at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
                        node = node->r;
                }
@@ -499,7 +499,7 @@ rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int
                                        prefix_toa(node->prefix), node->prefix->bitlen);
                        else
                                fprintf(stderr,
-                                       "patricia_search_best: take left at %d\n", node->bit);
+                                       "patricia_search_best: take left at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
                        node = node->l;
                }
@@ -518,7 +518,7 @@ rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int
                fprintf(stderr, "patricia_search_best: stop at %s/%d\n",
                        prefix_toa(node->prefix), node->prefix->bitlen);
        else
-               fprintf(stderr, "patricia_search_best: stop at %d\n", node->bit);
+               fprintf(stderr, "patricia_search_best: stop at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
 
        if(cnt <= 0)
@@ -601,7 +601,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
                                        "patricia_lookup: take right %s/%d\n",
                                        prefix_toa(node->prefix), node->prefix->bitlen);
                        else
-                               fprintf(stderr, "patricia_lookup: take right at %d\n", node->bit);
+                               fprintf(stderr, "patricia_lookup: take right at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
                        node = node->r;
                }
@@ -615,7 +615,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
                                        "patricia_lookup: take left %s/%d\n",
                                        prefix_toa(node->prefix), node->prefix->bitlen);
                        else
-                               fprintf(stderr, "patricia_lookup: take left at %d\n", node->bit);
+                               fprintf(stderr, "patricia_lookup: take left at %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
                        node = node->l;
                }
@@ -654,7 +654,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
        if(differ_bit > check_bit)
                differ_bit = check_bit;
 #ifdef PATRICIA_DEBUG
-       fprintf(stderr, "patricia_lookup: differ_bit %d\n", differ_bit);
+       fprintf(stderr, "patricia_lookup: differ_bit %u\n", differ_bit);
 #endif /* PATRICIA_DEBUG */
 
        parent = node->parent;
@@ -667,7 +667,7 @@ rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
                        fprintf(stderr, "patricia_lookup: up to %s/%d\n",
                                prefix_toa(node->prefix), node->prefix->bitlen);
                else
-                       fprintf(stderr, "patricia_lookup: up to %d\n", node->bit);
+                       fprintf(stderr, "patricia_lookup: up to %u\n", node->bit);
 #endif /* PATRICIA_DEBUG */
        }