[SSSD] [PATCH] Suppress some compiler warnings

Sumit Bose sbose at redhat.com
Fri Sep 24 12:03:40 UTC 2010


On Fri, Sep 24, 2010 at 07:20:02AM -0400, Stephen Gallagher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 09/24/2010 05:32 AM, Sumit Bose wrote:
> > Hi,
> > 
> > some of the compiler flags used to build Fedora packages, e.g.
> > '-Wp,-D_FORTIFY_SOURCE=2' produces some extra warnings which were not
> > addressed so far. Except the ones for krb5_common.c in 0001 they are
> > cosmetics but might still irritate some people or tools.
> > 
> 
> Nack.
> 
> If you're going to address the warning in write_krb5info_file(), would
> you mind solving ALL of https://fedorahosted.org/sssd/ticket/631 in the
> process?

sure, new versions attached.

bye,
Sumit

> 
> - -- 
> Stephen Gallagher
> RHCE 804006346421761
> 
> Delivering value year after year.
> Red Hat ranks #1 in value among software vendors.
> http://www.redhat.com/promo/vendor/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAkyciWEACgkQeiVVYja6o6MvfQCfbG92pu/PrOI6P1kOTG49ctR4
> lZQAnA7ouxRoJP9sim9w2Cy6Sk9RSH30
> =EoTO
> -----END PGP SIGNATURE-----
> _______________________________________________
> sssd-devel mailing list
> sssd-devel at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/sssd-devel
-------------- next part --------------
From f1412479d5e032ffc3bda8316db4be47404bd19f Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Fri, 24 Sep 2010 09:54:45 +0200
Subject: [PATCH 1/2] Suppress some 'may be used uninitialized' warnings

