diff options
author | Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com> | 2014-02-12 10:12:04 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-02-12 22:30:55 +0100 |
commit | a3c8390d19593b1e5277d95bfb4ab206d4785150 (patch) | |
tree | 2eb4e5432f4f79a75589c03b1513b656879ebf9c /src/util/find_uid.c | |
parent | cc026fd9ba386f2197e3217940d597dcad1a26fe (diff) | |
download | sssd-a3c8390d19593b1e5277d95bfb4ab206d4785150.tar.gz sssd-a3c8390d19593b1e5277d95bfb4ab206d4785150.tar.xz sssd-a3c8390d19593b1e5277d95bfb4ab206d4785150.zip |
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 <jhrozek@redhat.com>
Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/util/find_uid.c')
-rw-r--r-- | src/util/find_uid.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/util/find_uid.c b/src/util/find_uid.c index 91ee7f685..919486a9d 100644 --- a/src/util/find_uid.c +++ b/src/util/find_uid.c @@ -74,10 +74,10 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) ret = snprintf(path, PATHLEN, "/proc/%d/status", pid); if (ret < 0) { - DEBUG(1, ("snprintf failed")); + DEBUG(1, "snprintf failed"); return EINVAL; } else if (ret >= PATHLEN) { - DEBUG(1, ("path too long?!?!\n")); + DEBUG(1, "path too long?!?!\n"); return EINVAL; } @@ -85,11 +85,11 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) if (fd == -1) { error = errno; if (error == ENOENT) { - DEBUG(7, ("Proc file [%s] is not available anymore, continuing.\n", - path)); + DEBUG(7, "Proc file [%s] is not available anymore, continuing.\n", + path); return EOK; } - DEBUG(1, ("open failed [%d][%s].\n", error, strerror(error))); + DEBUG(1, "open failed [%d][%s].\n", error, strerror(error)); return error; } @@ -97,17 +97,17 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) if (ret == -1) { error = errno; if (error == ENOENT) { - DEBUG(7, ("Proc file [%s] is not available anymore, continuing.\n", - path)); + DEBUG(7, "Proc file [%s] is not available anymore, continuing.\n", + path); error = EOK; goto fail_fd; } - DEBUG(1, ("fstat failed [%d][%s].\n", error, strerror(error))); + DEBUG(1, "fstat failed [%d][%s].\n", error, strerror(error)); goto fail_fd; } if (!S_ISREG(stat_buf.st_mode)) { - DEBUG(1, ("not a regular file\n")); + DEBUG(1, "not a regular file\n"); error = EINVAL; goto fail_fd; } @@ -117,7 +117,7 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) if (ret == -1) { error = errno; DEBUG(SSSDBG_CRIT_FAILURE, - ("read failed [%d][%s].\n", error, strerror(error))); + "read failed [%d][%s].\n", error, strerror(error)); goto fail_fd; } @@ -127,7 +127,7 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) ret = close(fd); if (ret == -1) { error = errno; - DEBUG(1, ("close failed [%d][%s].\n", error, strerror(error))); + DEBUG(1, "close failed [%d][%s].\n", error, strerror(error)); } p = strstr(buf, "\nUid:\t"); @@ -135,7 +135,7 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) p += 6; e = strchr(p,'\t'); if (e == NULL) { - DEBUG(1, ("missing delimiter.\n")); + DEBUG(1, "missing delimiter.\n"); return EINVAL; } else { *e = '\0'; @@ -143,16 +143,16 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) num = (uint32_t) strtoint32(p, &endptr, 10); error = errno; if (error != 0) { - DEBUG(1, ("strtol failed [%s].\n", strerror(error))); + DEBUG(1, "strtol failed [%s].\n", strerror(error)); return error; } if (*endptr != '\0') { - DEBUG(1, ("uid contains extra characters\n")); + DEBUG(1, "uid contains extra characters\n"); return EINVAL; } } else { - DEBUG(1, ("format error\n")); + DEBUG(1, "format error\n"); return EINVAL; } @@ -180,12 +180,12 @@ static errno_t name_to_pid(const char *name, pid_t *pid) } if (*endptr != '\0') { - DEBUG(1, ("pid string contains extra characters.\n")); + DEBUG(1, "pid string contains extra characters.\n"); return EINVAL; } if (num <= 0 || num >= INT_MAX) { - DEBUG(1, ("pid out of range.\n")); + DEBUG(1, "pid out of range.\n"); return ERANGE; } @@ -214,7 +214,7 @@ static errno_t get_active_uid_linux(hash_table_t *table, uid_t search_uid) proc_dir = opendir("/proc"); if (proc_dir == NULL) { ret = errno; - DEBUG(1, ("Cannot open proc dir.\n")); + DEBUG(1, "Cannot open proc dir.\n"); goto done; }; @@ -223,13 +223,13 @@ static errno_t get_active_uid_linux(hash_table_t *table, uid_t search_uid) if (only_numbers(dirent->d_name) != 0) continue; ret = name_to_pid(dirent->d_name, &pid); if (ret != EOK) { - DEBUG(1, ("name_to_pid failed.\n")); + DEBUG(1, "name_to_pid failed.\n"); goto done; } ret = get_uid_from_pid(pid, &uid); if (ret != EOK) { - DEBUG(1, ("get_uid_from_pid failed.\n")); + DEBUG(1, "get_uid_from_pid failed.\n"); goto done; } @@ -241,7 +241,7 @@ static errno_t get_active_uid_linux(hash_table_t *table, uid_t search_uid) ret = hash_enter(table, &key, &value); if (ret != HASH_SUCCESS) { - DEBUG(1, ("cannot add to table [%s]\n", hash_error_string(ret))); + DEBUG(1, "cannot add to table [%s]\n", hash_error_string(ret)); ret = ENOMEM; goto done; } @@ -257,14 +257,14 @@ static errno_t get_active_uid_linux(hash_table_t *table, uid_t search_uid) } if (errno != 0 && dirent == NULL) { ret = errno; - DEBUG(1, ("readdir failed.\n")); + DEBUG(1, "readdir failed.\n"); goto done; } ret = closedir(proc_dir); proc_dir = NULL; if (ret == -1) { - DEBUG(1, ("closedir failed, watch out.\n")); + DEBUG(1, "closedir failed, watch out.\n"); } if (table != NULL) { @@ -277,7 +277,7 @@ done: if (proc_dir != NULL) { err = closedir(proc_dir); if (err) { - DEBUG(1, ("closedir failed, bad dirp?\n")); + DEBUG(1, "closedir failed, bad dirp?\n"); } } return ret; @@ -292,7 +292,7 @@ errno_t get_uid_table(TALLOC_CTX *mem_ctx, hash_table_t **table) hash_talloc, hash_talloc_free, mem_ctx, NULL, NULL); if (ret != HASH_SUCCESS) { - DEBUG(1, ("hash_create_ex failed [%s]\n", hash_error_string(ret))); + DEBUG(1, "hash_create_ex failed [%s]\n", hash_error_string(ret)); return ENOMEM; } @@ -316,15 +316,15 @@ errno_t check_if_uid_is_active(uid_t uid, bool *result) *result = false; } if (ret < 0) { - DEBUG(SSSDBG_CRIT_FAILURE, ("systemd-login gave error %d: %s\n", - -ret, strerror(-ret))); + DEBUG(SSSDBG_CRIT_FAILURE, "systemd-login gave error %d: %s\n", + -ret, strerror(-ret)); } /* fall back to the old method */ #endif ret = get_active_uid_linux(NULL, uid); if (ret != EOK && ret != ENOENT) { - DEBUG(1, ("get_uid_table failed.\n")); + DEBUG(1, "get_uid_table failed.\n"); return ret; } |