[SSSD] [PATCH] util-tests: Initialize boolean variable to default value

Jakub Hrozek jhrozek at redhat.com
Wed Apr 8 09:18:31 UTC 2015


On Wed, Apr 08, 2015 at 11:10:42AM +0200, Pavel Reichl wrote:
> On 04/07/2015 04:33 PM, Lukas Slebodnik wrote:
> >ehlo,
> >
> >The boolean variable found_nss could be used uninitialized
> >in test test_known_service if service "nss" would not be found.
> >We would catch it with valgind.
> >
> >Simple patch is attached.
> >
> >LS
> >
> >
> >_______________________________________________
> >sssd-devel mailing list
> >sssd-devel at lists.fedorahosted.org
> >https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
> Obvious ACK, ci passed:
> 
> http://sssd-ci.duckdns.org/logs/job/12/60/summary.html
> 

I think we should also commit the attached one-liner because the
condition in the test is wrong.
-------------- next part --------------
>From 840bfdb115d326ef3b3134c3dbf4a9df73b93be9 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 8 Apr 2015 11:17:44 +0200
Subject: [PATCH] tests: Revert strcmp condition

---
 src/tests/util-tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c
index 1cff0bb678ad60f857b28927a8f5a21df4f557d1..7270887377bf05d2a3387b7f4e459ac1678e233d 100644
--- a/src/tests/util-tests.c
+++ b/src/tests/util-tests.c
@@ -1013,7 +1013,7 @@ START_TEST(test_known_service)
     svcs = get_known_services();
     for (i = 0; svcs[i]; i++) {
         ck_assert_str_ne(svcs[i], "nosuchservice");
-        if (strcmp(svcs[i], "nss")) {
+        if (strcmp(svcs[i], "nss") == 0) {
             found_nss = true;
         }
     }
-- 
2.1.0



More information about the sssd-devel mailing list