Additionally the handling of errno and the errno_t return value of
functions is fixed in krb5_common.c.
---
 src/providers/krb5/krb5_common.c |   18 ++++++++++++------
 src/providers/ldap/sdap_access.c |    2 +-
 src/providers/proxy/proxy_auth.c |    2 +-
 src/tests/auth-tests.c           |    2 +-
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index e5471e3..d41fdb9 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -172,8 +172,8 @@ errno_t write_krb5info_file(const char *realm, const char *server,
 
     fd = mkstemp(tmp_name);
     if (fd == -1) {
-        DEBUG(1, ("mkstemp failed [%d][%s].\n", errno, strerror(errno)));
         ret = errno;
+        DEBUG(1, ("mkstemp failed [%d][%s].\n", ret, strerror(ret)));
         goto done;
     }
 
@@ -184,7 +184,8 @@ errno_t write_krb5info_file(const char *realm, const char *server,
             if (errno == EINTR || errno == EAGAIN) {
                 continue;
             }
-            DEBUG(1, ("write failed [%d][%s].\n", errno, strerror(errno)));
+            ret = errno;
+            DEBUG(1, ("write failed [%d][%s].\n", ret, strerror(ret)));
             goto done;
         }
         else {
@@ -195,24 +196,28 @@ errno_t write_krb5info_file(const char *realm, const char *server,
     if (written != server_len) {
         DEBUG(1, ("Write error, wrote [%d] bytes, expected [%d]\n",
                    written, server_len));
+        ret = EIO;
         goto done;
     }
 
     ret = fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
     if (ret == -1) {
-        DEBUG(1, ("fchmod failed [%d][%s].\n", errno, strerror(errno)));
+        ret = errno;
+        DEBUG(1, ("fchmod failed [%d][%s].\n", ret, strerror(ret)));
         goto done;
     }
 
     ret = close(fd);
     if (ret == -1) {
-        DEBUG(1, ("close failed [%d][%s].\n", errno, strerror(errno)));
+        ret = errno;
+        DEBUG(1, ("close failed [%d][%s].\n", ret, strerror(ret)));
         goto done;
     }
 
     ret = rename(tmp_name, krb5info_name);
     if (ret == -1) {
-        DEBUG(1, ("rename failed [%d][%s].\n", errno, strerror(errno)));
+        ret = errno;
+        DEBUG(1, ("rename failed [%d][%s].\n", ret, strerror(ret)));
         goto done;
     }
 
@@ -249,7 +254,8 @@ static void krb5_resolve_callback(void *private_data, struct fo_server *server)
 
     if (inet_ntop(srvaddr->h_addrtype, srvaddr->h_addr_list[0],
                   address, 128) == NULL) {
-        DEBUG(1, ("inet_ntop failed [%d][%s].\n", errno, strerror(errno)));
+        ret = errno;
+        DEBUG(1, ("inet_ntop failed [%d][%s].\n", ret, strerror(ret)));
         return;
     }
 
diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c
index 90b5371..4a30b74 100644
--- a/src/providers/ldap/sdap_access.c
+++ b/src/providers/ldap/sdap_access.c
@@ -452,7 +452,7 @@ static errno_t sdap_access_recv(struct tevent_req *req, int *pam_status)
 static void sdap_access_done(struct tevent_req *req)
 {
     errno_t ret;
-    int pam_status;
+    int pam_status = PAM_SYSTEM_ERR;
     struct be_req *breq =
             tevent_req_callback_data(req, struct be_req);
 
diff --git a/src/providers/proxy/proxy_auth.c b/src/providers/proxy/proxy_auth.c
index a78de31..64b38cb 100644
--- a/src/providers/proxy/proxy_auth.c
+++ b/src/providers/proxy/proxy_auth.c
@@ -711,7 +711,7 @@ static void proxy_child_done(struct tevent_req *req)
 {
     struct proxy_client_ctx *client_ctx =
             tevent_req_callback_data(req, struct proxy_client_ctx);
-    struct pam_data *pd;
+    struct pam_data *pd = NULL;
     char *password;
     int ret;
     struct tevent_immediate *imm;
diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c
index a3de43c..bae0794 100644
--- a/src/tests/auth-tests.c
+++ b/src/tests/auth-tests.c
@@ -161,7 +161,7 @@ static void do_failed_login_test(uint32_t failed_login_attempts,
                                  int expected_counter,
                                  time_t expected_delay)
 {
-    struct sysdb_test_ctx *test_ctx;
+    struct sysdb_test_ctx *test_ctx = NULL;
     int ret;
     const char *val[2];
     val[1] = NULL;
-- 
1.7.2.3

-------------- next part --------------
From 6186880287168f09f85f46f780de88c3fd5dd4f2 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Fri, 24 Sep 2010 10:31:22 +0200
Subject: [PATCH 2/2] Suppress some 'unchecked return value' warnings

---
 src/tests/files-tests.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c
index 2267a60..bd2de54 100644
--- a/src/tests/files-tests.c
+++ b/src/tests/files-tests.c
@@ -57,15 +57,22 @@ static void setup_files_test(void)
 static void teardown_files_test(void)
 {
     char *cmd = NULL;
+    int ret;
 
     /* OK this is crude but since the functions to remove tree are under test.. */
     if (dir_path && test_ctx) {
         cmd = talloc_asprintf(test_ctx, "/bin/rm -rf %s\n", dir_path);
-        system(cmd);
+        ret = system(cmd);
+        if (ret == -1) {
+            DEBUG(1, ("Removing [%s] failed.\n", dir_path));
+        }
     }
     if (dst_path && test_ctx) {
         cmd = talloc_asprintf(test_ctx, "/bin/rm -rf %s\n", dst_path);
-        system(cmd);
+        ret = system(cmd);
+        if (ret == -1) {
+            DEBUG(1, ("Removing [%s] failed.\n", dst_path));
+        }
     }
 
     /* clean up */
@@ -99,7 +106,7 @@ START_TEST(test_remove_tree)
     char origpath[PATH_MAX+1];
 
     errno = 0;
-    getcwd(origpath, PATH_MAX);
+    fail_unless(getcwd(origpath, PATH_MAX) == origpath, "Cannot getcwd\n");
     fail_unless(errno == 0, "Cannot getcwd\n");
 
     DEBUG(5, ("About to delete %s\n", dir_path));
@@ -150,7 +157,7 @@ START_TEST(test_simple_copy)
     int fd = -1;
 
     errno = 0;
-    getcwd(origpath, PATH_MAX);
+    fail_unless(getcwd(origpath, PATH_MAX) == origpath, "Cannot getcwd\n");
     fail_unless(errno == 0, "Cannot getcwd\n");
 
     /* create a file */
@@ -199,7 +206,7 @@ START_TEST(test_copy_symlink)
     struct stat statbuf;
 
     errno = 0;
-    getcwd(origpath, PATH_MAX);
+    fail_unless(getcwd(origpath, PATH_MAX) == origpath, "Cannot getcwd\n");
     fail_unless(errno == 0, "Cannot getcwd\n");
 
     /* create a subdir */
@@ -241,7 +248,7 @@ START_TEST(test_copy_node)
     struct stat statbuf;
 
     errno = 0;
-    getcwd(origpath, PATH_MAX);
+    fail_unless(getcwd(origpath, PATH_MAX) == origpath, "Cannot getcwd\n");
     fail_unless(errno == 0, "Cannot getcwd\n");
 
     /* create a node */
-- 
1.7.2.3



More information about the sssd-devel mailing list