diff options
| author | Pauli <[email protected]> | 2026-01-13 22:13:52 +0100 |
|---|---|---|
| committer | Pauli <[email protected]> | 2026-01-15 22:31:20 +0100 |
| commit | b79ec4cb221dbc5b5fdee2db0dc8fd2aa8d2306f (patch) | |
| tree | 658a7914acaba859b39d05cb049afc91c2fb3582 | |
| parent | Fix search pattern in check-news-changes CI job (diff) | |
| download | openssl-b79ec4cb221dbc5b5fdee2db0dc8fd2aa8d2306f.tar.gz openssl-b79ec4cb221dbc5b5fdee2db0dc8fd2aa8d2306f.zip | |
test: get rid of the TEST_strn2_ functions
Their semantics are poorly defined and they are rarely used. The _ne
version being completely unused & tricky to define properly.
Reviewed-by: Norbert Pocs <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Frederik Wedel-Heinen <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29627)
| -rw-r--r-- | test/testutil.h | 10 | ||||
| -rw-r--r-- | test/testutil/tests.c | 16 |
2 files changed, 12 insertions, 14 deletions
diff --git a/test/testutil.h b/test/testutil.h index b79ebd6914a..de4023f761e 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -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) diff --git a/test/testutil/tests.c b/test/testutil/tests.c index f67b5ce4bfa..ee83f8a4a96 100644 --- a/test/testutil/tests.c +++ b/test/testutil/tests.c @@ -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; |
