Stephen Gallagher <sgall...@redhat.com> wrote:
> On 09/03/2010 04:31 PM, Jan Zeleny wrote:
> > Stephen Gallagher <sgall...@redhat.com> wrote:
> >>      if (be_is_offline(state->be_ctx)) {
> >>      
> >>          /* Ok, we're offline. Return from the cache */
> >> 
> >> -        ret = sdap_access_decide_offline(req);
> >> +        sdap_access_decide_offline(req);
> >> 
> >>          goto finished;
> >>      
> >>      }
> >> 
> >> Please add ret = EOK before 'goto finished'. While it just happens to be
> >> true right now, I'd rather we kept this explicit here, in case we ever
> >> add something above this that changes ret.
> > 
> > That would create dead assignment and this patch should eliminate them
> > rather than create new ones. I would agree with you if the ret value was
> > used after "finished" label, but this isn't the case. I just want to be
> > sure about this.
> 
> You are correct. I misread the "finished" label.

Based on previous comments I updated the patch.

--
Jan
From d63a0e4538b2a35b7c27f53fcf731d42836b2681 Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzel...@redhat.com>
Date: Wed, 1 Sep 2010 16:30:32 +0200
Subject: [PATCH] Dead assignments cleanup in providers code

Dead assignments were deleted. Also prototype of function
sdap_access_decide_offline() has been changed, since its return
code was never used.
Ticket: #586
---
 src/providers/child_common.c       |    4 ++--
 src/providers/data_provider_opts.c |    1 -
 src/providers/krb5/krb5_child.c    |    1 -
 src/providers/ldap/ldap_id_enum.c  |    3 ---
 src/providers/ldap/sdap_access.c   |   18 +++++++-----------
 src/providers/proxy/proxy_id.c     |    2 --
 6 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/providers/child_common.c b/src/providers/child_common.c
index a242338..16618c7 100644
--- a/src/providers/child_common.c
+++ b/src/providers/child_common.c
@@ -493,14 +493,14 @@ void child_cleanup(int readfd, int writefd)
         ret = close(readfd);
         if (ret != EOK) {
             ret = errno;
-            DEBUG(1, ("close failed [%d][%s].\n", errno, strerror(errno)));
+            DEBUG(1, ("close failed [%d][%s].\n", ret, strerror(ret)));
         }
     }
     if (writefd != -1) {
         ret = close(writefd);
         if (ret != EOK) {
             ret = errno;
-            DEBUG(1, ("close failed [%d][%s].\n", errno, strerror(errno)));
+            DEBUG(1, ("close failed [%d][%s].\n", ret, strerror(ret)));
         }
     }
 }
