[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Remove strcmp_len(): it is now unused



commit 29254812a3428da4ffeaede5d211364d942f94ab
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Dec 17 09:04:25 2018 -0500

    Remove strcmp_len(): it is now unused
    
    (See 28856.)
---
 src/lib/string/util_string.c | 15 ---------------
 src/lib/string/util_string.h |  1 -
 src/test/test_util.c         |  9 ---------
 3 files changed, 25 deletions(-)

diff --git a/src/lib/string/util_string.c b/src/lib/string/util_string.c
index e76e73046..36e19d029 100644
--- a/src/lib/string/util_string.c
+++ b/src/lib/string/util_string.c
@@ -212,21 +212,6 @@ strcmpstart(const char *s1, const char *s2)
   return strncmp(s1, s2, n);
 }
 
-/** Compare the s1_len-byte string <b>s1</b> with <b>s2</b>,
- * without depending on a terminating nul in s1.  Sorting order is first by
- * length, then lexically; return values are as for strcmp.
- */
-int
-strcmp_len(const char *s1, const char *s2, size_t s1_len)
-{
-  size_t s2_len = strlen(s2);
-  if (s1_len < s2_len)
-    return -1;
-  if (s1_len > s2_len)
-    return 1;
-  return fast_memcmp(s1, s2, s2_len);
-}
-
 /** Compares the first strlen(s2) characters of s1 with s2.  Returns as for
  * strcasecmp.
  */
diff --git a/src/lib/string/util_string.h b/src/lib/string/util_string.h
index 99467a27c..6541afa4c 100644
--- a/src/lib/string/util_string.h
+++ b/src/lib/string/util_string.h
@@ -33,7 +33,6 @@ int tor_strisnonupper(const char *s);
 int tor_strisspace(const char *s);
 int strcmp_opt(const char *s1, const char *s2);
 int strcmpstart(const char *s1, const char *s2);
-int strcmp_len(const char *s1, const char *s2, size_t len);
 int strcasecmpstart(const char *s1, const char *s2);
 int strcmpend(const char *s1, const char *s2);
 int strcasecmpend(const char *s1, const char *s2);
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 2b4d64e42..7ac1a1ec4 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2153,15 +2153,6 @@ test_util_strmisc(void *arg)
   tt_int_op(strcmp_opt(NULL,  "foo"), OP_LT, 0);
   tt_int_op(strcmp_opt("foo", NULL),  OP_GT, 0);
 
-  /* Test strcmp_len */
-  tt_int_op(strcmp_len("foo", "bar", 3),   OP_GT, 0);
-  tt_int_op(strcmp_len("foo", "bar", 2),   OP_LT, 0);
-  tt_int_op(strcmp_len("foo2", "foo1", 4), OP_GT, 0);
-  tt_int_op(strcmp_len("foo2", "foo1", 3), OP_LT, 0); /* Really stop at len */
-  tt_int_op(strcmp_len("foo2", "foo", 3), OP_EQ, 0);  /* Really stop at len */
-  tt_int_op(strcmp_len("blah", "", 4),     OP_GT, 0);
-  tt_int_op(strcmp_len("blah", "", 0),    OP_EQ, 0);
-
  done:
   tor_free(cp_tmp);
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits