]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: get rid of the TEST_strn2_ functions
authorPauli <paul.dale@oracle.com>
Tue, 13 Jan 2026 21:13:52 +0000 (08:13 +1100)
committerPauli <paul.dale@oracle.com>
Thu, 15 Jan 2026 21:31:20 +0000 (08:31 +1100)
Their semantics are poorly defined and they are rarely used.  The _ne
version being completely unused & tricky to define properly.

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/29627)

test/testutil.h
test/testutil/tests.c

index b79ebd6914a1669ce96966c03c109e55a58a10d4..de4023f761e6ac1a528def3cf94429a36469ffd6 100644 (file)
@@ -355,9 +355,9 @@ DECLARE_COMPARISON(char *, str, ne)
  * Same as above, but for strncmp.
  */
 int test_strn_eq(const char *file, int line, const char *, const char *,
-    const char *a, size_t an, const char *b, size_t bn);
+    const char *a, const char *b, size_t n);
 int test_strn_ne(const char *file, int line, const char *, const char *,
-    const char *a, size_t an, const char *b, size_t bn);
+    const char *a, const char *b, size_t n);
 
 /*
  * Equality test for memory blocks where NULL is a legitimate value.
@@ -511,10 +511,8 @@ void test_perror(const char *s);
 
 #define TEST_str_eq(a, b) test_str_eq(__FILE__, __LINE__, #a, #b, a, b)
 #define TEST_str_ne(a, b) test_str_ne(__FILE__, __LINE__, #a, #b, a, b)
-#define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, n, b, n)
-#define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, n, b, n)
-#define TEST_strn2_eq(a, m, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
-#define TEST_strn2_ne(a, m, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
+#define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, b, n)
+#define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, b, n)
 
 #define TEST_mem_eq(a, m, b, n) test_mem_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
 #define TEST_mem_ne(a, m, b, n) test_mem_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
index f67b5ce4bfa792ac96639b8d7062af110670b3d5..ee83f8a4a96438f137214b8543940c6c9c47536c 100644 (file)
@@ -302,28 +302,28 @@ int test_str_ne(const char *file, int line, const char *st1, const char *st2,
 }
 
 int test_strn_eq(const char *file, int line, const char *st1, const char *st2,
-    const char *s1, size_t n1, const char *s2, size_t n2)
+    const char *s1, const char *s2, size_t n)
 {
     if (s1 == NULL && s2 == NULL)
         return 1;
-    if (n1 != n2 || s1 == NULL || s2 == NULL || strncmp(s1, s2, n1) != 0) {
+    if (s1 == NULL || s2 == NULL || strncmp(s1, s2, n) != 0) {
         test_fail_string_message(NULL, file, line, "string", st1, st2, "==",
-            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
-            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
+            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n),
+            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n));
         return 0;
     }
     return 1;
 }
 
 int test_strn_ne(const char *file, int line, const char *st1, const char *st2,
-    const char *s1, size_t n1, const char *s2, size_t n2)
+    const char *s1, const char *s2, size_t n)
 {
     if ((s1 == NULL) ^ (s2 == NULL))
         return 1;
-    if (n1 != n2 || s1 == NULL || strncmp(s1, s2, n1) == 0) {
+    if (s1 == NULL || strncmp(s1, s2, n) == 0) {
         test_fail_string_message(NULL, file, line, "string", st1, st2, "!=",
-            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
-            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
+            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n),
+            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n));
         return 0;
     }
     return 1;