diff --git a/src/providers/data_provider_opts.c b/src/providers/data_provider_opts.c
index 98283e4..14f48ac 100644
--- a/src/providers/data_provider_opts.c
+++ b/src/providers/data_provider_opts.c
@@ -42,7 +42,6 @@ int dp_get_options(TALLOC_CTX *memctx,
         opts[i].opt_name = def_opts[i].opt_name;
         opts[i].type = def_opts[i].type;
         opts[i].def_val = def_opts[i].def_val;
-        ret = EOK;
 
         switch (def_opts[i].type) {
         case DP_OPT_STRING:
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index cfb3f42..6892c66 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -270,7 +270,6 @@ static krb5_error_code create_ccache_file(struct krb5_req *kr, krb5_creds *creds
 done:
     if (fd != -1) {
         close(fd);
-        fd = -1;
     }
     if (kerr != 0 && tmp_cc != NULL) {
         krb5_cc_destroy(kr->ctx, tmp_cc);
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
index 87b9563..d605192 100644
--- a/src/providers/ldap/ldap_id_enum.c
+++ b/src/providers/ldap/ldap_id_enum.c
@@ -521,7 +521,6 @@ static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
 {
     struct tevent_req *req, *subreq;
     struct enum_groups_state *state;
-    const char *attr_name;
     int ret;
 
     req = tevent_req_create(memctx, &state, struct enum_groups_state);
@@ -531,8 +530,6 @@ static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
     state->ctx = ctx;
     state->op = op;
 
-    attr_name = ctx->opts->group_map[SDAP_AT_GROUP_NAME].name;
-
     if (ctx->max_group_timestamp && !purge) {
 
         state->filter = talloc_asprintf(state,
diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c
index 7d7832a..90b5371 100644
--- a/src/providers/ldap/sdap_access.c
+++ b/src/providers/ldap/sdap_access.c
@@ -99,7 +99,7 @@ struct sdap_access_req_ctx {
     char *basedn;
 };
 
-static int sdap_access_decide_offline(struct tevent_req *req);
+static void sdap_access_decide_offline(struct tevent_req *req);
 static int sdap_access_retry(struct tevent_req *req);
 static void sdap_access_connect_done(struct tevent_req *subreq);
 static void sdap_access_get_access_done(struct tevent_req *req);
@@ -182,7 +182,7 @@ static struct tevent_req *sdap_access_send(TALLOC_CTX *mem_ctx,
     /* Ok, we have one result, check if we are online or offline */
     if (be_is_offline(state->be_ctx)) {
         /* Ok, we're offline. Return from the cache */
-        ret = sdap_access_decide_offline(req);
+        sdap_access_decide_offline(req);
         goto finished;
     }
 
@@ -241,7 +241,7 @@ finished:
     return req;
 }
 
-static int sdap_access_decide_offline(struct tevent_req *req)
+static void sdap_access_decide_offline(struct tevent_req *req)
 {
     struct sdap_access_req_ctx *state =
             tevent_req_data(req, struct sdap_access_req_ctx);
@@ -253,8 +253,6 @@ static int sdap_access_decide_offline(struct tevent_req *req)
         DEBUG(6, ("Access denied by cached credentials\n"));
         state->pam_status = PAM_PERM_DENIED;
     }
-
-    return EOK;
 }
 
 static int sdap_access_retry(struct tevent_req *req)
@@ -287,11 +285,9 @@ static void sdap_access_connect_done(struct tevent_req *subreq)
 
     if (ret != EOK) {
         if (dp_error == DP_ERR_OFFLINE) {
-            ret = sdap_access_decide_offline(req);
-            if (ret == EOK) {
-                tevent_req_done(req);
-                return;
-            }
+            sdap_access_decide_offline(req);
+            tevent_req_done(req);
+            return;
         }
 
         tevent_req_error(req, ret);
@@ -344,7 +340,7 @@ static void sdap_access_get_access_done(struct tevent_req *subreq)
             }
             state->pam_status = PAM_SYSTEM_ERR;
         } else if (dp_error == DP_ERR_OFFLINE) {
-            ret = sdap_access_decide_offline(req);
+            sdap_access_decide_offline(req);
         } else {
             DEBUG(1, ("sdap_get_generic_send() returned error [%d][%s]\n",
                       ret, strerror(ret)));
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index 8536b93..d2fba72 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -1037,7 +1037,6 @@ void proxy_get_account_info(struct be_req *breq)
 {
     struct be_acct_req *ar;
     struct proxy_id_ctx *ctx;
-    struct tevent_context *ev;
     struct sysdb_ctx *sysdb;
     struct sss_domain_info *domain;
     uid_t uid;
@@ -1047,7 +1046,6 @@ void proxy_get_account_info(struct be_req *breq)
     ar = talloc_get_type(breq->req_data, struct be_acct_req);
     ctx = talloc_get_type(breq->be_ctx->bet_info[BET_ID].pvt_bet_data,
                           struct proxy_id_ctx);
-    ev = breq->be_ctx->ev;
     sysdb = breq->be_ctx->sysdb;
     domain = breq->be_ctx->domain;
 
-- 
1.7.2.1

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

Reply via email to