On Sunday 06,February,2011 07:27 PM, Alexander Petukhov wrote:
> dbm_bash.c is excluded from autotools build, because it doesn't work for now.
> As to cast warnings, I don't have them, can guess it's about glib, cause its 
> function are called 
> at lines that were mentioned.
> Regarding build system, yeah I didn't get clear about commom autoconf and 
> gettext package, will change it today.
> 

Hi Alex,

I've just committed some changes to integrate the debugger plugin into the
current geany-plugins autotools build system. While building, I encountered the
warnings/errors. They come from improper use of Glib, and from casting pointers
into ints and vice versa.

The attached patches should fix the warnings. Please review them and commit as
you see fit.

-- 
Kind regards,
Loong Jin
From 25cb90633972f221535745d9beaab64e69cfe861 Mon Sep 17 00:00:00 2001
From: Chow Loong Jin <[email protected]>
Date: Thu, 10 Feb 2011 00:34:03 +0800
Subject: [PATCH 1/3] Fix integer size mismatch while casting

 * Use GPOINTER_TO_INT and GINT_TO_POINTER for handling pointer/int
   conversion
 * Use the trinary operator (condition ? true : false) for checking
   null value of a pointer
---
 debugger/src/breakpoints.c |   12 +++++++-----
 debugger/src/dbm_gdb.c     |    4 ++--
 debugger/src/stree.c       |    6 +++---
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/debugger/src/breakpoints.c b/debugger/src/breakpoints.c
index 3d3d8aa..ca0ef4e 100644
--- a/debugger/src/breakpoints.c
+++ b/debugger/src/breakpoints.c
@@ -76,7 +76,7 @@ breakpoint* lookup_breakpoint(gchar* file, int line)
 	breakpoint* bp = NULL;
 	GTree* tree = NULL;
 	if (tree = (GTree*)g_hash_table_lookup(files, file))
-		bp = g_tree_lookup(tree, (gconstpointer)line);
+		bp = g_tree_lookup(tree, GINT_TO_POINTER(line));
 
 	return bp;
 }
@@ -91,10 +91,12 @@ breakpoint* lookup_breakpoint(gchar* file, int line)
  */
 gint compare_func(gconstpointer a, gconstpointer b, gpointer user_data)
 {
-	if (a == b)
+	gint ia = GPOINTER_TO_INT(a);
+	gint ib = GPOINTER_TO_INT(b);
+	if (ia == ib)
 		return 0;
 	else
-		return a > b ? 1 : -1; 
+		return ia > ib ? 1 : -1;
 }
 
 /*
@@ -298,7 +300,7 @@ void breaks_add(char* file, int line, char* condition, int enabled, int hitscoun
 	}
 	
 	/* insert to internal storage */
-	g_tree_insert(tree, (gpointer)bp->line, (gpointer)bp);
+	g_tree_insert(tree, GINT_TO_POINTER(bp->line), bp);
 
 	/* handle creation instantly if debugger is idle or stopped
 	and request debug module interruption overwise */
@@ -442,7 +444,7 @@ gboolean breaks_is_set(char* file, int line)
 	else
 	{
 		/* lookup for the break in GTree*/
-		gpointer p = g_tree_lookup(tree, (gconstpointer)line);
+		gpointer p = g_tree_lookup(tree, GINT_TO_POINTER(line));
 		return p && ((breakpoint*)p)->enabled;
 	}
 }
diff --git a/debugger/src/dbm_gdb.c b/debugger/src/dbm_gdb.c
index 601817f..e6718f7 100644
--- a/debugger/src/dbm_gdb.c
+++ b/debugger/src/dbm_gdb.c
@@ -251,7 +251,7 @@ GList* read_until_end()
 static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer data)
 {
 	gchar *line;
-	gint length;
+	gsize length;
 	
 	if (G_IO_STATUS_NORMAL != g_io_channel_read_line(src, &line, NULL, &length, NULL))
 		return TRUE;		
@@ -900,7 +900,7 @@ GList* get_stack()
 			strcpy(f->file, "");
 		
 		/* whether source is available */
-		f->have_source = (gboolean)fullname;
+		f->have_source = fullname ? TRUE : FALSE;
 
 		/* line */
 		int line = 0;
diff --git a/debugger/src/stree.c b/debugger/src/stree.c
index 959e971..d2c2377 100644
--- a/debugger/src/stree.c
+++ b/debugger/src/stree.c
@@ -93,7 +93,7 @@ void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_data)
 			-1);
 		
 		/* check if file name is not empty and we have source files for the frame */
-		if (strlen(file) && g_hash_table_lookup(frames, (gpointer)file))
+		if (strlen(file) && GPOINTER_TO_INT(g_hash_table_lookup(frames, (gpointer)file)))
 			callback(file, line);
 		
 		g_free(file);
@@ -203,8 +203,8 @@ void stree_add(frame *f)
                     -1);
     
 	/* remember if we have source for this frame */
