From a3c8390d19593b1e5277d95bfb4ab206d4785150 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Wed, 12 Feb 2014 10:12:04 -0500 Subject: Make DEBUG macro invocations variadic Use a script to update DEBUG macro invocations to use it as a variadic macro, supplying format string and its arguments directly, instead of wrapping them in parens. This script was used to update the code: grep -rwl --include '*.[hc]' DEBUG . | while read f; do mv "$f"{,.orig} perl -e \ 'use strict; use File::Slurp; my $text=read_file(\*STDIN); $text=~s#(\bDEBUG\s*\([^(]+)\((.*?)\)\s*\)\s*;#$1$2);#gs; print $text;' < "$f.orig" > "$f" rm "$f.orig" done Reviewed-by: Jakub Hrozek Reviewed-by: Stephen Gallagher Reviewed-by: Simo Sorce --- src/db/sysdb.c | 102 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/db/sysdb.c') diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 65277af01..901417e81 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -52,7 +52,7 @@ errno_t sysdb_ldb_connect(TALLOC_CTX *mem_ctx, const char *filename, mod_path = getenv(LDB_MODULES_PATH); if (mod_path != NULL) { - DEBUG(9, ("Setting ldb module path to [%s].\n", mod_path)); + DEBUG(9, "Setting ldb module path to [%s].\n", mod_path); ldb_set_modules_dir(ldb, mod_path); } @@ -665,7 +665,7 @@ int sysdb_attrs_add_lc_name_alias(struct sysdb_attrs *attrs, lc_str = sss_tc_utf8_str_tolower(attrs, value); if (lc_str == NULL) { - DEBUG(SSSDBG_OP_FAILURE, ("Cannot convert name to lowercase\n")); + DEBUG(SSSDBG_OP_FAILURE, "Cannot convert name to lowercase\n"); return ENOMEM; } @@ -724,21 +724,21 @@ int sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs, } el->values = vals; - DEBUG(9, ("Adding %d members to existing %d ones\n", - num, el->num_values)); + DEBUG(9, "Adding %d members to existing %d ones\n", + num, el->num_values); for (i = 0, j = el->num_values; i < num; i++) { member = sysdb_user_strdn(el->values, domain, list[i]); if (!member) { - DEBUG(4, ("Failed to get user dn for [%s]\n", list[i])); + DEBUG(4, "Failed to get user dn for [%s]\n", list[i]); continue; } el->values[j].data = (uint8_t *)member; el->values[j].length = strlen(member); j++; - DEBUG(7, (" member #%d: [%s]\n", i, member)); + DEBUG(7, " member #%d: [%s]\n", i, member); } el->num_values = j; @@ -812,8 +812,8 @@ int sysdb_error_to_errno(int ldberr) return EINVAL; default: DEBUG(SSSDBG_CRIT_FAILURE, - ("LDB returned unexpected error: [%s]\n", - ldb_strerror(ldberr))); + "LDB returned unexpected error: [%s]\n", + ldb_strerror(ldberr)); return EFAULT; } } @@ -826,7 +826,7 @@ int sysdb_transaction_start(struct sysdb_ctx *sysdb) ret = ldb_transaction_start(sysdb->ldb); if (ret != LDB_SUCCESS) { - DEBUG(1, ("Failed to start ldb transaction! (%d)\n", ret)); + DEBUG(1, "Failed to start ldb transaction! (%d)\n", ret); } return sysdb_error_to_errno(ret); } @@ -837,7 +837,7 @@ int sysdb_transaction_commit(struct sysdb_ctx *sysdb) ret = ldb_transaction_commit(sysdb->ldb); if (ret != LDB_SUCCESS) { - DEBUG(1, ("Failed to commit ldb transaction! (%d)\n", ret)); + DEBUG(1, "Failed to commit ldb transaction! (%d)\n", ret); } return sysdb_error_to_errno(ret); } @@ -848,7 +848,7 @@ int sysdb_transaction_cancel(struct sysdb_ctx *sysdb) ret = ldb_transaction_cancel(sysdb->ldb); if (ret != LDB_SUCCESS) { - DEBUG(1, ("Failed to cancel ldb transaction! (%d)\n", ret)); + DEBUG(1, "Failed to cancel ldb transaction! (%d)\n", ret); } return sysdb_error_to_errno(ret); } @@ -909,10 +909,10 @@ errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name) /* do a synchronous add */ ret = ldb_add(sysdb->ldb, msg); if (ret != LDB_SUCCESS) { - DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to initialize DB (%d, [%s]) " + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to initialize DB (%d, [%s]) " "for domain %s!\n", ret, ldb_errstring(sysdb->ldb), - domain_name)); + domain_name); ret = EIO; goto done; } @@ -939,10 +939,10 @@ errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name) /* do a synchronous add */ ret = ldb_add(sysdb->ldb, msg); if (ret != LDB_SUCCESS) { - DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to initialize DB (%d, [%s]) " + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to initialize DB (%d, [%s]) " "for domain %s!\n", ret, ldb_errstring(sysdb->ldb), - domain_name)); + domain_name); ret = EIO; goto done; } @@ -969,10 +969,10 @@ errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name) /* do a synchronous add */ ret = ldb_add(sysdb->ldb, msg); if (ret != LDB_SUCCESS) { - DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to initialize DB (%d, [%s]) for " + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to initialize DB (%d, [%s]) for " "domain %s!\n", ret, ldb_errstring(sysdb->ldb), - domain_name)); + domain_name); ret = EIO; goto done; } @@ -1044,11 +1044,11 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, if (ret != EOK) { goto done; } - DEBUG(5, ("DB File for %s: %s\n", domain->name, sysdb->ldb_file)); + DEBUG(5, "DB File for %s: %s\n", domain->name, sysdb->ldb_file); ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb); if (ret != EOK) { - DEBUG(1, ("sysdb_ldb_connect failed.\n")); + DEBUG(1, "sysdb_ldb_connect failed.\n"); goto done; } @@ -1103,14 +1103,14 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, if (!allow_upgrade) { DEBUG(SSSDBG_FATAL_FAILURE, - ("Wrong DB version (got %s expected %s)\n", - version, SYSDB_VERSION)); + "Wrong DB version (got %s expected %s)\n", + version, SYSDB_VERSION); ret = sysdb_version_check(SYSDB_VERSION, version); goto done; } - DEBUG(SSSDBG_CONF_SETTINGS, ("Upgrading DB [%s] from version: %s\n", - domain->name, version)); + DEBUG(SSSDBG_CONF_SETTINGS, "Upgrading DB [%s] from version: %s\n", + domain->name, version); if (strcmp(version, SYSDB_VERSION_0_3) == 0) { ret = sysdb_upgrade_03(sysdb, &version); @@ -1210,13 +1210,13 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, talloc_zfree(sysdb->ldb); ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb); if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, ("sysdb_ldb_connect failed.\n")); + DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_ldb_connect failed.\n"); } goto done; } - DEBUG(0,("Unknown DB version [%s], expected [%s] for domain %s!\n", - version?version:"not found", SYSDB_VERSION, domain->name)); + DEBUG(0,"Unknown DB version [%s], expected [%s] for domain %s!\n", + version?version:"not found", SYSDB_VERSION, domain->name); ret = sysdb_version_check(SYSDB_VERSION, version); goto done; } @@ -1227,8 +1227,8 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, while ((ldif = ldb_ldif_read_string(sysdb->ldb, &base_ldif))) { ret = ldb_add(sysdb->ldb, ldif->msg); if (ret != LDB_SUCCESS) { - DEBUG(0, ("Failed to initialize DB (%d, [%s]) for domain %s!\n", - ret, ldb_errstring(sysdb->ldb), domain->name)); + DEBUG(0, "Failed to initialize DB (%d, [%s]) for domain %s!\n", + ret, ldb_errstring(sysdb->ldb), domain->name); ret = EIO; goto done; } @@ -1249,7 +1249,7 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, talloc_zfree(sysdb->ldb); ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb); if (ret != EOK) { - DEBUG(1, ("sysdb_ldb_connect failed.\n")); + DEBUG(1, "sysdb_ldb_connect failed.\n"); } done: @@ -1326,7 +1326,7 @@ int sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname, e = &(attrs->a[i]); } if (strcasecmp(newname, attrs->a[i].name) == 0) { - DEBUG(3, ("New attribute name [%s] already exists.\n", newname)); + DEBUG(3, "New attribute name [%s] already exists.\n", newname); return EEXIST; } } @@ -1334,7 +1334,7 @@ int sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname, if (e != NULL) { dummy = talloc_strdup(attrs, newname); if (dummy == NULL) { - DEBUG(1, ("talloc_strdup failed.\n")); + DEBUG(1, "talloc_strdup failed.\n"); return ENOMEM; } @@ -1456,7 +1456,7 @@ errno_t sysdb_get_bool(struct sysdb_ctx *sysdb, goto done; } else if (res->count != 1) { DEBUG(SSSDBG_CRIT_FAILURE, - ("Got more than one reply for base search!\n")); + "Got more than one reply for base search!\n"); ret = EIO; goto done; } @@ -1513,7 +1513,7 @@ errno_t sysdb_set_bool(struct sysdb_ctx *sysdb, } } else if (res->count != 1) { DEBUG(SSSDBG_CRIT_FAILURE, - ("Got more than one reply for base search!\n")); + "Got more than one reply for base search!\n"); ret = EIO; goto done; } else { @@ -1640,7 +1640,7 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb, goto done; } if (orig_dn_el->num_values == 0) { - DEBUG(1, ("Original DN is not available.\n")); + DEBUG(1, "Original DN is not available.\n"); ret = EINVAL; goto done; } else if (orig_dn_el->num_values == 1) { @@ -1649,26 +1649,26 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb, &rdn_attr, &rdn_val); if (ret != EOK) { - DEBUG(1, ("Could not get rdn from [%s]\n", - (const char *) orig_dn_el->values[0].data)); + DEBUG(1, "Could not get rdn from [%s]\n", + (const char *) orig_dn_el->values[0].data); goto done; } } else { - DEBUG(1, ("Should not have more than one origDN\n")); + DEBUG(1, "Should not have more than one origDN\n"); ret = EINVAL; goto done; } /* First check whether the attribute name matches */ - DEBUG(8, ("Comparing attribute names [%s] and [%s]\n", - rdn_attr, ldap_attr)); + DEBUG(8, "Comparing attribute names [%s] and [%s]\n", + rdn_attr, ldap_attr); if (strcasecmp(rdn_attr, ldap_attr) != 0) { /* Multiple entries, and the RDN attribute doesn't match. * We have no way of resolving this deterministically, * so we'll use the first value as a fallback. */ - DEBUG(3, ("The entry has multiple names and the RDN attribute does " - "not match. Will use the first value as fallback.\n")); + DEBUG(3, "The entry has multiple names and the RDN attribute does " + "not match. Will use the first value as fallback.\n"); *_primary = (const char *)sysdb_name_el->values[0].data; ret = EOK; goto done; @@ -1689,7 +1689,7 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb, * throw up our hands. There's no deterministic way to * decide which name is correct. */ - DEBUG(1, ("Cannot save entry. Unable to determine groupname\n")); + DEBUG(1, "Cannot save entry. Unable to determine groupname\n"); ret = EINVAL; goto done; } @@ -1698,8 +1698,8 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb, done: if (ret != EOK) { - DEBUG(1, ("Could not determine primary name: [%d][%s]\n", - ret, strerror(ret))); + DEBUG(1, "Could not determine primary name: [%d][%s]\n", + ret, strerror(ret)); } talloc_free(tmp_ctx); return ret; @@ -1752,7 +1752,7 @@ errno_t sysdb_attrs_get_aliases(TALLOC_CTX *mem_ctx, if (lowercase) { DEBUG(SSSDBG_TRACE_INTERNAL, - ("Domain is case-insensitive; will add lowercased aliases\n")); + "Domain is case-insensitive; will add lowercased aliases\n"); } ai = 0; @@ -1830,7 +1830,7 @@ errno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb, ldap_attr, &name); if (ret != EOK) { - DEBUG(1, ("Could not determine primary name\n")); + DEBUG(1, "Could not determine primary name\n"); /* Skip and continue. Don't advance 'j' */ continue; } @@ -1875,7 +1875,7 @@ errno_t sysdb_get_real_name(TALLOC_CTX *mem_ctx, ret = sysdb_getpwnam(tmp_ctx, domain, name, &res); if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, ("Cannot canonicalize username\n")); + DEBUG(SSSDBG_OP_FAILURE, "Cannot canonicalize username\n"); goto done; } @@ -1885,14 +1885,14 @@ errno_t sysdb_get_real_name(TALLOC_CTX *mem_ctx, goto done; } else if (res->count != 1) { DEBUG(SSSDBG_CRIT_FAILURE, - ("sysdb_getpwnam returned count: [%d]\n", res->count)); + "sysdb_getpwnam returned count: [%d]\n", res->count); ret = EIO; goto done; } cname = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_NAME, NULL); if (!cname) { - DEBUG(SSSDBG_CRIT_FAILURE, ("A user with no name?\n")); + DEBUG(SSSDBG_CRIT_FAILURE, "A user with no name?\n"); ret = ENOENT; goto done; } @@ -1913,14 +1913,14 @@ errno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count, a = talloc_array(mem_ctx, struct sysdb_attrs *, count); if (a == NULL) { - DEBUG(1, ("talloc_array failed.\n")); + DEBUG(1, "talloc_array failed.\n"); return ENOMEM; } for (i = 0; i < count; i++) { a[i] = talloc(a, struct sysdb_attrs); if (a[i] == NULL) { - DEBUG(1, ("talloc failed.\n")); + DEBUG(1, "talloc failed.\n"); talloc_free(a); return ENOMEM; } -- cgit