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 d49fcd524ef37e4755263399903d2804aaf29737..bb944509da9f1dc89216266cf62c57fb4127fd57 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 8e4309f865daec3a574ffdb486c2dda7225cc120..5cdd780f0b2fe899c0079f1219f455e22537aeca 100644 --- a/src/providers/ipa/ipa_id.c +++ b/src/providers/ipa/ipa_id.c @@ -83,7 +83,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, @@ -112,7 +112,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 518ff85d7b2caa78e1ff779d9cbfb332dd447b1f..481b998065eec29a52b9c39fba4017ff10098481 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 13a8212bc2cb0055a0e200527e4c7da7d66c4c45..a258e827b4788c0bea65021e286d6628e952c4ea 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 ce66fa128e29eea880f28733570a7420bd6d445e..87eb91b1ee47fce61757aa58efc13d84ecc2acd2 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: -- 1.7.1 _______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel