[SSSD] [PATCH 5/5] Use an entry type mask macro to filter entry types

Simo Sorce simo at redhat.com
Tue Oct 23 13:29:33 UTC 2012


Avoids hardcodinf magic numbers everywhere and selfdocuments why a
mask is being applied.

Signed-off-by: Simo Sorce <simo at redhat.com>
---
 src/providers/data_provider.h         | 1 +
 src/providers/ipa/ipa_id.c            | 2 +-
 src/providers/ipa/ipa_subdomains_id.c | 2 +-
 src/providers/ldap/ldap_id.c          | 2 +-
 src/providers/proxy/proxy_id.c        | 2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/providers/data_provider.h b/src/providers/data_provider.h
index b783081bc343e6f123f8cc1bc37545d5023462cb..2d4d1ddbff16cd0848382c6d7e1113215aca4999 100644
--- a/src/providers/data_provider.h
+++ b/src/providers/data_provider.h
@@ -142,6 +142,7 @@
 #define BE_REQ_SUDO_RULES    0x0007
 #define BE_REQ_AUTOFS        0x0009
 #define BE_REQ_HOST          0x0010
+#define BE_REQ_TYPE_MASK     0x00FF
 #define BE_REQ_FAST          0x1000
 
 /* AUTH related common data and functions */
diff --git a/src/providers/ipa/ipa_id.c b/src/providers/ipa/ipa_id.c
index 7afa6df6fbd841309d33866caf080be12eac170f..fcb0c71ebaba743136ba9d0c686f0bd577b99537 100644
--- a/src/providers/ipa/ipa_id.c
+++ b/src/providers/ipa/ipa_id.c
@@ -92,7 +92,7 @@ void ipa_account_info_handler(struct be_req *breq)
         goto done;
     }
 
-    switch (ar->entry_type & 0xFFF) {
+    switch (ar->entry_type & BE_REQ_TYPE_MASK) {
     case BE_REQ_USER: /* user */
     case BE_REQ_GROUP: /* group */
 
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
index 4edfd2de1f1bf34c967763bf197df2090a9ddfb7..c60801a2d5274913730e601d5eda63b3847f3a6b 100644
--- a/src/providers/ipa/ipa_subdomains_id.c
+++ b/src/providers/ipa/ipa_subdomains_id.c
@@ -85,7 +85,7 @@ struct tevent_req *ipa_get_subdom_acct_send(TALLOC_CTX *memctx,
     }
     state->sysdb = state->domain->sysdb;
 
-    state->entry_type = (ar->entry_type & 0xFFF);
+    state->entry_type = (ar->entry_type & BE_REQ_TYPE_MASK);
     state->filter = ar->filter_value;
     state->filter_type = ar->filter_type;
 
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
index b8520df83d6b94818f2c24bca4e000ae2c9e8309..57bcda56b94a9e2894fe30040601a044dc63fcb2 100644
--- a/src/providers/ldap/ldap_id.c
+++ b/src/providers/ldap/ldap_id.c
@@ -923,7 +923,7 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
 
     ar = talloc_get_type(breq->req_data, struct be_acct_req);
 
-    switch (ar->entry_type & 0xFFF) {
+    switch (ar->entry_type & BE_REQ_TYPE_MASK) {
     case BE_REQ_USER: /* user */
 
         /* skip enumerations on demand */
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index 451bdff5be7ffb817921a7f063a57e769d751c1a..adb1939327a5e9aff66d8da01ef4b6f568bf962f 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -1346,7 +1346,7 @@ void proxy_get_account_info(struct be_req *breq)
         return proxy_reply(breq, DP_ERR_FATAL, EINVAL, "Invalid attr type");
     }
 
-    switch (ar->entry_type & 0xFFF) {
+    switch (ar->entry_type & BE_REQ_TYPE_MASK) {
     case BE_REQ_USER: /* user */
         switch (ar->filter_type) {
         case BE_FILTER_ENUM:
-- 
1.7.11.4




More information about the sssd-devel mailing list