On Thursday 10,February,2011 07:58 AM, Colomban Wendling wrote: > No more need for a temporary variable then, since the value is used only > once ;)
Aaand another revised patch! -- Kind regards, Loong Jin
From 1568a9ac280e8d76c2da8530c5b0263ee43ebe77 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 | 11 ++++------- debugger/src/dbm_gdb.c | 4 ++-- debugger/src/stree.c | 6 +++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/debugger/src/breakpoints.c b/debugger/src/breakpoints.c index 3d3d8aa..e7edf66 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,7 @@ breakpoint* lookup_breakpoint(gchar* file, int line) */ gint compare_func(gconstpointer a, gconstpointer b, gpointer user_data) { - if (a == b) - return 0; - else - return a > b ? 1 : -1; + return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b); } /* @@ -298,7 +295,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 +439,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
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Geany-devel mailing list [email protected] http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
