[SSSD] [PATCH] Suppress warning maybe-uninitialized

Lukas Slebodnik lslebodn at redhat.com
Thu Oct 2 17:33:02 UTC 2014


ehlo,

There is a warning with some version of gcc (4.9.1, 4.4.7).
Warning is not visible with gcc 4.8
In my opinion, variable "a" should be initialized every time if
"maps" is not NULL.

src/providers/ldap/sdap.c: In function 'sdap_parse_entry':
src/providers/ldap/sdap.c:481:56: warning: 'a' may be used uninitialized in
                                  this function [-Wmaybe-uninitialized]
                         for (ai = a; ai < attrs_num; ai++) {
                                                        ^
src/providers/ldap/sdap.c:307:9: note: 'a' was declared here
     int a, i, ret, ai;
         ^
  CCLD     libsss_ldap_common.la


You can also see warnin in koji build on fedora 21
https://kojipkgs.fedoraproject.org//packages/sssd/1.12.1/2.fc21/data/logs/x86_64/build.log
If you have better idea how to fix this warning I will be glad to review your
patch.

LS
-------------- next part --------------
>From b3fc90931ca25849d5be4865f8a2d686872872b0 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 2 Oct 2014 16:37:14 +0200
Subject: [PATCH] Suppress warning maybe-uninitialized

There is a warning with some version of gcc (4.9.1, 4.4.7).
In my opinion, variable "a" should be initialized every time if
"maps" is not NULL.

src/providers/ldap/sdap.c: In function 'sdap_parse_entry':
src/providers/ldap/sdap.c:481:56: warning: 'a' may be used uninitialized in
                                  this function [-Wmaybe-uninitialized]
                         for (ai = a; ai < attrs_num; ai++) {
                                                        ^
src/providers/ldap/sdap.c:307:9: note: 'a' was declared here
     int a, i, ret, ai;
         ^
  CCLD     libsss_ldap_common.la
---
 src/providers/ldap/sdap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index 7034b11ed8e3aabdcff94462079484dd3ca53ef9..1643a609013646a79ba5e5c96de7b573edf384fc 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -304,7 +304,8 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
     struct ldb_val v;
     char *str;
     int lerrno;
-    int a, i, ret, ai;
+    int i, ret, ai;
+    volatile int a;
     const char *name;
     bool store;
     bool base64;
-- 
2.1.0



More information about the sssd-devel mailing list