[dia] [warningectomy] format string is not a string literal
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [warningectomy] format string is not a string literal
- Date: Wed, 1 Oct 2014 22:35:03 +0000 (UTC)
commit 53e0ac25fd0034d5cc625b81e0f00086cc9368a4
Author: Hans Breuer <hans breuer org>
Date: Wed Oct 1 23:38:35 2014 +0200
[warningectomy] format string is not a string literal
Sprinkle G_GNUC_PRINTF() to avoid the following warnings and get some new ones.
message.c:180:38: warning: format string is not a string literal [-Wformat-nonliteral]
len = g_printf_string_upper_bound (fmt, args);
^~~
message.c:190:18: warning: format string is not a string literal [-Wformat-nonliteral]
vsprintf (buf, fmt, args2);
^~~
dialib.c:46:38: warning: format string is not a string literal [-Wformat-nonliteral]
len = g_printf_string_upper_bound (fmt, args);
^~~
dialib.c:57:18: warning: format string is not a string literal [-Wformat-nonliteral]
vsprintf (buf, fmt, args2);
^~~
diacontext.c:162:27: warning: format string is not a string literal [-Wformat-nonliteral]
msg = g_strdup_vprintf (format, args);
^~~~~~
diacontext.c:181:27: warning: format string is not a string literal [-Wformat-nonliteral]
msg = g_strdup_vprintf (format, args);
^~~~~~
lib/dia_image.c | 2 +-
lib/diacontext.h | 4 ++--
lib/dialib.c | 4 ++++
lib/message.c | 5 +++++
lib/message.h | 10 +++++-----
objects/custom/shape_typeinfo.c | 4 ++++
6 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/lib/dia_image.c b/lib/dia_image.c
index 9cbddd0..c733e69 100644
--- a/lib/dia_image.c
+++ b/lib/dia_image.c
@@ -342,7 +342,7 @@ dia_image_save(DiaImage *image, const gchar *filename)
image->filename = g_strdup (filename);
} else if (!type) {
/* pathologic case - pixbuf not even supporting PNG? */
- message_error(_("Unsupported file format for saving:\n%s\n%s\n"),
+ message_error(_("Unsupported file format for saving:\n%s\n"),
dia_message_filename(filename));
} else {
message_warning(_("Could not save file:\n%s\n%s\n"),
diff --git a/lib/diacontext.h b/lib/diacontext.h
index 54fc446..cf9f1ea 100644
--- a/lib/diacontext.h
+++ b/lib/diacontext.h
@@ -11,8 +11,8 @@ void dia_context_reset (DiaContext *context);
void dia_context_release (DiaContext *context);
void dia_context_set_filename (DiaContext *context, const char *filename);
-void dia_context_add_message (DiaContext *context, const char *fomat, ...);
-void dia_context_add_message_with_errno (DiaContext *context, int nr, const char *fomat, ...);
+void dia_context_add_message (DiaContext *context, const char *fomat, ...) G_GNUC_PRINTF(2, 3);
+void dia_context_add_message_with_errno (DiaContext *context, int nr, const char *fomat, ...)
G_GNUC_PRINTF(3, 4);
const char *dia_context_get_filename (DiaContext *context);
diff --git a/lib/dialib.c b/lib/dialib.c
index b6b3386..2d99e66 100644
--- a/lib/dialib.c
+++ b/lib/dialib.c
@@ -37,6 +37,10 @@
static void
stderr_message_internal(const char *title, enum ShowAgainStyle showAgain,
+ const char *fmt, va_list args, va_list args2) G_GNUC_PRINTF(3, 0);
+
+static void
+stderr_message_internal(const char *title, enum ShowAgainStyle showAgain,
const char *fmt, va_list args, va_list args2)
{
static gchar *buf = NULL;
diff --git a/lib/message.c b/lib/message.c
index 149d454..5a7e821 100644
--- a/lib/message.c
+++ b/lib/message.c
@@ -153,6 +153,11 @@ message_create_dialog(const gchar *title, DiaMessageInfo *msginfo, gchar *buf)
static void
gtk_message_internal(const char* title, enum ShowAgainStyle showAgain,
char const *fmt,
+ va_list args, va_list args2) G_GNUC_PRINTF(3, 0);
+
+static void
+gtk_message_internal(const char* title, enum ShowAgainStyle showAgain,
+ char const *fmt,
va_list args, va_list args2)
{
static gchar *buf = NULL;
diff --git a/lib/message.h b/lib/message.h
index dfb5106..96aacc8 100644
--- a/lib/message.h
+++ b/lib/message.h
@@ -33,12 +33,12 @@ typedef void (*MessageInternal)(const char *title, enum ShowAgainStyle showAgain
va_list args, va_list args2);
void set_message_func(MessageInternal func);
-void message(const char *title, const char *format, ...);
-void message_notice(const char *format, ...);
-void message_warning(const char *format, ...);
-void message_error(const char *format, ...);
+void message(const char *title, const char *format, ...) G_GNUC_PRINTF(2, 3);
+void message_notice(const char *format, ...) G_GNUC_PRINTF(1, 2);
+void message_warning(const char *format, ...) G_GNUC_PRINTF(1, 2);
+void message_error(const char *format, ...) G_GNUC_PRINTF(1, 2);
-void dia_log_message(const char *format, ...);
+void dia_log_message(const char *format, ...) G_GNUC_PRINTF(1, 2);
void dia_log_message_enable (gboolean yes);
/* also declared in dia_dirs.h, where I think it does not belong! --hb */
const gchar *dia_message_filename (const gchar *filename);
diff --git a/objects/custom/shape_typeinfo.c b/objects/custom/shape_typeinfo.c
index 6f3d7cd..bbcd697 100644
--- a/objects/custom/shape_typeinfo.c
+++ b/objects/custom/shape_typeinfo.c
@@ -146,6 +146,8 @@ endElementNs (void *ctx,
context->state = READ_ON;
}
+static void _error (void *ctx, const char * msg, ...) G_GNUC_PRINTF(2, 3);
+
static void
_error (void *ctx,
const char * msg,
@@ -163,6 +165,8 @@ _error (void *ctx,
va_end(args);
}
+static void _warning (void *ctx, const char * msg, ...) G_GNUC_PRINTF(2, 3);
+
static void
_warning (void *ctx,
const char * msg,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]