summaryrefslogtreecommitdiffstats
path: root/src/util/server.c
diff options
context:
space:
mode:
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>2014-02-12 10:12:04 -0500
committerJakub Hrozek <jhrozek@redhat.com>2014-02-12 22:30:55 +0100
commita3c8390d19593b1e5277d95bfb4ab206d4785150 (patch)
tree2eb4e5432f4f79a75589c03b1513b656879ebf9c /src/util/server.c
parentcc026fd9ba386f2197e3217940d597dcad1a26fe (diff)
downloadsssd-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/server.c')
-rw-r--r--src/util/server.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/util/server.c b/src/util/server.c
index b2fad1168..24c3548ed 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -57,11 +57,11 @@ static void close_low_fds(void)
if (fd < 0)
fd = open("/dev/null", O_WRONLY, 0);
if (fd < 0) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Can't open /dev/null\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Can't open /dev/null\n");
return;
}
if (fd != i) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Didn't get file descriptor %d\n",i));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Didn't get file descriptor %d\n",i);
return;
}
}
@@ -101,8 +101,8 @@ void become_daemon(bool Fork)
error = errno;
if (error != EINTR) {
DEBUG(SSSDBG_CRIT_FAILURE,
- ("Error [%d][%s] while waiting for child\n",
- error, strerror(error)));
+ "Error [%d][%s] while waiting for child\n",
+ error, strerror(error));
/* Forcibly kill this child */
kill(pid, SIGKILL);
ret = 1;
@@ -130,8 +130,8 @@ void become_daemon(bool Fork)
errno = 0;
if(chdir("/") == -1) {
ret = errno;
- DEBUG(SSSDBG_FATAL_FAILURE, ("Cannot change directory (%d [%s])\n",
- ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Cannot change directory (%d [%s])\n",
+ ret, strerror(ret));
return;
}
@@ -164,7 +164,7 @@ int pidfile(const char *path, const char *name)
ret = errno;
if (len == -1) {
DEBUG(SSSDBG_CRIT_FAILURE,
- ("read failed [%d][%s].\n", ret, strerror(ret)));
+ "read failed [%d][%s].\n", ret, strerror(ret));
close(fd);
talloc_free(file);
return EINVAL;
@@ -220,14 +220,14 @@ int pidfile(const char *path, const char *name)
if (written == -1) {
err = errno;
DEBUG(SSSDBG_CRIT_FAILURE,
- ("write failed [%d][%s]\n", err, strerror(err)));
+ "write failed [%d][%s]\n", err, strerror(err));
close(fd);
return err;
}
if (written != size) {
DEBUG(SSSDBG_CRIT_FAILURE,
- ("Wrote %zd bytes expected %zu\n", written, size));
+ "Wrote %zd bytes expected %zu\n", written, size);
close(fd);
return EIO;
}
@@ -242,7 +242,7 @@ void orderly_shutdown(int status)
#if HAVE_GETPGRP
static int sent_sigterm;
if (sent_sigterm == 0 && getpgrp() == getpid()) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("SIGTERM: killing children\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE, "SIGTERM: killing children\n");
sent_sigterm = 1;
kill(-getpgrp(), SIGTERM);
}
@@ -265,7 +265,7 @@ static void default_quit(struct tevent_context *ev,
static void sig_segv_abrt(int sig)
{
DEBUG(SSSDBG_FATAL_FAILURE,
- ("Received signal %s, shutting down\n", strsignal(sig)));
+ "Received signal %s, shutting down\n", strsignal(sig));
orderly_shutdown(1);
}
#endif /* HAVE_PRCTL */
@@ -320,8 +320,8 @@ static void server_stdin_handler(struct tevent_context *event_ctx,
errno = 0;
if (sss_atomic_read_s(0, &c, 1) == 0) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("%s: EOF on stdin - terminating\n",
- binary_name));
+ DEBUG(SSSDBG_CRIT_FAILURE, "%s: EOF on stdin - terminating\n",
+ binary_name);
#if HAVE_GETPGRP
if (getpgrp() == getpid()) {
kill(-getpgrp(), SIGTERM);
@@ -344,8 +344,8 @@ int die_if_parent_died(void)
ret = prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0);
if (ret != 0) {
ret = errno;
- DEBUG(SSSDBG_OP_FAILURE, ("prctl failed [%d]: %s",
- ret, strerror(ret)));
+ DEBUG(SSSDBG_OP_FAILURE, "prctl failed [%d]: %s",
+ ret, strerror(ret));
return ret;
}
#endif
@@ -368,12 +368,12 @@ static void te_server_hup(struct tevent_context *ev,
struct logrotate_ctx *lctx =
talloc_get_type(private_data, struct logrotate_ctx);
- DEBUG(SSSDBG_CRIT_FAILURE, ("Received SIGHUP. Rotating logfiles.\n"));
+ DEBUG(SSSDBG_CRIT_FAILURE, "Received SIGHUP. Rotating logfiles.\n");
ret = monitor_common_rotate_logs(lctx->confdb, lctx->confdb_path);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Could not reopen log file [%s]\n",
- strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Could not reopen log file [%s]\n",
+ strerror(ret));
}
}
@@ -404,8 +404,8 @@ int server_setup(const char *name, int flags,
* value after reading domain from the configuration */
ret = unsetenv(SSS_DOM_ENV);
if (ret != 0) {
- DEBUG(SSSDBG_MINOR_FAILURE, ("Unsetting "SSS_DOM_ENV" failed, journald "
- "logging mightnot work as expected\n"));
+ DEBUG(SSSDBG_MINOR_FAILURE, "Unsetting "SSS_DOM_ENV" failed, journald "
+ "logging mightnot work as expected\n");
}
setup_signals();
@@ -415,15 +415,15 @@ int server_setup(const char *name, int flags,
umask(0177);
if (flags & FLAGS_DAEMON) {
- DEBUG(SSSDBG_IMPORTANT_INFO, ("Becoming a daemon.\n"));
+ DEBUG(SSSDBG_IMPORTANT_INFO, "Becoming a daemon.\n");
become_daemon(true);
}
if (flags & FLAGS_PID_FILE) {
ret = pidfile(PID_PATH, name);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Error creating pidfile: %s/%s! "
- "(%d [%s])\n", PID_PATH, name, ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error creating pidfile: %s/%s! "
+ "(%d [%s])\n", PID_PATH, name, ret, strerror(ret));
return ret;
}
}
@@ -438,7 +438,7 @@ int server_setup(const char *name, int flags,
event_ctx = tevent_context_init(talloc_autofree_context());
if (event_ctx == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
- ("The event context initialiaziton failed\n"));
+ "The event context initialiaziton failed\n");
return 1;
}
@@ -458,7 +458,7 @@ int server_setup(const char *name, int flags,
ctx = talloc(event_ctx, struct main_context);
if (ctx == NULL) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Out of memory, aborting!\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory, aborting!\n");
return ENOMEM;
}
@@ -467,13 +467,13 @@ int server_setup(const char *name, int flags,
conf_db = talloc_asprintf(ctx, "%s/%s", DB_PATH, CONFDB_FILE);
if (conf_db == NULL) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Out of memory, aborting!\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory, aborting!\n");
return ENOMEM;
}
ret = confdb_init(ctx, &ctx->confdb_ctx, conf_db);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("The confdb initialization failed\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE, "The confdb initialization failed\n");
return ret;
}
@@ -484,8 +484,8 @@ int server_setup(const char *name, int flags,
SSSDBG_DEFAULT,
&debug_level);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Error reading from confdb (%d) "
- "[%s]\n", ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) "
+ "[%s]\n", ret, strerror(ret));
return ret;
}
@@ -499,8 +499,8 @@ int server_setup(const char *name, int flags,
SSSDBG_TIMESTAMP_DEFAULT,
&dt);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Error reading from confdb (%d) "
- "[%s]\n", ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) "
+ "[%s]\n", ret, strerror(ret));
return ret;
}
if (dt) debug_timestamps = 1;
@@ -514,8 +514,8 @@ int server_setup(const char *name, int flags,
SSSDBG_MICROSECONDS_DEFAULT,
&dm);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Error reading from confdb (%d) "
- "[%s]\n", ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) "
+ "[%s]\n", ret, strerror(ret));
return ret;
}
if (dm) debug_microseconds = 1;
@@ -528,8 +528,8 @@ int server_setup(const char *name, int flags,
CONFDB_SERVICE_DEBUG_TO_FILES,
dl, &dl);
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Error reading from confdb (%d) [%s]\n",
- ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) [%s]\n",
+ ret, strerror(ret));
return ret;
}
if (dl) debug_to_file = 1;
@@ -551,15 +551,15 @@ int server_setup(const char *name, int flags,
if (debug_to_file) {
ret = open_debug_file();
if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Error setting up logging (%d) "
- "[%s]\n", ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error setting up logging (%d) "
+ "[%s]\n", ret, strerror(ret));
return ret;
}
}
sss_log(SSS_LOG_INFO, "Starting up");
- DEBUG(SSSDBG_TRACE_FUNC, ("CONFDB: %s\n", conf_db));
+ DEBUG(SSSDBG_TRACE_FUNC, "CONFDB: %s\n", conf_db);
if (flags & FLAGS_INTERACTIVE) {
/* terminate when stdin goes away */