[sound-juicer] Do not mix code and declarations



commit ac33bfb77e7566ce44a63337afc9bd6038d1f6f3
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Thu Nov 10 13:04:15 2016 +0000

    Do not mix code and declarations
    
    Make sure all variables are declared at the start of each block.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777692

 libjuicer/sj-metadata-musicbrainz5.c |    4 +++-
 src/sj-extracting.c                  |    6 +++---
 src/sj-main.c                        |   16 +++++++++-------
 tests/mb-test.c                      |    3 ++-
 4 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/libjuicer/sj-metadata-musicbrainz5.c b/libjuicer/sj-metadata-musicbrainz5.c
index 9432b85..b8bc68f 100644
--- a/libjuicer/sj-metadata-musicbrainz5.c
+++ b/libjuicer/sj-metadata-musicbrainz5.c
@@ -315,13 +315,15 @@ static gboolean
 mcn_matches_barcode (const char *mcn,
                      const char *barcode)
 {
+  gsize len;
+
   if (mcn == NULL || barcode == NULL)
     return FALSE;
 
   /* The MCN should match an EAN barcode (13 digits)
    * or an UPC barcode (12 digits) with a leading '0'.
    */
-  gsize len = strlen (barcode);
+  len = strlen (barcode);
   if (len == 12) /* UPC barcode - skip leading '0' */
     return *mcn == '0' && strcmp (mcn + 1, barcode) == 0;
   else if (len == 13) /* EAN barcode */
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index 1dec0e2..431ab29 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -405,6 +405,8 @@ pop_and_extract (int *overwrite_mode)
     char *directory;
     GFile *file = NULL, *temp_file = NULL;
     GError *error = NULL;
+    goffset file_size;
+    GtkTreePath* path;
 
     /* Pop the next track to extract */
     gtk_tree_model_get (GTK_TREE_MODEL (track_store), &current, COLUMN_DETAILS, &track, -1);
@@ -428,8 +430,6 @@ pop_and_extract (int *overwrite_mode)
     /* Save the directory name for later */
     paths = g_list_append (paths, directory);
 
-
-    goffset file_size;
     file_size = check_file_size (file);
 
     /* Skip if destination file can't be accessed (unexpected error). */
@@ -462,7 +462,7 @@ pop_and_extract (int *overwrite_mode)
                                    CLAMP ((float)current_duration / (float)total_duration, 0.0, 1.0));
 
     /* Set the Treelist focus to the item to be extracted */
-    GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL (track_store), &current);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL (track_store), &current);
     gtk_tree_view_set_cursor(GTK_TREE_VIEW (track_listview), path, NULL, TRUE);
     gtk_tree_path_free(path);
 
diff --git a/src/sj-main.c b/src/sj-main.c
index e9c8dc2..5973720 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -794,9 +794,11 @@ static void open_changed_cb (GSettings *settings, const gchar *key, gpointer use
  */
 static void audio_volume_changed_cb (GSettings *settings, const gchar *key, gpointer user_data)
 {
+  GtkWidget *volb;
+
   g_assert (strcmp (key, SJ_SETTINGS_AUDIO_VOLUME) == 0);
 
-  GtkWidget *volb = GET_WIDGET ("volume_button");
+  volb = GET_WIDGET ("volume_button");
   gtk_scale_button_set_value (GTK_SCALE_BUTTON (volb), g_settings_get_double (settings, key));
 }
 
@@ -1661,25 +1663,25 @@ static void on_contents_activate(GSimpleAction *action, GVariant *parameter, gpo
 static gboolean
 is_cd_duplication_available(void)
 {
+  gchar *brasero_cd_burner, *cdrdao;
+  BraseroMediumMonitor *monitor;
+  GSList *drives, *iter;
+
   /* First check the brasero tool is available in the path */
-  gchar* brasero_cd_burner = g_find_program_in_path ("brasero");
+  brasero_cd_burner = g_find_program_in_path ("brasero");
   if (brasero_cd_burner == NULL) {
     return FALSE;
   }
   g_free(brasero_cd_burner);
 
   /* Second check the cdrdao tool is available in the path */
-  gchar* cdrdao = g_find_program_in_path ("cdrdao");
+  cdrdao = g_find_program_in_path ("cdrdao");
   if (cdrdao == NULL) {
     return FALSE;
   }
   g_free(cdrdao);
 
   /* Now check that there is at least one cd recorder available */
-  BraseroMediumMonitor     *monitor;
-  GSList                  *drives;
-  GSList                  *iter;
-
   monitor = brasero_medium_monitor_get_default ();
   drives = brasero_medium_monitor_get_drives (monitor, BRASERO_DRIVE_TYPE_ALL);
 
diff --git a/tests/mb-test.c b/tests/mb-test.c
index 5566659..1108635 100644
--- a/tests/mb-test.c
+++ b/tests/mb-test.c
@@ -63,9 +63,10 @@ metadata_cb (GObject *object, GAsyncResult *result, gpointer user_data)
   album_list = albums;
   while (albums) {
     AlbumDetails *album;
-    album = (AlbumDetails*)albums->data;
     char *disc_number;
     char *release_date = NULL;
+
+    album = (AlbumDetails*)albums->data;
     g_print ("Source: %s\n", source_to_str(album->metadata_source));
     if (album->metadata_source == SOURCE_MUSICBRAINZ)
       g_print ("Album ID: %s\n", album->album_id);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]