[brasero/wip/lantw/fix-build-with-modern-compilers: 2/3] build: Fix non-literal format string error for clang
- From: Ting-Wei Lan <lantw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [brasero/wip/lantw/fix-build-with-modern-compilers: 2/3] build: Fix non-literal format string error for clang
- Date: Sat, 22 Sep 2018 03:13:16 +0000 (UTC)
commit 20ba32ead3a2d218ff2fc36ec2a8818c2e66efef
Author: Ting-Wei Lan <lantw src gnome org>
Date: Thu Apr 2 16:07:22 2015 +0800
build: Fix non-literal format string error for clang
https://bugzilla.gnome.org/show_bug.cgi?id=747226
libbrasero-burn/brasero-burn.c | 14 +++-----
libbrasero-burn/brasero-session-helper.h | 4 +--
libbrasero-burn/burn-debug.c | 56 ++++++++++++--------------------
libbrasero-burn/burn-debug.h | 10 +++---
libbrasero-burn/burn-job.h | 16 +++------
libbrasero-burn/burn-plugin.c | 3 ++
libbrasero-burn/burn-process.c | 29 ++++++++---------
libbrasero-media/brasero-media-private.h | 2 +-
libbrasero-media/brasero-media.c | 9 ++---
libbrasero-utils/brasero-misc.c | 9 ++---
libbrasero-utils/brasero-misc.h | 2 +-
plugins/transcode/burn-normalize.c | 2 +-
plugins/transcode/burn-transcode.c | 2 +-
plugins/transcode/burn-vob.c | 2 +-
14 files changed, 64 insertions(+), 96 deletions(-)
---
diff --git a/libbrasero-burn/brasero-burn.c b/libbrasero-burn/brasero-burn.c
index 5e1577be..dc4d198a 100644
--- a/libbrasero-burn/brasero-burn.c
+++ b/libbrasero-burn/brasero-burn.c
@@ -112,16 +112,12 @@ struct _BraseroBurnPrivate {
#define BRASERO_BURN_DEBUG(burn, message, ...) \
{ \
- gchar *format; \
BRASERO_BURN_LOG (message, ##__VA_ARGS__); \
- format = g_strdup_printf ("%s (%s %s)", \
- message, \
- G_STRFUNC, \
- G_STRLOC); \
brasero_burn_log (burn, \
- format, \
- ##__VA_ARGS__); \
- g_free (format); \
+ message " (%s %s)", \
+ ##__VA_ARGS__, \
+ G_STRFUNC, \
+ G_STRLOC); \
}
typedef enum {
@@ -178,7 +174,7 @@ brasero_burn_new ()
return g_object_new (BRASERO_TYPE_BURN, NULL);
}
-static void
+G_GNUC_PRINTF (2, 3) static void
brasero_burn_log (BraseroBurn *burn,
const gchar *format,
...)
diff --git a/libbrasero-burn/brasero-session-helper.h b/libbrasero-burn/brasero-session-helper.h
index 15543c38..b83487a9 100644
--- a/libbrasero-burn/brasero-session-helper.h
+++ b/libbrasero-burn/brasero-session-helper.h
@@ -123,11 +123,11 @@ brasero_burn_session_stop (BraseroBurnSession *session);
void
brasero_burn_session_logv (BraseroBurnSession *session,
const gchar *format,
- va_list arg_list);
+ va_list arg_list) G_GNUC_PRINTF (2, 0);
void
brasero_burn_session_log (BraseroBurnSession *session,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (2, 3);
/**
* Allow to save a whole session settings/source and restore it later.
diff --git a/libbrasero-burn/burn-debug.c b/libbrasero-burn/burn-debug.c
index e84d2be4..f0a57239 100644
--- a/libbrasero-burn/burn-debug.c
+++ b/libbrasero-burn/burn-debug.c
@@ -98,20 +98,17 @@ brasero_burn_debug_message (const gchar *location,
...)
{
va_list arg_list;
- gchar *format_real;
if (!debug)
return;
- format_real = g_strdup_printf ("BraseroBurn: (at %s) %s\n",
- location,
- format);
+ printf ("BraseroBurn: (at %s) ", location);
va_start (arg_list, format);
- vprintf (format_real, arg_list);
+ vprintf (format, arg_list);
va_end (arg_list);
- g_free (format_real);
+ putchar ('\n');
}
void
@@ -119,17 +116,12 @@ brasero_burn_debug_messagev (const gchar *location,
const gchar *format,
va_list arg_list)
{
- gchar *format_real;
-
if (!debug)
return;
- format_real = g_strdup_printf ("BraseroBurn: (at %s) %s\n",
- location,
- format);
-
- vprintf (format_real, arg_list);
- g_free (format_real);
+ printf ("BraseroBurn: (at %s) ", location);
+ vprintf (format, arg_list);
+ putchar ('\n');
}
static void
@@ -173,7 +165,6 @@ brasero_burn_debug_flags_type_message (BraseroBurnFlag flags,
...)
{
gchar buffer [256] = {0};
- gchar *format_real;
va_list arg_list;
if (!debug)
@@ -181,16 +172,15 @@ brasero_burn_debug_flags_type_message (BraseroBurnFlag flags,
brasero_debug_burn_flags_to_string (buffer, flags);
- format_real = g_strdup_printf ("BraseroBurn: (at %s) %s %s\n",
- location,
- format,
- buffer);
+ printf ("BraseroBurn: (at %s) ", location);
va_start (arg_list, format);
- vprintf (format_real, arg_list);
+ vprintf (format, arg_list);
va_end (arg_list);
- g_free (format_real);
+ putchar (' ');
+ fputs (buffer, stdout);
+ putchar ('\n');
}
static void
@@ -276,7 +266,6 @@ brasero_burn_debug_track_type_struct_message (BraseroTrackType *type,
...)
{
gchar buffer [256];
- gchar *format_real;
va_list arg_list;
if (!debug)
@@ -319,16 +308,15 @@ brasero_burn_debug_track_type_struct_message (BraseroTrackType *type,
else
strcpy (buffer, "Undefined");
- format_real = g_strdup_printf ("BraseroBurn: (at %s) %s %s\n",
- location,
- format,
- buffer);
+ printf ("BraseroBurn: (at %s) ", location);
va_start (arg_list, format);
- vprintf (format_real, arg_list);
+ vprintf (format, arg_list);
va_end (arg_list);
- g_free (format_real);
+ putchar (' ');
+ fputs (buffer, stdout);
+ putchar ('\n');
}
void
@@ -340,7 +328,6 @@ brasero_burn_debug_track_type_message (BraseroTrackDataType type,
...)
{
gchar buffer [256];
- gchar *format_real;
va_list arg_list;
if (!debug)
@@ -386,15 +373,14 @@ brasero_burn_debug_track_type_message (BraseroTrackDataType type,
break;
}
- format_real = g_strdup_printf ("BraseroBurn: (at %s) %s %s\n",
- location,
- format,
- buffer);
+ printf ("BraseroBurn: (at %s) ", location);
va_start (arg_list, format);
- vprintf (format_real, arg_list);
+ vprintf (format, arg_list);
va_end (arg_list);
- g_free (format_real);
+ putchar (' ');
+ fputs (buffer, stdout);
+ putchar ('\n');
}
diff --git a/libbrasero-burn/burn-debug.h b/libbrasero-burn/burn-debug.h
index cae79b0d..66f94388 100644
--- a/libbrasero-burn/burn-debug.h
+++ b/libbrasero-burn/burn-debug.h
@@ -98,28 +98,28 @@ brasero_burn_debug_track_type_struct_message (BraseroTrackType *type,
BraseroPluginIOFlag flags,
const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (4, 5);
void
brasero_burn_debug_track_type_message (BraseroTrackDataType type,
guint subtype,
BraseroPluginIOFlag flags,
const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (5, 6);
void
brasero_burn_debug_flags_type_message (BraseroBurnFlag flags,
const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (3, 4);
void
brasero_burn_debug_message (const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (2, 3);
void
brasero_burn_debug_messagev (const gchar *location,
const gchar *format,
- va_list args);
+ va_list args) G_GNUC_PRINTF (2, 0);
G_END_DECLS
diff --git a/libbrasero-burn/burn-job.h b/libbrasero-burn/burn-job.h
index 59c91735..5e234b03 100644
--- a/libbrasero-burn/burn-job.h
+++ b/libbrasero-burn/burn-job.h
@@ -311,30 +311,22 @@ void
brasero_job_log_message (BraseroJob *job,
const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (3, 4);
#define BRASERO_JOB_LOG(job, message, ...) \
{ \
- gchar *format; \
- format = g_strdup_printf ("%s %s", \
- G_OBJECT_TYPE_NAME (job), \
- message); \
brasero_job_log_message (BRASERO_JOB (job), \
G_STRLOC, \
- format, \
+ "%s " message, \
+ G_OBJECT_TYPE_NAME (job), \
##__VA_ARGS__); \
- g_free (format); \
}
#define BRASERO_JOB_LOG_ARG(job, message, ...) \
{ \
- gchar *format; \
- format = g_strdup_printf ("\t%s", \
- (gchar*) message); \
brasero_job_log_message (BRASERO_JOB (job), \
G_STRLOC, \
- format, \
+ "\t" message, \
##__VA_ARGS__); \
- g_free (format); \
}
#define BRASERO_JOB_NOT_SUPPORTED(job) \
diff --git a/libbrasero-burn/burn-plugin.c b/libbrasero-burn/burn-plugin.c
index f97bc5fa..739b8ff7 100644
--- a/libbrasero-burn/burn-plugin.c
+++ b/libbrasero-burn/burn-plugin.c
@@ -277,8 +277,11 @@ brasero_plugin_test_app (BraseroPlugin *plugin,
for (i = 0; i < 3 && version [i] >= 0; i++);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
if ((standard_output && sscanf (standard_output, version_format, &major, &minor, &sub) == i)
|| (standard_error && sscanf (standard_error, version_format, &major, &minor, &sub) == i)) {
+#pragma clang diagnostic pop
if (major < version [0]
|| (version [1] >= 0 && minor < version [1])
|| (version [2] >= 0 && sub < version [2]))
diff --git a/libbrasero-burn/burn-process.c b/libbrasero-burn/burn-process.c
index bd0b8d56..4d0b2da3 100644
--- a/libbrasero-burn/burn-process.c
+++ b/libbrasero-burn/burn-process.c
@@ -62,10 +62,6 @@ enum {
BRASERO_CHANNEL_STDERR
};
-static const gchar *debug_prefixes [] = { "stdout: %s",
- "stderr: %s",
- NULL };
-
typedef BraseroBurnResult (*BraseroProcessReadFunc) (BraseroProcess *process,
const gchar *line);
@@ -143,6 +139,7 @@ brasero_process_ask_argv (BraseroJob *job,
for (i = 0; priv->argv->pdata [i]; i++)
BRASERO_JOB_LOG_ARG (process,
+ "%s",
priv->argv->pdata [i]);
if (result != BRASERO_BURN_OK) {
@@ -327,6 +324,14 @@ brasero_process_watch_child (gpointer data)
return FALSE;
}
+#define PROCESS_READ_LOG(msg) \
+{ \
+ if (channel_type == BRASERO_CHANNEL_STDERR) \
+ BRASERO_JOB_LOG (process, "stderr: %s", msg) \
+ else \
+ BRASERO_JOB_LOG (process, "stdout: %s", msg) \
+}
+
static gboolean
brasero_process_read (BraseroProcess *process,
GIOChannel *channel,
@@ -377,9 +382,7 @@ brasero_process_read (BraseroProcess *process,
case '\r':
case '\xe2': /* Unicode paragraph separator */
case '\0':
- BRASERO_JOB_LOG (process,
- debug_prefixes [channel_type],
- buffer->str);
+ PROCESS_READ_LOG (buffer->str);
if (readfunc && buffer->str [0] != '\0')
result = readfunc (process, buffer->str);
@@ -412,9 +415,7 @@ brasero_process_read (BraseroProcess *process,
g_string_append (buffer, line);
g_free (line);
- BRASERO_JOB_LOG (process,
- debug_prefixes [channel_type],
- buffer->str);
+ PROCESS_READ_LOG (buffer->str);
if (readfunc && buffer->str [0] != '\0')
result = readfunc (process, buffer->str);
@@ -435,9 +436,7 @@ brasero_process_read (BraseroProcess *process,
return FALSE;
}
else if (status == G_IO_STATUS_EOF) {
- BRASERO_JOB_LOG (process,
- debug_prefixes [channel_type],
- "EOF");
+ PROCESS_READ_LOG ("EOF");
return FALSE;
}
else
@@ -445,9 +444,7 @@ brasero_process_read (BraseroProcess *process,
}
else if (condition & G_IO_HUP) {
/* only handle the HUP when we have read all available lines of output */
- BRASERO_JOB_LOG (process,
- debug_prefixes [channel_type],
- "HUP");
+ PROCESS_READ_LOG ("HUP");
return FALSE;
}
diff --git a/libbrasero-media/brasero-media-private.h b/libbrasero-media/brasero-media-private.h
index 365e9e1e..0358edde 100644
--- a/libbrasero-media/brasero-media-private.h
+++ b/libbrasero-media/brasero-media-private.h
@@ -64,7 +64,7 @@ brasero_media_to_string (BraseroMedia media,
void
brasero_media_message (const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (2, 3);
G_END_DECLS
diff --git a/libbrasero-media/brasero-media.c b/libbrasero-media/brasero-media.c
index 7ef28377..ad4f1aa2 100644
--- a/libbrasero-media/brasero-media.c
+++ b/libbrasero-media/brasero-media.c
@@ -488,20 +488,17 @@ brasero_media_message (const gchar *location,
...)
{
va_list arg_list;
- gchar *format_real;
if (!debug)
return;
- format_real = g_strdup_printf ("BraseroMedia: (at %s) %s\n",
- location,
- format);
+ format = printf ("BraseroMedia: (at %s) ", location);
va_start (arg_list, format);
- vprintf (format_real, arg_list);
+ vprintf (format, arg_list);
va_end (arg_list);
- g_free (format_real);
+ putchar ('\n');
}
#include <gtk/gtk.h>
diff --git a/libbrasero-utils/brasero-misc.c b/libbrasero-utils/brasero-misc.c
index 594d5a8b..c088953e 100644
--- a/libbrasero-utils/brasero-misc.c
+++ b/libbrasero-utils/brasero-misc.c
@@ -102,20 +102,17 @@ brasero_utils_debug_message (const gchar *location,
...)
{
va_list arg_list;
- gchar *format_real;
if (!use_debug)
return;
- format_real = g_strdup_printf ("BraseroUtils: (at %s) %s\n",
- location,
- format);
+ g_strdup_printf ("BraseroUtils: (at %s) ", location);
va_start (arg_list, format);
- vprintf (format_real, arg_list);
+ vprintf (format, arg_list);
va_end (arg_list);
- g_free (format_real);
+ putchar ('\n');
}
static gboolean
diff --git a/libbrasero-utils/brasero-misc.h b/libbrasero-utils/brasero-misc.h
index 26ccf955..b6f72ef6 100644
--- a/libbrasero-utils/brasero-misc.h
+++ b/libbrasero-utils/brasero-misc.h
@@ -55,7 +55,7 @@ brasero_utils_set_use_debug (gboolean active);
void
brasero_utils_debug_message (const gchar *location,
const gchar *format,
- ...);
+ ...) G_GNUC_PRINTF (2, 3);
#define BRASERO_UTILS_LOG(format, ...) \
brasero_utils_debug_message (G_STRLOC, \
diff --git a/plugins/transcode/burn-normalize.c b/plugins/transcode/burn-normalize.c
index 1a71b02e..c7f780f5 100644
--- a/plugins/transcode/burn-normalize.c
+++ b/plugins/transcode/burn-normalize.c
@@ -502,7 +502,7 @@ brasero_normalize_bus_messages (GstBus *bus,
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &error, &debug);
- BRASERO_JOB_LOG (normalize, debug);
+ BRASERO_JOB_LOG (normalize, "%s", debug);
g_free (debug);
brasero_job_error (BRASERO_JOB (normalize), error);
diff --git a/plugins/transcode/burn-transcode.c b/plugins/transcode/burn-transcode.c
index b93d17af..05f2b28a 100644
--- a/plugins/transcode/burn-transcode.c
+++ b/plugins/transcode/burn-transcode.c
@@ -1549,7 +1549,7 @@ brasero_transcode_bus_messages (GstBus *bus,
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &error, &debug);
- BRASERO_JOB_LOG (transcode, debug);
+ BRASERO_JOB_LOG (transcode, "%s", debug);
g_free (debug);
brasero_job_error (BRASERO_JOB (transcode), error);
diff --git a/plugins/transcode/burn-vob.c b/plugins/transcode/burn-vob.c
index 1ddcdefa..f92a0a26 100644
--- a/plugins/transcode/burn-vob.c
+++ b/plugins/transcode/burn-vob.c
@@ -142,7 +142,7 @@ brasero_vob_bus_messages (GstBus *bus,
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &error, &debug);
- BRASERO_JOB_LOG (vob, debug);
+ BRASERO_JOB_LOG (vob, "%s", debug);
g_free (debug);
brasero_job_error (BRASERO_JOB (vob), error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]