[SSSD] [PATCH] TESTS: Fix authtok test for zero length string.

Lukas Slebodnik lslebodn at redhat.com
Tue Jan 21 08:48:51 UTC 2014


ehlo,

I have one error with current master (I compile with -Werror)

src/tests/cmocka/test_authtok.c:207:48: error: expression which evaluates
to zero treated as a null pointer constant of type 'const uint8_t *'
      [-Werror,-Wnon-literal-null-conversion]
    ret = sss_authtok_set(ts->authtoken, type, '\0', 0);
                                               ^~~~
1 error generated.o

I had an discussion with Pallavi Jha on IRC yesterday and this test should
test empty string(zero length string). Test fof NULL is few lines befor this
test.

Patch is attached.

LS
-------------- next part --------------
>From b816d11745223eaa99c28dd40101c40119fa9357 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Mon, 20 Jan 2014 21:23:19 +0100
Subject: [PATCH] TESTS: Fix authtok test for zero length string.

There is a test for sss_authtok_set where '\0' is used as argument data.
'\0' is evaluated as zero and zero is treated as a null pointer.
And there is another test for NULL pointer few lines before.
Patch changes 3rd argument  '\0' into properly cast zero length sting ""
---
 src/tests/cmocka/test_authtok.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tests/cmocka/test_authtok.c b/src/tests/cmocka/test_authtok.c
index c4e394cf8386ada04acc818f3ecf856f29333e2f..50205cc33e9b64cdf4537c6adbe54370b1f3de3b 100644
--- a/src/tests/cmocka/test_authtok.c
+++ b/src/tests/cmocka/test_authtok.c
@@ -204,7 +204,7 @@ static void test_sss_authtok_empty(void **state)
     assert_int_equal(0, sss_authtok_get_size(ts->authtoken));
     assert_null(sss_authtok_get_data(ts->authtoken));
 
-    ret = sss_authtok_set(ts->authtoken, type, '\0', 0);
+    ret = sss_authtok_set(ts->authtoken, type, (const uint8_t*)"", 0);
     assert_int_equal(ret, EOK);
 
     assert_int_equal(type, sss_authtok_get_type(ts->authtoken));
-- 
1.8.4.2



More information about the sssd-devel mailing list