diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2013-05-12 12:29:21 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-06-07 00:14:12 +0200 |
commit | 7119f0c483049a8850d3075c0b1062f35200a538 (patch) | |
tree | 7be03fca0634dda1406df2b9bde387ca7c89877e /src | |
parent | 7527ec8ab2b79ec576ace2da9e2c158b849adfa6 (diff) | |
download | sssd-7119f0c483049a8850d3075c0b1062f35200a538.tar.gz sssd-7119f0c483049a8850d3075c0b1062f35200a538.tar.bz2 sssd-7119f0c483049a8850d3075c0b1062f35200a538.zip |
Do not obfuscate calls with booleans
Instead of using boolean variables to denote whether the call is adding
a primary or a secondary server, use a function wrapper that tells what
it's doing by its name.
Diffstat (limited to 'src')
-rw-r--r-- | src/providers/ad/ad_common.c | 28 | ||||
-rw-r--r-- | src/providers/ipa/ipa_common.c | 28 | ||||
-rw-r--r-- | src/providers/krb5/krb5_common.c | 29 | ||||
-rw-r--r-- | src/providers/ldap/ldap_common.c | 39 |
4 files changed, 93 insertions, 31 deletions
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c index e3419995..4a6343f7 100644 --- a/src/providers/ad/ad_common.c +++ b/src/providers/ad/ad_common.c @@ -141,11 +141,11 @@ static void ad_resolve_callback(void *private_data, struct fo_server *server); static errno_t -ad_servers_init(TALLOC_CTX *mem_ctx, - struct be_ctx *bectx, - const char *servers, - struct ad_options *options, - bool primary) +_ad_servers_init(TALLOC_CTX *mem_ctx, + struct be_ctx *bectx, + const char *servers, + struct ad_options *options, + bool primary) { size_t i; errno_t ret = 0; @@ -210,6 +210,20 @@ done: return ret; } +static inline errno_t +ad_primary_servers_init(TALLOC_CTX *mem_ctx, struct be_ctx *bectx, + const char *servers, struct ad_options *options) +{ + return _ad_servers_init(mem_ctx, bectx, servers, options, true); +} + +static inline errno_t +ad_backup_servers_init(TALLOC_CTX *mem_ctx, struct be_ctx *bectx, + const char *servers, struct ad_options *options) +{ + return _ad_servers_init(mem_ctx, bectx, servers, options, false); +} + static int ad_user_data_cmp(void *ud1, void *ud2) { return strcasecmp((char*) ud1, (char*) ud2); @@ -286,13 +300,13 @@ ad_failover_init(TALLOC_CTX *mem_ctx, struct be_ctx *bectx, primary_servers = BE_SRV_IDENTIFIER; } - ret = ad_servers_init(mem_ctx, bectx, primary_servers, options, true); + ret = ad_primary_servers_init(mem_ctx, bectx, primary_servers, options); if (ret != EOK) { goto done; } if (backup_servers) { - ret = ad_servers_init(mem_ctx, bectx, backup_servers, options, false); + ret = ad_backup_servers_init(mem_ctx, bectx, backup_servers, options); if (ret != EOK) { goto done; } diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c index 509b2abd..ec36b57d 100644 --- a/src/providers/ipa/ipa_common.c +++ b/src/providers/ipa/ipa_common.c @@ -754,11 +754,11 @@ static void ipa_resolve_callback(void *private_data, struct fo_server *server) talloc_free(tmp_ctx); } -errno_t ipa_servers_init(struct be_ctx *ctx, - struct ipa_service *service, - struct ipa_options *options, - const char *servers, - bool primary) +static errno_t _ipa_servers_init(struct be_ctx *ctx, + struct ipa_service *service, + struct ipa_options *options, + const char *servers, + bool primary) { TALLOC_CTX *tmp_ctx; char **list = NULL; @@ -825,6 +825,20 @@ done: return ret; } +static inline errno_t +ipa_primary_servers_init(struct be_ctx *ctx, struct ipa_service *service, + struct ipa_options *options, const char *servers) +{ + return _ipa_servers_init(ctx, service, options, servers, true); +} + +static inline errno_t +ipa_backup_servers_init(struct be_ctx *ctx, struct ipa_service *service, + struct ipa_options *options, const char *servers) +{ + return _ipa_servers_init(ctx, service, options, servers, false); +} + static int ipa_user_data_cmp(void *ud1, void *ud2) { return strcasecmp((char*) ud1, (char*) ud2); @@ -900,13 +914,13 @@ int ipa_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx, primary_servers = BE_SRV_IDENTIFIER; } - ret = ipa_servers_init(ctx, service, options, primary_servers, true); + ret = ipa_primary_servers_init(ctx, service, options, primary_servers); if (ret != EOK) { goto done; } if (backup_servers) { - ret = ipa_servers_init(ctx, service, options, backup_servers, false); + ret = ipa_backup_servers_init(ctx, service, options, backup_servers); if (ret != EOK) { goto done; } diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c index 940cc373..e60e6e0e 100644 --- a/src/providers/krb5/krb5_common.c +++ b/src/providers/krb5/krb5_common.c @@ -470,11 +470,11 @@ static void krb5_resolve_callback(void *private_data, struct fo_server *server) return; } -errno_t krb5_servers_init(struct be_ctx *ctx, - struct krb5_service *service, - const char *service_name, - const char *servers, - bool primary) +static errno_t _krb5_servers_init(struct be_ctx *ctx, + struct krb5_service *service, + const char *service_name, + const char *servers, + bool primary) { TALLOC_CTX *tmp_ctx; char **list = NULL; @@ -597,6 +597,20 @@ done: return ret; } +static inline errno_t +krb5_primary_servers_init(struct be_ctx *ctx, struct krb5_service *service, + const char *service_name, const char *servers) +{ + return _krb5_servers_init(ctx, service, service_name, servers, true); +} + +static inline errno_t +krb5_backup_servers_init(struct be_ctx *ctx, struct krb5_service *service, + const char *service_name, const char *servers) +{ + return _krb5_servers_init(ctx, service, service_name, servers, false); +} + static int krb5_user_data_cmp(void *ud1, void *ud2) { return strcasecmp((char*) ud1, (char*) ud2); @@ -647,13 +661,14 @@ int krb5_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx, primary_servers = BE_SRV_IDENTIFIER; } - ret = krb5_servers_init(ctx, service, service_name, primary_servers, true); + ret = krb5_primary_servers_init(ctx, service, service_name, primary_servers); if (ret != EOK) { goto done; } if (backup_servers) { - ret = krb5_servers_init(ctx, service, service_name, backup_servers, false); + ret = krb5_backup_servers_init(ctx, service, service_name, + backup_servers); if (ret != EOK) { goto done; } diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index acb24b19..1e92400d 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -1194,12 +1194,12 @@ done: return ret; } -errno_t sdap_urls_init(struct be_ctx *ctx, - struct sdap_service *service, - const char *service_name, - const char *dns_service_name, - const char *urls, - bool primary) +static errno_t _sdap_urls_init(struct be_ctx *ctx, + struct sdap_service *service, + const char *service_name, + const char *dns_service_name, + const char *urls, + bool primary) { TALLOC_CTX *tmp_ctx; char *srv_user_data; @@ -1294,6 +1294,25 @@ done: return ret; } + +static inline errno_t +sdap_primary_urls_init(struct be_ctx *ctx, struct sdap_service *service, + const char *service_name, const char *dns_service_name, + const char *urls) +{ + return _sdap_urls_init(ctx, service, service_name, + dns_service_name, urls, true); +} + +static inline errno_t +sdap_backup_urls_init(struct be_ctx *ctx, struct sdap_service *service, + const char *service_name, const char *dns_service_name, + const char *urls) +{ + return _sdap_urls_init(ctx, service, service_name, + dns_service_name, urls, false); +} + static int ldap_user_data_cmp(void *ud1, void *ud2) { return strcasecmp((char*) ud1, (char*) ud2); @@ -1337,15 +1356,15 @@ int sdap_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx, urls = BE_SRV_IDENTIFIER; } - ret = sdap_urls_init(ctx, service, service_name, dns_service_name, - urls, true); + ret = sdap_primary_urls_init(ctx, service, service_name, dns_service_name, + urls); if (ret != EOK) { goto done; } if (backup_urls) { - ret = sdap_urls_init(ctx, service, service_name, dns_service_name, - backup_urls, false); + ret = sdap_backup_urls_init(ctx, service, service_name, + dns_service_name, backup_urls); if (ret != EOK) { goto done; } |