From e11c7dc43f4ff9897e37cc0d793f8e1fb3b8453a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 28 Nov 2012 03:24:58 +0000 Subject: Use an entry type mask macro to filter entry types Avoids hardcoding magic numbers everywhere and self documents why a mask is being applied. --- src/providers/data_provider.h | 1 + src/providers/ipa/ipa_id.c | 4 ++-- 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, 6 insertions(+), 5 deletions(-) diff --git a/src/providers/data_provider.h b/src/providers/data_provider.h index d49fcd524..bb944509d 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 6b3e40ef3..afe0a636d 100644 --- a/src/providers/ipa/ipa_id.c +++ b/src/providers/ipa/ipa_id.c @@ -84,7 +84,7 @@ void ipa_account_info_handler(struct be_req *breq) /* if domain names do not match, this is a subdomain case */ req = ipa_get_subdom_acct_send(breq, breq->be_ctx->ev, ctx, ar); - } else if ((ar->entry_type & 0xFFF) == BE_REQ_NETGROUP) { + } else if ((ar->entry_type & BE_REQ_TYPE_MASK) == BE_REQ_NETGROUP) { /* netgroups are handled by a separate request function */ if (ar->filter_type != BE_FILTER_NAME) { return sdap_handler_done(breq, DP_ERR_FATAL, @@ -113,7 +113,7 @@ static void ipa_account_info_done(struct tevent_req *req) const char *error_text; int ret, dp_error; - if ((ar->entry_type & 0xFFF) == BE_REQ_NETGROUP) { + if ((ar->entry_type & BE_REQ_TYPE_MASK) == BE_REQ_NETGROUP) { ret = ipa_id_get_netgroup_recv(req, &dp_error); } else { ret = ipa_get_subdom_acct_recv(req, &dp_error); diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c index 518ff85d7..481b99806 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 13a8212bc..a258e827b 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -929,7 +929,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 ce66fa128..87eb91b1e 100644 --- a/src/providers/proxy/proxy_id.c +++ b/src/providers/proxy/proxy_id.c @@ -1347,7 +1347,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: -- cgit