[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: Sat, 4 Oct 2014 11:06:17 +0000 (UTC)
commit 980f70c22321d31c10b6c68fae0931cba5ec2a60
Author: Hans Breuer <hans breuer org>
Date: Fri Oct 3 21:30:20 2014 +0200
[warningectomy] format string is not a string literal
Now also fix dia_assert_true() declaration and use.
debug.c:39:15: warning: format string is not a string literal [-Wformat-nonliteral]
g_vprintf(format, args);
^~~~~~
And followup warnings of the fix:
object.c:1109:49: warning: more '%' conversions than data arguments [-Wformat]
"%s: Object %p has illegal type name %p (%s)\n",
~^
object.c:1118:45: warning: format specifies type 'char *' but the argument has
type 'const DiaObject *' (aka 'const struct _DiaObject *') [-Wformat]
"%s: Object %p has null handles\n", obj);
~~ ^~~
object.c:1118:22: warning: more '%' conversions than data arguments [-Wformat]
"%s: Object %p has null handles\n", obj);
~^
lib/debug.c | 3 ++-
lib/debug.h | 3 ++-
lib/object.c | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/lib/debug.c b/lib/debug.c
index 3c8a962..348069b 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -32,7 +32,8 @@
* @return val
*/
gboolean
-dia_assert_true(gboolean val, gchar *format, ...) {
+dia_assert_true(gboolean val, const gchar *format, ...)
+{
va_list args;
if (!val) {
va_start(args, format);
diff --git a/lib/debug.h b/lib/debug.h
index 205b3e1..bacc982 100644
--- a/lib/debug.h
+++ b/lib/debug.h
@@ -25,7 +25,8 @@
#include <stdio.h>
#include <stdarg.h>
+#include <glib.h>
-gboolean dia_assert_true(gboolean val, gchar *format, ...);
+gboolean dia_assert_true(gboolean val, const gchar *format, ...) G_GNUC_PRINTF(2,3);
#endif
diff --git a/lib/object.c b/lib/object.c
index e9107f9..7a7ac10 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1106,7 +1106,7 @@ dia_object_sanity_check(const DiaObject *obj, const gchar *msg) {
if (obj != NULL) {
dia_assert_true(obj->type->name != NULL &&
g_utf8_validate(obj->type->name, -1, NULL),
- "%s: Object %p has illegal type name %p (%s)\n",
+ "%s: Object %p has illegal type name '%s'\n",
msg, obj, obj->type->name);
/* Check the position vs. the bounding box */
/* Check the handles */
@@ -1115,7 +1115,7 @@ dia_object_sanity_check(const DiaObject *obj, const gchar *msg) {
msg, obj, obj->num_handles);
if (obj->num_handles != 0) {
dia_assert_true(obj->handles != NULL,
- "%s: Object %p has null handles\n", obj);
+ "%s: Object %p has null handles\n", msg, obj);
}
for (i = 0; i < obj->num_handles; i++) {
Handle *h = obj->handles[i];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]