>From 5dc30f6134e9ad5b98b71d07b12b696b1f6948c8 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sun, 12 May 2013 12:29:21 +0200 Subject: [PATCH 01/15] Do not obfuscate calls with booleans --- src/providers/ad/ad_common.c | 19 ++++++++++++------- src/providers/ipa/ipa_common.c | 19 ++++++++++++------- src/providers/krb5/krb5_common.c | 20 +++++++++++++------- src/providers/ldap/ldap_common.c | 25 +++++++++++++++---------- 4 files changed, 52 insertions(+), 31 deletions(-) diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c index e34199959cb7ca3cd21f7d188a624e03fb12162e..e34b2db4cd7317ceebdc843eb5381183b83ad64f 100644 --- a/src/providers/ad/ad_common.c +++ b/src/providers/ad/ad_common.c @@ -140,12 +140,17 @@ done: static void ad_resolve_callback(void *private_data, struct fo_server *server); +#define ad_primary_servers_init(mem_ctx, bectx, servers, options) \ + _ad_servers_init(mem_ctx, bectx, servers, options, true) +#define ad_backup_servers_init(mem_ctx, bectx, servers, options) \ + _ad_servers_init(mem_ctx, bectx, servers, options, false) + 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; @@ -286,13 +291,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 509b2abd0b9b2ff1af04b353e0a44df573e3790a..e371824840584056a6217b8b960159c03ce55fdd 100644 --- a/src/providers/ipa/ipa_common.c +++ b/src/providers/ipa/ipa_common.c @@ -754,11 +754,16 @@ 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) +#define ipa_primary_servers_init(ctx, service, options, servers) \ + _ipa_servers_init(ctx, service, options, servers, true) +#define ipa_backup_servers_init(ctx, service, options, servers) \ + _ipa_servers_init(ctx, service, options, servers, false) + +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; @@ -900,13 +905,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 c6865c09960463b8648957cb777d0d2b4e7b1dde..6c26fcc11731dd437f45f2b411c918e3bb468712 100644 --- a/src/providers/krb5/krb5_common.c +++ b/src/providers/krb5/krb5_common.c @@ -465,11 +465,16 @@ 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) +#define krb5_primary_servers_init(ctx, service, service_name, servers) \ + _krb5_servers_init(ctx, service, service_name, servers, true) +#define krb5_backup_servers_init(ctx, service, service_name, servers) \ + _krb5_servers_init(ctx, service, service_name, servers, false) + +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; @@ -642,13 +647,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 acb24b190157efe06967963ad05014cf9017db7f..155019ec7a430b133dbdf6e57a6ec81a46f0dc0b 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -1194,12 +1194,17 @@ 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) +#define sdap_primary_urls_init(ctx, service, service_name, dns_service_name, urls) \ + _sdap_urls_init(ctx, service, service_name, dns_service_name, urls, true) +#define sdap_backup_urls_init(ctx, service, service_name, dns_service_name, urls) \ + _sdap_urls_init(ctx, service, service_name, dns_service_name, urls, false) + +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; @@ -1337,15 +1342,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; } -- 1.8.2.1