-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/27/2010 01:19 PM, Stephen Gallagher wrote:
> On 04/27/2010 05:25 AM, Jakub Hrozek wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> I noticed there were some warnings when compiling with the default
>> Fedora CFLAGS.
> 
> 
> I don't see any warnings when building on Fedora 13 with the default 
> CFLAGS. Could you please identify the warnings you're trying to fix>
> 

I get these on F12, x86_64 (CFLAGS and configure switches as returned by
rpm -E '%configure'):

- ---
providers/ldap/sdap_async_accounts.c: In function ‘sdap_save_user’:
providers/ldap/sdap_async_accounts.c:40: warning: ‘name’ may be used
uninitialized in this function
providers/proxy.c: In function ‘get_pw_uid’:
providers/proxy.c:417: warning: ‘status’ may be used uninitialized in
this function
providers/proxy.c: In function ‘get_gr_name’:
providers/proxy.c:672: warning: ‘status’ may be used uninitialized in
this function
providers/proxy.c: In function ‘get_gr_gid’:
providers/proxy.c:820: warning: ‘status’ may be used uninitialized in
this function
providers/ldap/sdap_async_accounts.c: In function ‘sdap_save_user’:
providers/ldap/sdap_async_accounts.c:40: warning: ‘name’ may be used
uninitialized in this function
tools/sss_sync_ops.c: In function ‘groupmod’:
tools/sss_sync_ops.c:262: warning: ‘member_dn’ may be used uninitialized
in this function
tools/sss_sync_ops.c: In function ‘usermod’:
tools/sss_sync_ops.c:202: warning: ‘member_dn’ may be used uninitialized
in this function
tools/sss_sync_ops.c:201: warning: ‘attrs’ may be used uninitialized in
this function
- ---

I think the ones in sss_sync_ops are spurious, but the others are legit.

> Also, you're changing functionality here. For example, in 
> sdap_save_user(), by removing the 'goto fail' lines, we will no longer 
> print a DEBUG message on failure.
> 

Ah, correct, especially in the sdap_save_user() case it would be confusing.

A new patch is attached.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkvW1CwACgkQHsardTLnvCXEFwCfaUOwrWI1+8WJwGC67QKbxECz
xF8AniLpdjlZL+a/b/zYBlTRwvozsAcq
=l0kk
-----END PGP SIGNATURE-----
From c1ee4880741ffdcdfe046477b455052cc5385bc4 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Mon, 26 Apr 2010 23:36:24 +0200
Subject: [PATCH] Silence warnings with -O2

---
 src/providers/ldap/sdap_async_accounts.c |    6 ++++--
 src/providers/proxy.c                    |   24 ++++++++++++++++++------
 src/tools/sss_sync_ops.c                 |    8 ++++----
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c
index bdaa9e9..f949e46 100644
--- a/src/providers/ldap/sdap_async_accounts.c
+++ b/src/providers/ldap/sdap_async_accounts.c
@@ -56,10 +56,12 @@ static int sdap_save_user(TALLOC_CTX *memctx,
 
     ret = sysdb_attrs_get_el(attrs,
                              opts->user_map[SDAP_AT_USER_NAME].sys_name, &el);
-    if (ret) goto fail;
     if (el->num_values == 0) {
         ret = EINVAL;
-        goto fail;
+    }
+    if (ret) {
+        DEBUG(1, ("Failed to save the user - entry has no name attribute\n"));
+        return ret;
     }
     name = (const char *)el->values[0].data;
 
diff --git a/src/providers/proxy.c b/src/providers/proxy.c
index 4da89cc..c7aef30 100644
--- a/src/providers/proxy.c
+++ b/src/providers/proxy.c
@@ -430,14 +430,18 @@ static int get_pw_uid(TALLOC_CTX *mem_ctx,
     pwd = talloc_zero(tmpctx, struct passwd);
     if (!pwd) {
         ret = ENOMEM;
-        goto done;
+        DEBUG(1, ("proxy -> getpwuid_r failed for '%d': [%d] %s\n",
+                  uid, ret, strerror(ret)));
+        return ret;
     }
 
     buflen = DEFAULT_BUFSIZE;
     buffer = talloc_size(tmpctx, buflen);
     if (!buffer) {
         ret = ENOMEM;
-        goto done;
+        DEBUG(1, ("proxy -> getpwuid_r failed for '%d': [%d] %s\n",
+                  uid, ret, strerror(ret)));
+        return ret;
     }
 
     status = ctx->ops.getpwuid_r(uid, pwd, buffer, buflen, &ret);
@@ -687,14 +691,18 @@ static int get_gr_name(TALLOC_CTX *mem_ctx,
     grp = talloc(tmpctx, struct group);
     if (!grp) {
         ret = ENOMEM;
-        goto done;
+        DEBUG(1, ("proxy -> getgrnam_r failed for '%s': [%d] %s\n",
+                  name, ret, strerror(ret)));
+        return ret;
     }
 
     buflen = DEFAULT_BUFSIZE;
     buffer = talloc_size(tmpctx, buflen);
     if (!buffer) {
         ret = ENOMEM;
-        goto done;
+        DEBUG(1, ("proxy -> getgrnam_r failed for '%s': [%d] %s\n",
+                  name, ret, strerror(ret)));
+        return ret;
     }
 
     /* FIXME: should we move this call outside the transaction to keep the
@@ -835,14 +843,18 @@ static int get_gr_gid(TALLOC_CTX *mem_ctx,
     grp = talloc(tmpctx, struct group);
     if (!grp) {
         ret = ENOMEM;
-        goto done;
+        DEBUG(1, ("proxy -> getgrgid_r failed for '%d': [%d] %s\n",
+                  gid, ret, strerror(ret)));
+        return ret;
     }
 
     buflen = DEFAULT_BUFSIZE;
     buffer = talloc_size(tmpctx, buflen);
     if (!buffer) {
         ret = ENOMEM;
-        goto done;
+        DEBUG(1, ("proxy -> getgrgid_r failed for '%d': [%d] %s\n",
+                  gid, ret, strerror(ret)));
+        return ret;
     }
 
 again:
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index 45fd573..a92f8ca 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -198,8 +198,8 @@ int usermod(TALLOC_CTX *mem_ctx,
             struct sysdb_ctx *sysdb,
             struct ops_ctx *data)
 {
-    struct sysdb_attrs *attrs;
-    struct ldb_dn *member_dn;
+    struct sysdb_attrs *attrs = NULL;
+    struct ldb_dn *member_dn = NULL;
     int ret;
 
     if (data->addgroups || data->rmgroups) {
@@ -258,8 +258,8 @@ int groupmod(TALLOC_CTX *mem_ctx,
              struct sysdb_ctx *sysdb,
              struct ops_ctx *data)
 {
-    struct sysdb_attrs *attrs;
-    struct ldb_dn *member_dn;
+    struct sysdb_attrs *attrs = NULL;
+    struct ldb_dn *member_dn = NULL;
     int ret;
 
     if (data->addgroups || data->rmgroups) {
-- 
1.6.6.1

Attachment: 0001-Silence-warnings-with-O2.patch.sig
Description: PGP signature

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to