From 3241f09bad7620c83385338d21f0cdc91bca388a Mon Sep 17 00:00:00 2001 From: Roberto Newmon Date: Sun, 29 Oct 2017 08:30:02 +0000 Subject: Fix non-null warning Help the compiler understand the control flow in the MATCH_FUNC and INVALID_MATCH_FUNC macros. Because we are using macros, the compiler is not able to correlate the replaced values of the macro variables to each other yielding non-null warnings. Introduce a C variable to mimic the macro variable helping the compiler understanding the control flow. --- tests/str-unicode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/str-unicode.c b/tests/str-unicode.c index 5dbf16483a..d9cc37cb6b 100644 --- a/tests/str-unicode.c +++ b/tests/str-unicode.c @@ -34,31 +34,31 @@ #define MATCH_FUNC(fname, password, normalized) \ static void fname(void **glob_state) \ { \ + const char *pwd_normalized = normalized; \ gnutls_datum_t out; \ int ret = gnutls_utf8_password_normalize((uint8_t*)password, strlen(password), &out, 0); \ - if (normalized == NULL) { /* expect failure */ \ + if (pwd_normalized == NULL) { /* expect failure */ \ assert_int_not_equal(ret, 0); \ - return; \ } else { \ assert_int_equal(ret, 0); \ + assert_int_equal(strcmp((char*)out.data, (char*)pwd_normalized), 0); \ + gnutls_free(out.data); \ } \ - assert_int_equal(strcmp((char*)out.data, (char*)normalized), 0); \ - gnutls_free(out.data); \ } #define INVALID_MATCH_FUNC(fname, password, normalized) \ static void inv_##fname(void **glob_state) \ { \ + const char *pwd_normalized = normalized; \ gnutls_datum_t out; \ int ret = gnutls_utf8_password_normalize((uint8_t*)password, strlen(password), &out, GNUTLS_UTF8_IGNORE_ERRS); \ - if (normalized == NULL) { \ + if (pwd_normalized == NULL) { \ assert_int_not_equal(ret, 0); \ - return; \ } else { \ assert_int_equal(ret, 0); \ + assert_int_equal(strcmp((char*)out.data, (char*)pwd_normalized), 0); \ + gnutls_free(out.data); \ } \ - assert_int_equal(strcmp((char*)out.data, (char*)normalized), 0); \ - gnutls_free(out.data); \ } MATCH_FUNC(test_ascii, "correct horse battery staple", "correct horse battery staple"); -- cgit v1.2.1