-    if (f->have_source && !g_hash_table_lookup(frames, (gpointer)f->file))
-		g_hash_table_insert(frames, g_strdup(f->file), (gpointer)f->have_source);
+    if (f->have_source && !GPOINTER_TO_INT(g_hash_table_lookup(frames, (gpointer)f->file)))
+		g_hash_table_insert(frames, g_strdup(f->file), GINT_TO_POINTER(f->have_source));
 }
 
 /*
-- 
1.7.1

From 8828799d5523cb876b7a398ad7c8d88001f62db4 Mon Sep 17 00:00:00 2001
From: Chow Loong Jin <[email protected]>
Date: Thu, 10 Feb 2011 00:37:23 +0800
Subject: [PATCH 2/3] Use %si to pass non-literal strings to dialogs_show_msgbox

---
 debugger/src/breakpoints.c |   10 +++++-----
 debugger/src/debug.c       |    4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/debugger/src/breakpoints.c b/debugger/src/breakpoints.c
index ca0ef4e..7e41ab9 100644
--- a/debugger/src/breakpoints.c
+++ b/debugger/src/breakpoints.c
@@ -122,7 +122,7 @@ void handle_break_new(breakpoint* bp, gboolean success)
 		markers_add_breakpoint(bp);
 	}
 	else
-		dialogs_show_msgbox(GTK_MESSAGE_ERROR, debug_error_message());
+		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 }
 
 /*
@@ -141,10 +141,10 @@ void handle_break_remove(breakpoint* bp, gboolean success)
 		bptree_remove_breakpoint(bp);
 		/* remove from internal storage */
 		GTree *tree = g_hash_table_lookup(files,bp->file);
-		g_tree_remove(tree, (gconstpointer)bp->line);
+		g_tree_remove(tree, GINT_TO_POINTER(bp->line));
 	}
 	else
-		dialogs_show_msgbox(GTK_MESSAGE_ERROR, debug_error_message());
+		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 }
 
 /*
@@ -158,7 +158,7 @@ void handle_hitscount_set(breakpoint* bp, gboolean success)
 	if (success)
 		bptree_set_hitscount(bp->iter, bp->hitscount);
 	else
-		dialogs_show_msgbox(GTK_MESSAGE_ERROR, debug_error_message());
+		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 }
 
 /*
@@ -181,7 +181,7 @@ void handle_condition_set(breakpoint* bp, gboolean success)
 		strcpy(bp->condition, oldcondition);
 		g_free(oldcondition);
 		/* show error message */
-		dialogs_show_msgbox(GTK_MESSAGE_ERROR, debug_error_message());
+		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 	}
 }
 
diff --git a/debugger/src/debug.c b/debugger/src/debug.c
index a652116..e119698 100644
--- a/debugger/src/debug.c
+++ b/debugger/src/debug.c
@@ -735,7 +735,7 @@ static void on_debugger_message (gchar* message, gchar *color)
  */
 static void on_debugger_error (gchar* message)
 {
-	dialogs_show_msgbox(GTK_MESSAGE_ERROR, message);
+	dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", message);
 }
 
 /* callbacks structure to pass to debugger module */
@@ -986,7 +986,7 @@ void debug_run()
 					sprintf(msg, _("Breakpoint at %s:%i cannot be set\nDebugger message: %s"),
 						erroneous_break->file, erroneous_break->line, active_module->error_message());
 						
-					dialogs_show_msgbox(GTK_MESSAGE_ERROR, msg);
+					dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", msg);
 						
 					active_module->stop();
 					debug_state = DBS_STOP_REQUESTED;
-- 
1.7.1

From 677d1d8be164f185b8ab0b39d503caee25e74dc5 Mon Sep 17 00:00:00 2001
From: Chow Loong Jin <[email protected]>
Date: Thu, 10 Feb 2011 00:38:41 +0800
Subject: [PATCH 3/3] Add sentinel value to g_object_set calls

---
 debugger/src/tpage.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/debugger/src/tpage.c b/debugger/src/tpage.c
index c6b85ac..0fda376 100644
--- a/debugger/src/tpage.c
+++ b/debugger/src/tpage.c
@@ -247,13 +247,13 @@ void on_render_value(GtkTreeViewColumn *tree_column,
 {
 	/* do not allow to edit value in read only mode */
 	if (page_read_only)
-		g_object_set (cell, "editable", FALSE);
+		g_object_set (cell, "editable", FALSE, NULL);
 	else
 	{
 		/* do not allow to edit value for empty row */
 		GtkTreePath *path = gtk_tree_model_get_path(tree_model, iter);
 		gboolean empty = !gtk_tree_path_compare(path, gtk_tree_row_reference_get_path(empty_row));
-		g_object_set (cell, "editable", entering_new_var || !empty);
+		g_object_set (cell, "editable", entering_new_var || !empty, NULL);
 		gtk_tree_path_free(path);
 	}
 }
-- 
1.7.1

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to