[telepathy-gabble/master] Don't use a va_list twice.
Will Thompson
will.thompson at collabora.co.uk
Wed Jun 3 10:42:03 PDT 2009
Using a va_list twice within one va_start/va_end is not portable. You
have to start and end once per use. Here we just construct the formatted
message once, which I think is clearer.
Reviewed-by: Sjoerd Simons <sjoerd.simons at collabora.co.uk>
---
src/debug.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/debug.c b/src/debug.c
index 5534e61..1555eb6 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -103,21 +103,18 @@ gabble_debug_free (void)
static void
log_to_debugger (GabbleDebugFlags flag,
- const gchar *format,
- va_list args)
+ const gchar *message)
{
GabbleDebugger *dbg = gabble_debugger_get_singleton ();
- gchar *domain, *message = NULL;
+ gchar *domain;
GTimeVal now;
g_get_current_time (&now);
domain = g_strdup_printf ("%s/%s", G_LOG_DOMAIN, debug_flag_to_key (flag));
- message = g_strdup_vprintf (format, args);
gabble_debugger_add_message (dbg, &now, domain, G_LOG_LEVEL_DEBUG, message);
- g_free (message);
g_free (domain);
}
@@ -125,16 +122,19 @@ void gabble_debug (GabbleDebugFlags flag,
const gchar *format,
...)
{
+ gchar *message;
va_list args;
va_start (args, format);
+ message = g_strdup_vprintf (format, args);
+ va_end (args);
- log_to_debugger (flag, format, args);
+ log_to_debugger (flag, message);
if (flag & flags)
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s", message);
- va_end (args);
+ g_free (message);
}
#endif /* ENABLE_DEBUG */
--
1.5.6.5
More information about the telepathy-commits
mailing list