From 46c28ba3044c2121c2c0af4493ac655dcb41e0e6 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Wed, 12 Feb 2014 10:12:59 -0500 Subject: Update DEBUG* invocations to use new levels Use a script (identical to commit 83bf46f4066e3d5e838a32357c201de9bd6ecdfd) to update DEBUG* macro invocations, which use literal numbers for levels, to use bitmask macros instead: grep -rl --include '*.[hc]' DEBUG . | while read f; do mv "$f"{,.orig} perl -e 'use strict; use File::Slurp; my @map=qw" SSSDBG_FATAL_FAILURE SSSDBG_CRIT_FAILURE SSSDBG_OP_FAILURE SSSDBG_MINOR_FAILURE SSSDBG_CONF_SETTINGS SSSDBG_FUNC_DATA SSSDBG_TRACE_FUNC SSSDBG_TRACE_LIBS SSSDBG_TRACE_INTERNAL SSSDBG_TRACE_ALL "; my $text=read_file(\*STDIN); my $repl; $text=~s/ ^ ( .* \b (DEBUG|DEBUG_PAM_DATA|DEBUG_GR_MEM) \s* \(\s* )( [0-9] )( \s*, ) ( \s* ) ( .* ) $ / $repl = $1.$map[$3].$4.$5.$6, length($repl) <= 80 ? $repl : $1.$map[$3].$4."\n".(" " x length($1)).$6 /xmge; print $text; ' < "$f.orig" > "$f" rm "$f.orig" done --- src/sbus/sssd_dbus_connection.c | 53 ++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'src/sbus/sssd_dbus_connection.c') diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c index 60b06a432..b32164827 100644 --- a/src/sbus/sssd_dbus_connection.c +++ b/src/sbus/sssd_dbus_connection.c @@ -57,12 +57,12 @@ static void sbus_dispatch(struct tevent_context *ev, DEBUG(SSSDBG_TRACE_ALL, "dbus conn: %p\n", dbus_conn); if (conn->retries > 0) { - DEBUG(6, "SBUS is reconnecting. Deferring.\n"); + DEBUG(SSSDBG_TRACE_FUNC, "SBUS is reconnecting. Deferring.\n"); /* Currently trying to reconnect, defer dispatch for 30ms */ tv = tevent_timeval_current_ofs(0, 30); new_event = tevent_add_timer(ev, conn, tv, sbus_dispatch, conn); if (new_event == NULL) { - DEBUG(0,"Could not defer dispatch!\n"); + DEBUG(SSSDBG_FATAL_FAILURE,"Could not defer dispatch!\n"); } return; } @@ -72,11 +72,11 @@ static void sbus_dispatch(struct tevent_context *ev, /* Attempt to reconnect automatically */ ret = sbus_auto_reconnect(conn); if (ret == EOK) { - DEBUG(1, "Performing auto-reconnect\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Performing auto-reconnect\n"); return; } - DEBUG(0, "Cannot start auto-reconnection.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Cannot start auto-reconnection.\n"); conn->reconnect_callback(conn, SBUS_RECONNECT_ERROR, conn->reconnect_pvt); @@ -85,7 +85,7 @@ static void sbus_dispatch(struct tevent_context *ev, if ((conn->disconnect) || (!dbus_connection_get_is_connected(dbus_conn))) { - DEBUG(3,"Connection is not open for dispatching.\n"); + DEBUG(SSSDBG_MINOR_FAILURE,"Connection is not open for dispatching.\n"); /* * Free the connection object. * This will invoke the destructor for the connection @@ -100,7 +100,7 @@ static void sbus_dispatch(struct tevent_context *ev, */ ret = dbus_connection_get_dispatch_status(dbus_conn); if (ret != DBUS_DISPATCH_COMPLETE) { - DEBUG(9,"Dispatching.\n"); + DEBUG(SSSDBG_TRACE_ALL,"Dispatching.\n"); dbus_connection_dispatch(dbus_conn); } @@ -111,7 +111,7 @@ static void sbus_dispatch(struct tevent_context *ev, if (ret != DBUS_DISPATCH_COMPLETE) { new_event = tevent_add_timer(ev, conn, tv, sbus_dispatch, conn); if (new_event == NULL) { - DEBUG(2,"Could not add dispatch event!\n"); + DEBUG(SSSDBG_OP_FAILURE,"Could not add dispatch event!\n"); /* TODO: Calling exit here is bad */ exit(1); @@ -139,7 +139,7 @@ static void sbus_conn_wakeup_main(void *data) /* D-BUS calls this function when it is time to do a dispatch */ te = tevent_add_timer(conn->ev, conn, tv, sbus_dispatch, conn); if (te == NULL) { - DEBUG(2,"Could not add dispatch event!\n"); + DEBUG(SSSDBG_OP_FAILURE,"Could not add dispatch event!\n"); /* TODO: Calling exit here is bad */ exit(1); } @@ -204,7 +204,8 @@ static int sbus_conn_set_fns(struct sbus_connection *conn) sbus_toggle_watch, conn, NULL); if (!dbret) { - DEBUG(2,"Error setting up D-BUS connection watch functions\n"); + DEBUG(SSSDBG_OP_FAILURE, + "Error setting up D-BUS connection watch functions\n"); return EIO; } @@ -215,7 +216,8 @@ static int sbus_conn_set_fns(struct sbus_connection *conn) sbus_toggle_timeout, conn, NULL); if (!dbret) { - DEBUG(2,"Error setting up D-BUS server timeout functions\n"); + DEBUG(SSSDBG_OP_FAILURE, + "Error setting up D-BUS server timeout functions\n"); /* FIXME: free resources ? */ return EIO; } @@ -251,7 +253,8 @@ int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev, /* Open a shared D-BUS connection to the address */ dbus_conn = dbus_connection_open(address, &dbus_error); if (!dbus_conn) { - DEBUG(1, "Failed to open connection: name=%s, message=%s\n", + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to open connection: name=%s, message=%s\n", dbus_error.name, dbus_error.message); if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error); return EIO; @@ -307,7 +310,8 @@ int sbus_default_connection_destructor(void *ctx) } else { /* Critical Error! */ - DEBUG(1,"Critical Error, connection_type is neither shared nor private!\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "Critical Error, connection_type is neither shared nor private!\n"); return -1; } @@ -410,7 +414,7 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn, intf_p = talloc_get_type(user_data, struct sbus_interface_p); method = dbus_message_get_member(message); - DEBUG(9, "Received SBUS method [%s]\n", method); + DEBUG(SSSDBG_TRACE_ALL, "Received SBUS method [%s]\n", method); path = dbus_message_get_path(message); msg_interface = dbus_message_get_interface(message); @@ -437,7 +441,8 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn, if (!found) { /* Reply DBUS_ERROR_UNKNOWN_METHOD */ - DEBUG(1, "No matching method found for %s.\n", method); + DEBUG(SSSDBG_CRIT_FAILURE, + "No matching method found for %s.\n", method); reply = dbus_message_new_error(message, DBUS_ERROR_UNKNOWN_METHOD, NULL); sbus_conn_send_reply(intf_p->conn, reply); dbus_message_unref(reply); @@ -484,7 +489,8 @@ int sbus_conn_add_interface(struct sbus_connection *conn, path = intf->path; if (path_in_interface_list(conn->intf_list, path)) { - DEBUG(0, "Cannot add method context with identical path.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Cannot add method context with identical path.\n"); return EINVAL; } @@ -500,7 +506,8 @@ int sbus_conn_add_interface(struct sbus_connection *conn, dbret = dbus_connection_register_object_path(conn->dbus.conn, path, &intf->vtable, intf_p); if (!dbret) { - DEBUG(0, "Could not register object path to the connection.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not register object path to the connection.\n"); return ENOMEM; } @@ -561,12 +568,12 @@ static void sbus_reconnect(struct tevent_context *ev, conn = talloc_get_type(data, struct sbus_connection); dbus_error_init(&dbus_error); - DEBUG(3, "Making reconnection attempt %d to [%s]\n", + DEBUG(SSSDBG_MINOR_FAILURE, "Making reconnection attempt %d to [%s]\n", conn->retries, conn->address); conn->dbus.conn = dbus_connection_open(conn->address, &dbus_error); if (conn->dbus.conn) { /* We successfully reconnected. Set up mainloop integration. */ - DEBUG(3, "Reconnected to [%s]\n", conn->address); + DEBUG(SSSDBG_MINOR_FAILURE, "Reconnected to [%s]\n", conn->address); ret = sbus_conn_set_fns(conn); if (ret != EOK) { dbus_connection_unref(conn->dbus.conn); @@ -581,7 +588,8 @@ static void sbus_reconnect(struct tevent_context *ev, &iter->intf->vtable, iter); if (!dbret) { - DEBUG(0, "Could not register object path.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, + "Could not register object path.\n"); dbus_connection_unref(conn->dbus.conn); goto failed; } @@ -602,7 +610,8 @@ static void sbus_reconnect(struct tevent_context *ev, failed: /* Reconnection failed, try again in a few seconds */ - DEBUG(1, "Failed to open connection: name=%s, message=%s\n", + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to open connection: name=%s, message=%s\n", dbus_error.name, dbus_error.message); if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error); @@ -720,7 +729,7 @@ int sbus_conn_send(struct sbus_connection *conn, * Critical Failure * Insufficient memory to send message */ - DEBUG(0, "D-BUS send failed.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "D-BUS send failed.\n"); return ENOMEM; } @@ -733,7 +742,7 @@ int sbus_conn_send(struct sbus_connection *conn, * Critical Failure * Insufficient memory to create pending call notify */ - DEBUG(0, "D-BUS send failed.\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "D-BUS send failed.\n"); dbus_pending_call_cancel(pending_reply); dbus_pending_call_unref(pending_reply); return ENOMEM; -- cgit