diff options
author | Roberto Newmon <robertonewmon@fake-box.com> | 2017-10-29 08:30:02 +0000 |
---|---|---|
committer | Roberto Newmon <robertonewmon@fake-box.com> | 2017-10-29 08:30:02 +0000 |
commit | 3241f09bad7620c83385338d21f0cdc91bca388a (patch) | |
tree | 7c61175efe9bdea6373fa242536210a2b702e9f0 /tests | |
parent | 3f94962533deba3bbfcbcc0d2bf866d1a1972f99 (diff) | |
download | gnutls-3241f09bad7620c83385338d21f0cdc91bca388a.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/str-unicode.c | 16 |
1 files 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"); |