[SSSD] [PATCH] krb5: fix warning variable may be used uninitialized

Lukas Slebodnik lslebodn at redhat.com
Thu Oct 10 10:09:17 UTC 2013


ehlo,

scan-build found a warning.

src/providers/krb5/krb5_child.c:1988:9: error: ‘offline’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
     ret = k5c_setup(kr, offline);

gcc also reports this warning with enabled optimization >= "-O2".

It seems to me really weird, because compilator assumes that function
sss_atomic_read_s return value -1 and errno==0.
I tried to modify function sss_atomic_read_s, but I could not fix this warning.

Another possible solution is to initialize variable "offline" to some default
value.

I appreciate any comment.

Patch is attached.

LS
-------------- next part --------------
>From 697ddf41f413db41c011e6aa6f139bff2976073e Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 10 Oct 2013 11:25:28 +0200
Subject: [PATCH] krb5: fix warning may be used uninitialized

Resolves:
https://fedorahosted.org/sssd/ticket/2112
---
 src/providers/krb5/krb5_child.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index 16ab4dbbbdd12650adcbfb60f856e66c0e6077a7..24a1fe1badd682bd9017ee14a5210d6dcacb8376 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -1675,6 +1675,7 @@ static errno_t k5c_recv_data(struct krb5_req *kr, int fd, uint32_t *offline)
     len = sss_atomic_read_s(fd, buf, IN_BUF_SIZE);
     if (len == -1) {
         ret = errno;
+        ret = (ret == 0) ? EINVAL: ret;
         DEBUG(SSSDBG_CRIT_FAILURE,
               ("read failed [%d][%s].\n", ret, strerror(ret)));
         return ret;
-- 
1.8.3.1



More information about the sssd-devel mailing list