From c60f82df6d7202e2fc96628124cda3a2f0debbd7 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 2 Jan 2014 23:37:14 +0000 Subject: [PATCH] [QA] Rename variables to avoid shadowing global variables. --- src/clipboard.c | 6 +++--- src/dialog.c | 8 ++++---- src/osm-traces.c | 26 +++++++++++++------------- src/osm-traces.h | 2 +- src/preferences.c | 10 +++++----- src/preferences.h | 2 +- src/vikmapslayer.c | 2 +- src/viktrwlayer.c | 8 ++++---- src/viktrwlayer_propwin.c | 2 -- src/vikwindow.c | 4 ++-- 10 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/clipboard.c b/src/clipboard.c index fbd38c85..ee0828bb 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -288,14 +288,14 @@ static void clip_receive_html ( GtkClipboard *c, GtkSelectionData *sd, gpointer span = s; } for (i=0; i0) { span[i] = ' '; } - if (c == '>') { + if (ch == '>') { if (tag>0) tag--; } } diff --git a/src/dialog.c b/src/dialog.c index 4590db61..79d0f38b 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -522,13 +522,13 @@ GList *a_dialog_select_from_list ( GtkWindow *parent, GList *names, gboolean mul while ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT ) { - GList *names = NULL; + GList *names_selected = NULL; GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); - gtk_tree_selection_selected_foreach(selection, get_selected_foreach_func, &names); - if (names) + gtk_tree_selection_selected_foreach(selection, get_selected_foreach_func, &names_selected); + if (names_selected) { gtk_widget_destroy ( dialog ); - return (names); + return names_selected; } a_dialog_error_msg(parent, _("Nothing was selected")); } diff --git a/src/osm-traces.c b/src/osm-traces.c index d0225356..0cc1e40c 100644 --- a/src/osm-traces.c +++ b/src/osm-traces.c @@ -52,12 +52,12 @@ static gint last_active = -1; /** * Login to use for OSM uploading. */ -static gchar *user = NULL; +static gchar *osm_user = NULL; /** * Password to use for OSM uploading. */ -static gchar *password = NULL; +static gchar *osm_password = NULL; /** * Mutex to protect auth. token @@ -125,7 +125,7 @@ static const gchar *get_default_user() return default_user; } -void osm_set_login(const gchar *user_, const gchar *password_) +void osm_set_login(const gchar *user, const gchar *password) { /* Allocate mutex */ if (login_mutex == NULL) @@ -133,10 +133,10 @@ void osm_set_login(const gchar *user_, const gchar *password_) login_mutex = g_mutex_new(); } g_mutex_lock(login_mutex); - g_free(user); user = NULL; - g_free(password); password = NULL; - user = g_strdup(user_); - password = g_strdup(password_); + g_free(osm_user); osm_user = NULL; + g_free(osm_password); osm_password = NULL; + osm_user = g_strdup(user); + osm_password = g_strdup(password); g_mutex_unlock(login_mutex); } @@ -144,7 +144,7 @@ gchar *osm_get_login() { gchar *user_pass = NULL; g_mutex_lock(login_mutex); - user_pass = g_strdup_printf("%s:%s", user, password); + user_pass = g_strdup_printf("%s:%s", osm_user, osm_password); g_mutex_unlock(login_mutex); return user_pass; } @@ -311,7 +311,7 @@ static void osm_traces_upload_thread ( OsmTracesInfo *oti, gpointer threaddata ) file = NULL; /* finally, upload it */ - gint ans = osm_traces_upload_file(user, password, filename, + gint ans = osm_traces_upload_file(osm_user, osm_password, filename, oti->name, oti->description, oti->tags, oti->vistype); // @@ -368,15 +368,15 @@ void osm_login_widgets (GtkWidget *user_entry, GtkWidget *password_entry) const gchar *pref_user = a_preferences_get(VIKING_OSM_TRACES_PARAMS_NAMESPACE "username")->s; const gchar *pref_password = a_preferences_get(VIKING_OSM_TRACES_PARAMS_NAMESPACE "password")->s; - if (user != NULL && user[0] != '\0') - gtk_entry_set_text(GTK_ENTRY(user_entry), user); + if (osm_user != NULL && osm_user[0] != '\0') + gtk_entry_set_text(GTK_ENTRY(user_entry), osm_user); else if (pref_user != NULL && pref_user[0] != '\0') gtk_entry_set_text(GTK_ENTRY(user_entry), pref_user); else if (default_user != NULL) gtk_entry_set_text(GTK_ENTRY(user_entry), default_user); - if (password != NULL && password[0] != '\0') - gtk_entry_set_text(GTK_ENTRY(password_entry), password); + if (osm_password != NULL && osm_password[0] != '\0') + gtk_entry_set_text(GTK_ENTRY(password_entry), osm_password); else if (pref_password != NULL) gtk_entry_set_text(GTK_ENTRY(password_entry), pref_password); /* This is a password -> invisible */ diff --git a/src/osm-traces.h b/src/osm-traces.h index b5341b00..a97d9cec 100644 --- a/src/osm-traces.h +++ b/src/osm-traces.h @@ -32,7 +32,7 @@ G_BEGIN_DECLS void osm_traces_init(); void osm_traces_upload_viktrwlayer ( VikTrwLayer *vtl, VikTrack *trk ); -void osm_set_login (const gchar *user_, const gchar *password_); +void osm_set_login (const gchar *user, const gchar *password); gchar *osm_get_login(); void osm_login_widgets (GtkWidget *user_entry, GtkWidget *password_entry); diff --git a/src/preferences.c b/src/preferences.c index 7174cc99..003c861d 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -119,17 +119,17 @@ static gboolean preferences_load_from_file() return FALSE; } -static void preferences_run_setparam ( gpointer notused, guint16 i, VikLayerParamData data, VikLayerParam *params ) +static void preferences_run_setparam ( gpointer notused, guint16 i, VikLayerParamData data, VikLayerParam *vlparams ) { - if ( params[i].type == VIK_LAYER_PARAM_STRING_LIST ) + if ( vlparams[i].type == VIK_LAYER_PARAM_STRING_LIST ) g_critical ( "Param strings not implemented in preferences"); //fake it - g_hash_table_insert ( values, (gchar *)(params[i].name), vik_layer_typed_param_data_copy_from_data(params[i].type, data) ); + g_hash_table_insert ( values, (gchar *)(vlparams[i].name), vik_layer_typed_param_data_copy_from_data(vlparams[i].type, data) ); } /* Allow preferences to be manipulated externally */ -void a_preferences_run_setparam ( VikLayerParamData data, VikLayerParam *params ) +void a_preferences_run_setparam ( VikLayerParamData data, VikLayerParam *vlparams ) { - preferences_run_setparam (NULL, 0, data, params); + preferences_run_setparam (NULL, 0, data, vlparams); } static VikLayerParamData preferences_run_getparam ( gpointer notused, guint16 i, gboolean notused2 ) diff --git a/src/preferences.h b/src/preferences.h index 09b045c8..464b38c2 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -47,7 +47,7 @@ void a_preferences_show_window(GtkWindow *parent); VikLayerParamData *a_preferences_get(const gchar *key); /* Allow preferences to be manipulated externally */ -void a_preferences_run_setparam ( VikLayerParamData data, VikLayerParam *params ); +void a_preferences_run_setparam ( VikLayerParamData data, VikLayerParam *vlparams ); gboolean a_preferences_save_to_file(); diff --git a/src/vikmapslayer.c b/src/vikmapslayer.c index 6f11f7d9..b8e38f01 100644 --- a/src/vikmapslayer.c +++ b/src/vikmapslayer.c @@ -1133,7 +1133,7 @@ static void maps_layer_draw_section ( VikMapsLayer *vml, VikViewport *vvp, VikCo gint tilesize_y_ceil = ceil ( tilesize_y ); gint8 xinc = (ulm.x == xmin) ? 1 : -1; gint8 yinc = (ulm.y == ymin) ? 1 : -1; - gdouble xx, yy; gint xx_tmp, yy_tmp; + gint xx_tmp, yy_tmp; gint base_yy, xend, yend; xend = (xinc == 1) ? (xmax+1) : (xmin-1); diff --git a/src/viktrwlayer.c b/src/viktrwlayer.c index a629f4c4..6af595ef 100644 --- a/src/viktrwlayer.c +++ b/src/viktrwlayer.c @@ -10492,16 +10492,16 @@ void vik_track_download_map(VikTrack *tr, VikMapsLayer *vml, VikViewport *vvp, g g_message("%s: this feature works only in Mercator mode", __FUNCTION__); if (fillins) { - GList *iter = fillins; - while (iter) { - cur_coord = (VikCoord *)(iter->data); + GList *fiter = fillins; + while (fiter) { + cur_coord = (VikCoord *)(fiter->data); vik_coord_set_area(cur_coord, &wh, &tl, &br); rect = g_malloc(sizeof(Rect)); rect->tl = tl; rect->br = br; rect->center = *cur_coord; rects_to_download = g_list_prepend(rects_to_download, rect); - iter = iter->next; + fiter = fiter->next; } } diff --git a/src/viktrwlayer_propwin.c b/src/viktrwlayer_propwin.c index 2cf48d37..c54b263c 100644 --- a/src/viktrwlayer_propwin.c +++ b/src/viktrwlayer_propwin.c @@ -1704,7 +1704,6 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets ) max_speed = widgets->max_speed * 110 / 100; // This is just an indicator - no actual values can be inferred by user - gint i; for ( i = 0; i < widgets->profile_width; i++ ) { int y_speed = widgets->profile_height - (widgets->profile_height * widgets->speeds[i])/max_speed; gdk_draw_rectangle(GDK_DRAWABLE(pix), dist_speed_gc, TRUE, i+MARGIN-2, y_speed-2, 4, 4); @@ -1803,7 +1802,6 @@ static void draw_et ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets ) max_speed = widgets->max_speed * 110 / 100; // This is just an indicator - no actual values can be inferred by user - gint i; for ( i = 0; i < widgets->profile_width; i++ ) { int y_speed = widgets->profile_height - (widgets->profile_height * widgets->speeds[i])/max_speed; gdk_draw_rectangle(GDK_DRAWABLE(pix), elev_speed_gc, TRUE, i+MARGIN-2, y_speed-2, 4, 4); diff --git a/src/vikwindow.c b/src/vikwindow.c index 67584618..9ad4d7d8 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -3751,8 +3751,8 @@ static void draw_to_image_file ( VikWindow *vw, gboolean one_image_only ) if ( !fn ) return; - gint active = gtk_combo_box_get_active ( GTK_COMBO_BOX(zoom_combo) ); - gdouble zoom = pow (2, active-2 ); + gint active_z = gtk_combo_box_get_active ( GTK_COMBO_BOX(zoom_combo) ); + gdouble zoom = pow (2, active_z-2 ); if ( one_image_only ) save_image_file ( vw, fn, -- 2.39.5