URL: https://github.com/SSSD/sssd/pull/592
Author: amitkumar50
 Title: #592: too complex if-else structure in sss_dp_get_account_msg
Action: synchronized

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/592/head:pr592
git checkout pr592
From 2e49cb705ced4dde632ad764cf551674ca3358e4 Mon Sep 17 00:00:00 2001
From: Amit Kumar <amitk...@redhat.com>
Date: Wed, 6 Jun 2018 11:27:54 +0530
Subject: [PATCH] Responder: simplify if-else structure in
 sss_dp_get_account_msg()

The structure of if-else statements in sss_dp_get_account_msg
become too complex. Replacing if-else with switch initially,
Will investigate more on refactoring further.

Resolves: https://pagure.io/SSSD/sssd/issue/1903
---
 src/responder/common/responder_dp.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c
index 9669b5fee..208c415ac 100644
--- a/src/responder/common/responder_dp.c
+++ b/src/responder/common/responder_dp.c
@@ -679,19 +679,24 @@ sss_dp_get_account_msg(void *pvt)
     dp_flags = info->fast_reply ? DP_FAST_REPLY : 0;
 
     if (info->opt_name) {
-        if (info->type == SSS_DP_SECID) {
-            filter = talloc_asprintf(info, "%s=%s", DP_SEC_ID,
-                                     info->opt_name);
-        } else if (info->type == SSS_DP_CERT) {
-            filter = talloc_asprintf(info, "%s=%s", DP_CERT,
-                                     info->opt_name);
-        } else if (info->type == SSS_DP_WILDCARD_USER ||
-                   info->type == SSS_DP_WILDCARD_GROUP) {
-            filter = talloc_asprintf(info, "%s=%s", DP_WILDCARD,
-                                     info->opt_name);
-        } else {
-            filter = talloc_asprintf(info, "name=%s", info->opt_name);
-        }
+        switch(info->type) {
+            case SSS_DP_SECID:
+                filter = talloc_asprintf(info, "%s=%s", DP_SEC_ID,
+                                         info->opt_name);
+                break;
+            case SSS_DP_CERT:
+                filter = talloc_asprintf(info, "%s=%s", DP_CERT,
+                                         info->opt_name);
+                break;
+            case SSS_DP_WILDCARD_USER:
+            case SSS_DP_WILDCARD_GROUP:
+                filter = talloc_asprintf(info, "%s=%s", DP_WILDCARD,
+                                         info->opt_name);
+                break;
+            default:
+                filter = talloc_asprintf(info, "name=%s", info->opt_name);
+		break;
+	}
     } else if (info->opt_id) {
         filter = talloc_asprintf(info, "idnumber=%u", info->opt_id);
     } else {
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/sssd-devel@lists.fedorahosted.org/message/QRPDYQNVZTDVIGAC5QMEXR7K2YBQITIB/

Reply via email to