Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sat, 09 Jun 2012 16:35:48 Commit: 3944fdfa3c11b7c4373b7258cc3d13a7b6166a62 https://github.com/geany/geany-plugins/commit/3944fdfa3c11b7c4373b7258cc3d13...
Log Message: ----------- geanygdb: Fix various const string warnings
This doesn't introduce any feature change and only one effective code change on a tricky (but not strictly speaking wrong) spot.
Modified Paths: -------------- geanygdb/src/gdb-io-break.c geanygdb/src/gdb-io-frame.c geanygdb/src/gdb-io-priv.h geanygdb/src/gdb-io-read.c geanygdb/src/gdb-io-run.c geanygdb/src/gdb-io.h geanygdb/src/gdb-lex.c geanygdb/src/gdb-lex.h geanygdb/src/gdb-ui-envir.c geanygdb/src/gdb-ui-frame.c geanygdb/src/gdb-ui-locn.c geanygdb/src/gdb-ui-main.c geanygdb/src/gdb-ui.h
Modified: geanygdb/src/gdb-io-break.c 11 files changed, 9 insertions(+), 2 deletions(-) =================================================================== @@ -64,8 +64,15 @@
#define populate(rec, hash, key) \ - rec->key=gdblx_lookup_string(hash, #key""); \ - if (rec->key) {rec->key=g_strdup(rec->key);} + do \ + { \ + const gchar *populate_key = gdblx_lookup_string(hash, #key""); \ + if (populate_key) \ + { \ + rec->key = g_strdup(populate_key); \ + } \ + } \ + while (0)
Modified: geanygdb/src/gdb-io-frame.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -154,7 +154,7 @@
static gchar * -fmt_val(gchar * value) +fmt_val(const gchar * value) { gchar buf[256]; if (!value) @@ -305,7 +305,7 @@ }
void -gdbio_show_locals(GdbFrameFunc func, gchar * level) +gdbio_show_locals(GdbFrameFunc func, const gchar * level) { free_lists(); gdbio_locals_func = func;
Modified: geanygdb/src/gdb-io-priv.h 8 files changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -60,7 +60,7 @@ expands to: gchar *somevar = gdblx_lookup_string ( myhash, "somevar" ); */ -#define HSTR(hash,token) gchar* token = gdblx_lookup_string(hash, #token"") +#define HSTR(hash,token) const gchar* token = gdblx_lookup_string(hash, #token"") #define HTAB(hash,token) GHashTable* token = gdblx_lookup_hash(hash, #token"") #define HLST(hash,token) GSList* token = gdblx_lookup_list(hash, #token"")
@@ -76,12 +76,12 @@
-void gdbio_info_func(gchar * fmt, ...); -void gdbio_error_func(gchar * fmt, ...); +void gdbio_info_func(const gchar * fmt, ...); +void gdbio_error_func(const gchar * fmt, ...); void gdbio_do_status(GdbStatus s);
-void gdbio_target_exited(gchar * reason); +void gdbio_target_exited(const gchar * reason); void gdbio_set_target_pid(GPid pid); GPid gdbio_get_target_pid(void); void gdbio_set_running(gboolean running);
Modified: geanygdb/src/gdb-io-read.c 8 files changed, 5 insertions(+), 3 deletions(-) =================================================================== @@ -297,7 +297,7 @@
static gboolean -do_step_func(GHashTable * h, gchar * reason) +do_step_func(GHashTable * h, const gchar * reason_) { HTAB(h, frame); HSTR(frame, fullname); @@ -306,6 +306,7 @@ { if (gdbio_setup.step_func) { + gchar *reason = g_strdup(reason_); gchar *p; for (p = reason; *p; p++) { @@ -315,6 +316,7 @@ } } gdbio_setup.step_func(fullname, line, reason); + g_free(reason); } else { @@ -384,14 +386,14 @@
static void -watchpoint_trigger(GHashTable * h, GHashTable * wp, gchar * reason) +watchpoint_trigger(GHashTable * h, GHashTable * wp, const gchar * reason) { HTAB(h, value); HSTR(wp, exp); HSTR(wp, number); HSTR(value, new); HSTR(value, old); - gchar *readval = gdblx_lookup_string(value, "value"); + const gchar *readval = gdblx_lookup_string(value, "value"); if (new && old) { gdbio_info_func("%s #%s expression:%s old-value:%s new-value:%s\n",
Modified: geanygdb/src/gdb-io-run.c 24 files changed, 12 insertions(+), 12 deletions(-) =================================================================== @@ -36,7 +36,7 @@ GdbIoSetup gdbio_setup;
-static gchar *gdbio_args[] = { "gdb", "--interpreter=mi", "-nx", NULL }; +static const gchar *gdbio_args[] = { "gdb", "--interpreter=mi", "-nx", NULL };
static GPid gdbio_pid = 0; static GPid target_pid = 0; @@ -132,7 +132,7 @@ }
static gboolean -gerror(gchar * msg, GError ** err) +gerror(const gchar * msg, GError ** err) { if (*err) { @@ -156,7 +156,7 @@
gint -gdbio_atoi(gchar * str) +gdbio_atoi(const gchar * str) { gchar *tail = NULL; gint rv = strtol(str, &tail, 10); @@ -165,7 +165,7 @@
void -gdbio_error_func(gchar * fmt, ...) +gdbio_error_func(const gchar * fmt, ...) { va_list args; gchar *msg; @@ -185,7 +185,7 @@
void -gdbio_info_func(gchar * fmt, ...) +gdbio_info_func(const gchar * fmt, ...) { va_list args; gchar *msg; @@ -277,9 +277,9 @@
static gchar * -start_xterm(gchar * term_cmd) +start_xterm(const gchar * term_cmd) { - gchar *term_args[] = { "xterm", "-title", "Debug terminal", "-e", NULL, NULL, NULL }; + const gchar *term_args[] = { "xterm", "-title", "Debug terminal", "-e", NULL, NULL, NULL }; GError *err = NULL; gint i = 0; gchar *tty_name = NULL; @@ -353,10 +353,10 @@ } term_args[i] = gdbio_setup.tty_helper; term_args[i + 1] = xterm_tty_file; - all = g_strjoinv("" "", term_args); + all = g_strjoinv("" "", (gchar **) term_args); gdbio_info_func(""%s"\n", all); g_free(all); - if (g_spawn_async(NULL, term_args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &xterm_pid, &err)) + if (g_spawn_async(NULL, (gchar **) term_args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &xterm_pid, &err)) { gchar *contents = NULL; gsize len; @@ -535,7 +535,7 @@
void -gdbio_target_exited(gchar * reason) +gdbio_target_exited(const gchar * reason) { gdbio_info_func(_("Target process exited. (pid=%d; %s%s)\n"), target_pid, reason @@ -789,7 +789,7 @@ gchar **gdbio_env = utils_copy_environment(exclude, "LANG", "C", NULL); const gchar *env_lang = g_getenv("LANG"); gdbio_exit(); - if (g_spawn_async_with_pipes(NULL, gdbio_args, gdbio_env, + if (g_spawn_async_with_pipes(NULL, (gchar **) gdbio_args, gdbio_env, GDB_SPAWN_FLAGS, NULL, NULL, &gdbio_pid, &gdbio_in, &gdbio_out, NULL, &err)) { @@ -828,7 +828,7 @@
void -gdbio_exec_target(gchar * terminal_command) +gdbio_exec_target(const gchar * terminal_command) { if (terminal_command) {
Modified: geanygdb/src/gdb-io.h 22 files changed, 11 insertions(+), 11 deletions(-) =================================================================== @@ -26,7 +26,7 @@ extern ssize_t getline(char **lineptr, size_t * n, FILE * stream); extern const gchar *basename(const gchar * path);
-gint gdbio_atoi(gchar * str); +gint gdbio_atoi(const gchar * str); gint gdbio_wait(gint ms);
@@ -63,14 +63,14 @@
typedef struct { - gchar *signal_name; - gchar *signal_meaning; - gchar *addr; - gchar *func; - gchar *file; - gchar *fullname; - gchar *line; - gchar *from; + const gchar *signal_name; + const gchar *signal_meaning; + const gchar *addr; + const gchar *func; + const gchar *file; + const gchar *fullname; + const gchar *line; + const gchar *from; } GdbSignalInfo;
@@ -133,7 +133,7 @@ be started first, and the target program will be run in the resulting console. */ -void gdbio_exec_target(gchar * terminal_command); +void gdbio_exec_target(const gchar * terminal_command);
/* Send SIGINT to target */ @@ -189,7 +189,7 @@ Passes a GdbFrameInfo pointer and a GSList of GdbVar pointers to func representing the state of the local variables at the specified level. */ -void gdbio_show_locals(GdbFrameFunc func, gchar * level); +void gdbio_show_locals(GdbFrameFunc func, const gchar * level);
/*
Modified: geanygdb/src/gdb-lex.c 18 files changed, 9 insertions(+), 9 deletions(-) =================================================================== @@ -79,7 +79,7 @@ { GScanner *scanner = g_scanner_new(NULL); scanner->msg_handler = scan_error; - scanner->config->cset_identifier_nth = ID_NTH; + scanner->config->cset_identifier_nth = (gchar *) ID_NTH; return scanner; }
@@ -129,7 +129,7 @@ static GScanner *scanner = NULL;
GHashTable * -gdblx_parse_results(gchar * results) +gdblx_parse_results(const gchar * results) { gchar *key = NULL; gboolean equals = FALSE; @@ -310,21 +310,21 @@
static GdbLxValue * -find_value(GHashTable * hash, gchar * key, GdbLxValueType type) +find_value(GHashTable * hash, const gchar * key, GdbLxValueType type) { GdbLxValue *v = hash ? g_hash_table_lookup(hash, key) : NULL; return v && v->type == type ? v : NULL; }
-gchar * -gdblx_lookup_string(GHashTable * hash, gchar * key) +const gchar * +gdblx_lookup_string(GHashTable * hash, const gchar * key) { GdbLxValue *v = find_value(hash, key, vt_STRING); return v ? v->string : NULL; }
GHashTable * -gdblx_lookup_hash(GHashTable * hash, gchar * key) +gdblx_lookup_hash(GHashTable * hash, const gchar * key) { GdbLxValue *v = find_value(hash, key, vt_HASH); return v ? v->hash : NULL; @@ -332,7 +332,7 @@
GSList * -gdblx_lookup_list(GHashTable * hash, gchar * key) +gdblx_lookup_list(GHashTable * hash, const gchar * key) { GdbLxValue *v = find_value(hash, key, vt_LIST); return v ? v->list : NULL; @@ -341,8 +341,8 @@
/* True if key exists, it's a string, and its value matches 'expected' */ gboolean -gdblx_check_keyval(GHashTable * hash, gchar * key, gchar * expected) +gdblx_check_keyval(GHashTable * hash, const gchar * key, const gchar * expected) { - gchar *value = gdblx_lookup_string(hash, key); + const gchar *value = gdblx_lookup_string(hash, key); return value && g_str_equal(value, expected); }
Modified: geanygdb/src/gdb-lex.h 10 files changed, 5 insertions(+), 5 deletions(-) =================================================================== @@ -47,22 +47,22 @@
-GHashTable *gdblx_parse_results(gchar * resutls); +GHashTable *gdblx_parse_results(const gchar * resutls);
/* The gdblx_lookup_* functions below return NULL if their hash is NULL, if the key is not found, or if its value is not of the expected return type. */ -gchar *gdblx_lookup_string(GHashTable * hash, gchar * key); -GHashTable *gdblx_lookup_hash(GHashTable * hash, gchar * key); -GSList *gdblx_lookup_list(GHashTable * hash, gchar * key); +const gchar *gdblx_lookup_string(GHashTable * hash, const gchar * key); +GHashTable *gdblx_lookup_hash(GHashTable * hash, const gchar * key); +GSList *gdblx_lookup_list(GHashTable * hash, const gchar * key);
/* Returns TRUE if hash is not NULL, key exists, and key type is vt_STRING, and the key's value matches 'expected'. */ -gboolean gdblx_check_keyval(GHashTable * hash, gchar * key, gchar * expected); +gboolean gdblx_check_keyval(GHashTable * hash, const gchar * key, const gchar * expected);
/* Dumps a pretty-printed representation of the hash table to stderr */
Modified: geanygdb/src/gdb-ui-envir.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -27,7 +27,7 @@
static GtkWidget * -newlabel(gchar * s) +newlabel(const gchar * s) { GtkWidget *w = gtk_label_new(s); gtk_misc_set_alignment(GTK_MISC(w), 0.0f, 0.0f);
Modified: geanygdb/src/gdb-ui-frame.c 6 files changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -148,7 +148,7 @@ }
GtkWidget * -gdbui_new_dialog(gchar * title) +gdbui_new_dialog(const gchar * title) { GtkWidget *dlg = gtk_dialog_new(); gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(gdbui_setup.main_window)); @@ -160,7 +160,7 @@
static void -monospace(GtkWidget * label, gchar * line, gchar * text) +monospace(GtkWidget * label, const gchar * line, const gchar * text) { gchar *esc = g_markup_escape_text(text, -1); gchar *mu; @@ -197,7 +197,7 @@
static GtkWidget * -make_list(const GSList * list, gchar * title, VarWidgets * vw) +make_list(const GSList * list, const gchar * title, VarWidgets * vw) { GtkTreeIter iter; GtkTreeViewColumn *column;
Modified: geanygdb/src/gdb-ui-locn.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -43,7 +43,7 @@
LocationInfo * -gdbui_location_dlg(gchar * title, gboolean is_watch) +gdbui_location_dlg(const gchar * title, gboolean is_watch) { GtkWidget *file_entry = NULL; GtkWidget *line_entry; @@ -163,7 +163,7 @@ rv = g_new0(LocationInfo, 1); if (is_watch) { - gchar *opt = ""; + const gchar *opt = ""; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opt_r))) { opt = "-r";
Modified: geanygdb/src/gdb-ui-main.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -375,7 +375,7 @@ struct SdebugMenu
void -gdbui_set_tip(GtkWidget * w, gchar * tip) +gdbui_set_tip(GtkWidget * w, const gchar * tip) { if (gdbui_setup.options.show_tooltips) { @@ -390,7 +390,7 @@ struct SdebugMenu static const gboolean disable_mnemonics = TRUE;
static GtkWidget * -make_btn(const gchar *text, GtkCallback cb, gchar *img, gchar *tip) +make_btn(const gchar *text, GtkCallback cb, const gchar *img, const gchar *tip) { GtkWidget *button;
Modified: geanygdb/src/gdb-ui.h 6 files changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -71,10 +71,10 @@ void gdbui_create_menu(GtkWidget * parent); void gdbui_create_dview(GtkWidget * parent);
-void gdbui_set_tip(GtkWidget * w, gchar * tip); +void gdbui_set_tip(GtkWidget * w, const gchar * tip); void gdbui_enable(gboolean enabled);
-GtkWidget *gdbui_new_dialog(gchar * title); +GtkWidget *gdbui_new_dialog(const gchar * title);
void gdbui_opts_init(void); void gdbui_opts_done(void); @@ -85,5 +85,5 @@ void gdbui_break_dlg(gboolean is_watch); void gdbui_env_dlg(const GdbEnvironInfo * env);
-LocationInfo *gdbui_location_dlg(gchar * title, gboolean is_watch); +LocationInfo *gdbui_location_dlg(const gchar * title, gboolean is_watch); void gdbui_free_location_info(LocationInfo * li);
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
plugins-commits@lists.geany.org