[easytag/wip/easytag-next: 12/13] Use g_return_if_fail() and g_return_val_if_fail()



commit bad0b6d8aba5279a8ed3bf5c7ccd3d0d2429fe19
Author: David King <amigadave amigadave com>
Date:   Thu Dec 6 18:37:59 2012 +0000

    Use g_return_if_fail() and g_return_val_if_fail()

 src/bar.c     |    3 +-
 src/browser.c |   43 ++++++++++++-------------
 src/cddb.c    |   17 +++++-----
 src/charset.c |   33 ++++++++++++--------
 src/easytag.c |   79 +++++++++++++++++++++++++---------------------
 src/et_core.c |   96 ++++++++++++++++++++++++++++++++------------------------
 src/et_core.h |    4 +-
 src/log.c     |    2 +-
 src/misc.c    |   59 ++++++++++++++++++-----------------
 src/picture.c |   12 +++----
 src/prefs.c   |    2 +-
 src/scan.c    |   36 +++++++++++----------
 12 files changed, 207 insertions(+), 179 deletions(-)
---
diff --git a/src/bar.c b/src/bar.c
index 294dc05..e7513b2 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -454,7 +454,8 @@ Statusbar_Remove_Timer (void)
 void Statusbar_Message (gchar *message, gint with_timer)
 {
     gchar *msg_temp;
-    if (!StatusBar) return;
+
+    g_return_if_fail (StatusBar != NULL);
 
     /* Validate UTF8 */
     /*if (!g_utf8_validate(message, -1, NULL))
diff --git a/src/browser.c b/src/browser.c
index 9dbdba6..6f0bb6f 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -310,7 +310,7 @@ Browser_Tree_Get_Path_Of_Selected_Node (void)
     GtkTreeIter selectedIter;
     gchar *path;
 
-    if (!BrowserTree) return NULL;
+    g_return_val_if_fail (BrowserTree != NULL, NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserTree));
     if (selection
@@ -334,7 +334,7 @@ Browser_Update_Current_Path (const gchar *path)
 {
     /* Be sure that we aren't passing 'BrowserCurrentPath' as parameter of the function :
      * to avoid some memory problems */
-    if (path == NULL || path == BrowserCurrentPath) return;
+    g_return_if_fail (path != NULL || path != BrowserCurrentPath);
 
     if (BrowserCurrentPath != NULL)
         g_free(BrowserCurrentPath);
@@ -458,7 +458,7 @@ Browser_Tree_Key_Press (GtkWidget *tree, GdkEvent *event, gpointer data)
     GtkTreeSelection *treeSelection;
     GtkTreePath *treePath;
 
-    if (!tree) return FALSE;
+    g_return_val_if_fail (tree != NULL, FALSE);
 
     treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
 
@@ -537,8 +537,7 @@ gboolean Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data
     GtkTreeModel     *fileListModel;
     GtkTreeSelection *fileSelection;
 
-
-    if (!list) return FALSE;
+    g_return_val_if_fail (list != NULL, FALSE);
 
     fileListModel = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
     fileSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
@@ -693,7 +692,7 @@ void Browser_Tree_Collapse (void)
 {
     GtkTreePath *rootPath;
 
-    if (!BrowserTree) return;
+    g_return_if_fail (BrowserTree != NULL);
 
     gtk_tree_view_collapse_all(GTK_TREE_VIEW(BrowserTree));
 
@@ -712,7 +711,7 @@ void Browser_Tree_Collapse (void)
 static void
 Browser_Tree_Set_Node_Visible (GtkWidget *directoryView, GtkTreePath *path)
 {
-    if (!directoryView || !path) return;
+    g_return_if_fail (directoryView != NULL || path != NULL);
 
     gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(directoryView), path, NULL, TRUE, 0.5, 0.0);
 }
@@ -730,7 +729,7 @@ void Browser_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter
      */
     GtkTreePath *rowPath;
 
-    if (!treeModel || !rowIter) return;
+    g_return_if_fail (treeModel != NULL || rowIter != NULL);
 
     rowPath = gtk_tree_model_get_path(treeModel, rowIter);
     gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(BrowserList), rowPath, NULL, FALSE, 0, 0);
@@ -907,7 +906,7 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
     gchar *nodeName;
     gchar *temp;
 
-    if (!BrowserTree) return FALSE;
+    g_return_val_if_fail (BrowserTree != NULL, FALSE);
 
     /* Load current_path */
     if(!current_path || !*current_path)
@@ -1050,7 +1049,7 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
     gboolean activate_bg_color = 0;
     GtkTreeIter rowIter;
 
-    if (!BrowserList) return;
+    g_return_if_fail (BrowserList != NULL);
 
     gtk_list_store_clear(fileListModel);
     etfilelist = g_list_first(etfilelist);
@@ -1637,7 +1636,7 @@ GtkTreePath *Browser_List_Select_File_By_Etfile2 (ET_File *searchETFile, gboolea
 static void
 Browser_List_Select_File_By_Iter (GtkTreeIter *rowIter, gboolean select_it)
 {
-    if (!BrowserList) return;
+    g_return_if_fail (BrowserList != NULL);
 
     if (select_it)
     {
@@ -1661,7 +1660,7 @@ ET_File *Browser_List_Select_File_By_Iter_String (const gchar* stringIter, gbool
     GtkTreeIter iter;
     ET_File *current_etfile = NULL;
 
-    if (!fileListModel || !BrowserList) return NULL;
+    g_return_val_if_fail (fileListModel != NULL || BrowserList != NULL, NULL);
 
     if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(fileListModel), &iter, stringIter))
     {
@@ -1699,7 +1698,7 @@ ET_File *Browser_List_Select_File_By_DLM (const gchar* string, gboolean select_i
     gchar *current_filename = NULL, *current_title = NULL;
     int max = 0, this;
 
-    if (!fileListModel || !BrowserList) return NULL;
+    g_return_val_if_fail (fileListModel != NULL || BrowserList != NULL, NULL);
 
     if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(fileListModel), &iter))
     {
@@ -1911,7 +1910,7 @@ void Browser_List_Select_All_Files (void)
 {
     GtkTreeSelection *selection;
 
-    if (!BrowserList) return;
+    g_return_if_fail (BrowserList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
     if (selection)
@@ -1930,7 +1929,7 @@ void Browser_List_Unselect_All_Files (void)
 {
     GtkTreeSelection *selection;
 
-    if (!BrowserList) return;
+    g_return_if_fail (BrowserList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
     if (selection)
@@ -1948,7 +1947,7 @@ void Browser_List_Invert_File_Selection (void)
     GtkTreeSelection *selection;
     gboolean valid;
 
-    if (!fileListModel || !BrowserList) return;
+    g_return_if_fail (fileListModel != NULL || BrowserList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
     if (selection)
@@ -1983,7 +1982,7 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
     GtkTreeSelection *selection;
     gchar *artistname, *artist_to_select = NULL;
 
-    if (!BrowserArtistList) return;
+    g_return_if_fail (BrowserArtistList != NULL);
 
     if (etfile_to_select)
         artist_to_select = ((File_Tag *)etfile_to_select->FileTag->data)->artist;
@@ -2144,7 +2143,7 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
     GtkTreeSelection *selection;
     gchar *albumname, *album_to_select = NULL;
 
-    if (!BrowserAlbumList) return;
+    g_return_if_fail (BrowserAlbumList != NULL);
 
     if (etfile_to_select)
         album_to_select = ((File_Tag *)etfile_to_select->FileTag->data)->album;
@@ -2393,7 +2392,7 @@ Browser_Tree_Initialize (void)
     GtkTreeIter parent_iter;
     GtkTreeIter dummy_iter;
 
-    if (!directoryTreeModel) return;
+    g_return_if_fail (directoryTreeModel != NULL);
 
     gtk_tree_store_clear(directoryTreeModel);
 
@@ -2846,7 +2845,7 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
     GtkTreeIter subNodeIter;
     GdkPixbuf *pixbuf;
 
-    if (!directoryTreeModel) return;
+    g_return_if_fail (directoryTreeModel != NULL);
 
     gtk_tree_model_get(GTK_TREE_MODEL(directoryTreeModel), iter,
                        TREE_COLUMN_FULL_PATH, &parentPath,
@@ -2950,7 +2949,7 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
 {
     GtkTreeIter subNodeIter;
 
-    if (!directoryTreeModel) return;
+    g_return_if_fail (directoryTreeModel != NULL);
 
     gtk_tree_model_iter_children(GTK_TREE_MODEL(directoryTreeModel),
                                  &subNodeIter, iter);
@@ -4250,7 +4249,7 @@ void Run_Program_With_Directory (GtkWidget *combobox)
     GList *args_list = NULL;
     gboolean program_ran;
 
-    if (!GTK_IS_COMBO_BOX(combobox)) return;
+    g_return_if_fail (GTK_IS_COMBO_BOX (combobox));
 
     program_name      = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
     current_directory = g_object_get_data(G_OBJECT(combobox), "Current_Directory");
diff --git a/src/cddb.c b/src/cddb.c
index cdc8766..026c34e 100644
--- a/src/cddb.c
+++ b/src/cddb.c
@@ -1452,7 +1452,7 @@ Cddb_Track_List_Unselect_All ()
 {
     GtkTreeSelection *selection;
 
-    if (!CddbTrackListView) return;
+    g_return_if_fail (CddbTrackListView != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(CddbTrackListView));
     if (selection)
@@ -1469,7 +1469,7 @@ Cddb_Track_List_Select_All ()
 {
     GtkTreeSelection *selection;
 
-    if (!CddbTrackListView) return;
+    g_return_if_fail (CddbTrackListView != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(CddbTrackListView));
     if (selection)
@@ -1488,7 +1488,7 @@ Cddb_Track_List_Invert_Selection ()
     GtkTreeIter iter;
     gboolean valid;
 
-    if (!CddbTrackListView) return;
+    g_return_if_fail (CddbTrackListView != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(CddbTrackListView));
 
@@ -1907,7 +1907,7 @@ Cddb_Read_Cddb_Header (FILE **file, gchar **cddb_out)
 static gboolean
 Cddb_Free_Album_List (void)
 {
-    if (!CddbAlbumList) return FALSE;
+    g_return_val_if_fail (CddbAlbumList != NULL, FALSE);
 
     CddbAlbumList = g_list_last(CddbAlbumList);
     while (CddbAlbumList)
@@ -1946,7 +1946,7 @@ Cddb_Free_Track_Album_List (GList *track_list)
 {
     GList *CddbTrackAlbumList;
 
-    if (!track_list) return FALSE;
+    g_return_val_if_fail (track_list != NULL, FALSE);
 
     CddbTrackAlbumList = g_list_last(track_list);
     while (CddbTrackAlbumList)
@@ -2843,8 +2843,7 @@ Cddb_Search_Album_From_Selected_Files (void)
     GtkTreeIter *fileIter;
     GList *file_iterlist = NULL;
 
-
-    if (!BrowserList) return FALSE;
+    g_return_val_if_fail (BrowserList != NULL, FALSE);
 
     // Number of selected files
     fileListModel = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(BrowserList)));
@@ -4115,7 +4114,7 @@ Cddb_Set_Track_Infos_To_File_List (void)
 static void
 Cddb_Display_Red_Lines_In_Result (void)
 {
-    if (!CddbDisplayRedLinesButton) return;
+    g_return_if_fail (CddbDisplayRedLinesButton != NULL);
 
     if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(CddbDisplayRedLinesButton)) )
     {
@@ -4137,7 +4136,7 @@ Cddb_Get_Id3_Genre_From_Cddb_Genre (const gchar *cddb_genre)
 {
     guint i;
 
-    if (!cddb_genre) return "";
+    g_return_val_if_fail (cddb_genre != NULL, "");
 
     for (i=0; i<=CDDB_GENRE_MAX; i++)
         if (strcasecmp(cddb_genre,cddb_genre_vs_id3_genre[i][0])==0)
diff --git a/src/charset.c b/src/charset.c
index ff95113..a9a3540 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -381,17 +381,18 @@ gchar *convert_string (const gchar *string, const gchar *from_codeset,
 {
     return convert_string_1(string, -1, from_codeset, to_codeset, display_error);
 }
+
 /* Length must be passed, as the string might be Unicode, in which case we can't
  * count zeroes (see strlen call below). */
-gchar *convert_string_1 (const gchar *string, gssize length, const gchar *from_codeset,
+gchar *
+convert_string_1 (const gchar *string, gssize length, const gchar *from_codeset,
                          const gchar *to_codeset, const gboolean display_error)
 {
     gchar *output;
     GError *error = NULL;
     gsize bytes_written;
 
-    if (!string)
-        return NULL;
+    g_return_val_if_fail (string != NULL, NULL);
 
     output = g_convert(string, length, to_codeset, from_codeset, NULL, &bytes_written, &error);
     //output = g_convert_with_fallback(string, length, to_codeset, from_codeset, "?", NULL, &bytes_written, &error);
@@ -472,13 +473,13 @@ gchar *convert_to_utf8 (const gchar *string)
  *  - conversion OK : returns the UTF-8 string (new allocated)
  *  - conversion KO : tries others encodings else returns an 'escaped' string
  */
-gchar *filename_to_display (const gchar *string)
+gchar *
+filename_to_display (const gchar *string)
 {
     gchar *ret = NULL;
     GError *error = NULL;
 
-    if (!string)
-        return NULL;
+    g_return_val_if_fail (string != NULL, NULL);
 
     if (g_utf8_validate(string, -1, NULL))
     {
@@ -535,7 +536,7 @@ gchar *filename_from_display (const gchar *string)
     const gchar *char_encoding = NULL;
     //const gchar *filename_encoding = NULL;
 
-    if (!string) return NULL;
+    g_return_val_if_fail (string != NULL, NULL);
 
     // Get system encoding from LANG if found (ex : fr_FR.UTF-8 => UTF-8)
     if (get_locale())
@@ -700,13 +701,19 @@ void Charset_Populate_Combobox (GtkComboBox *combo, gchar *select_charset)
 /*
  * Return charset_name from charset_title
  */
-gchar *Charset_Get_Name_From_Title (const gchar *charset_title)
+gchar *
+Charset_Get_Name_From_Title (const gchar *charset_title)
 {
     guint i;
 
-    if (charset_title)
-        for (i=0; i<CHARSET_TRANS_ARRAY_LEN; i++)
-            if ( strcasecmp(_(charset_title),_(charset_trans_array[i].charset_title)) == 0 )
-                return charset_trans_array[i].charset_name;
-    return "";
+    g_return_val_if_fail (charset_title != NULL, "");
+
+    for (i = 0; i < CHARSET_TRANS_ARRAY_LEN; i++)
+    {
+        if (strcasecmp (_(charset_title),
+                        _(charset_trans_array[i].charset_title)) == 0)
+        {
+            return charset_trans_array[i].charset_name;
+        }
+    }
 }
diff --git a/src/easytag.c b/src/easytag.c
index aaeff3b..d7d8d7d 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -1178,8 +1178,8 @@ Mini_Button_Clicked (GObject *object)
     File_Tag *FileTag;
     GtkTreeSelection *selection;
 
-
-    if (!ETCore->ETFileDisplayedList || !BrowserList) return;
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                      BrowserList != NULL);
 
     // Save the current displayed data
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -1850,7 +1850,8 @@ void Action_Scan_Selected_Files (void)
     ET_File *etfile;
     GtkTreeSelection *selection;
 
-    if (!ETCore->ETFileDisplayedList || !BrowserList) return;
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                      BrowserList != NULL);
 
     /* Check if scanner window is opened */
     if (!ScannerWindow)
@@ -1929,7 +1930,8 @@ void Action_Remove_Selected_Tags (void)
     double fraction;
     GtkTreeSelection *selection;
 
-    if (!ETCore->ETFileDisplayedList || !BrowserList) return;
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                      BrowserList != NULL);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -1985,7 +1987,8 @@ gint Action_Undo_Selected_Files (void)
     ET_File *etfile;
     GtkTreeSelection *selection;
 
-    if (!ETCore->ETFileDisplayedList || !BrowserList) return FALSE;
+    g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                          BrowserList != NULL, FALSE);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2021,7 +2024,7 @@ void Action_Undo_From_History_List (void)
 {
     ET_File *ETFile;
 
-    if (!ETCore->ETFileList) return;
+    g_return_if_fail (ETCore->ETFileList != NULL);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2051,7 +2054,8 @@ gint Action_Redo_Selected_File (void)
     ET_File *etfile;
     GtkTreeSelection *selection;
 
-    if (!ETCore->ETFileDisplayedList || !BrowserList) return FALSE;
+    g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                          BrowserList != NULL, FALSE);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2085,7 +2089,7 @@ void Action_Redo_From_History_List (void)
 {
     ET_File *ETFile;
 
-    if (!ETCore->ETFileDisplayedList) return;
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2127,9 +2131,11 @@ gint Save_All_Files_With_Answer (gboolean force_saving_files)
 {
     GList *etfilelist;
 
-    if (!ETCore || !ETCore->ETFileList) return FALSE;
-    etfilelist = g_list_first(ETCore->ETFileList);
-    return Save_List_Of_Files(etfilelist,force_saving_files);
+    g_return_val_if_fail (ETCore != NULL || ETCore->ETFileList != NULL, FALSE);
+
+    etfilelist = g_list_first (ETCore->ETFileList);
+
+    return Save_List_Of_Files (etfilelist, force_saving_files);
 }
 
 /*
@@ -2144,7 +2150,7 @@ Save_Selected_Files_With_Answer (gboolean force_saving_files)
     ET_File *etfile;
     GtkTreeSelection *selection;
 
-    if (!BrowserList) return FALSE;
+    g_return_val_if_fail (BrowserList != NULL, FALSE);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
     selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
@@ -2188,7 +2194,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
     GtkWidget *widget_focused;
     GtkTreePath *currentPath = NULL;
 
-    if (!ETCore) return FALSE;
+    g_return_val_if_fail (ETCore != NULL, FALSE);
 
     /* Save the current position in the list */
     etfile_save_position = ETCore->ETFileDisplayed;
@@ -2395,7 +2401,8 @@ Delete_Selected_Files_With_Answer (void)
     GtkTreeRowReference *rowref;
     GtkTreeSelection *selection;
 
-    if (!ETCore->ETFileDisplayedList || !BrowserList) return FALSE;
+    g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                          BrowserList != NULL, FALSE);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2536,8 +2543,7 @@ Save_File (ET_File *ETFile, gboolean multiple_files,
     gchar *basename_cur_utf8, *basename_new_utf8;
     gchar *dirname_cur_utf8, *dirname_new_utf8;
 
-
-    if (!ETFile) return 0;
+    g_return_val_if_fail (ETFile != NULL, 0);
 
     basename_cur_utf8 = g_path_get_basename(filename_cur_utf8);
     basename_new_utf8 = g_path_get_basename(filename_new_utf8);
@@ -3328,7 +3334,7 @@ Delete_File (ET_File *ETFile, gboolean multiple_files)
     gint response;
     gint stop_loop;
 
-    if (!ETFile) return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     // Filename of the file to delete
     cur_filename      = ((File_Name *)(ETFile->FileNameCur)->data)->value;
@@ -3447,9 +3453,10 @@ Copy_File (const gchar *fileold, const gchar *filenew)
     return TRUE;
 }
 
-void Action_Select_Browser_Style (void)
+void
+Action_Select_Browser_Style (void)
 {
-    if (!ETCore->ETFileDisplayedList) return;
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -3484,8 +3491,7 @@ gboolean Read_Directory (gchar *path_real)
     GtkAction *uiaction;
     GtkWidget *TBViewMode;
 
-    if (!path_real)
-        return FALSE;
+    g_return_val_if_fail (path_real != NULL, FALSE);
 
     ReadingDirectory = TRUE;    /* A flag to avoid to start another reading */
 
@@ -4074,9 +4080,9 @@ Disable_Command_Buttons (void)
 static void
 Tag_Area_Set_Sensitive (gboolean activate)
 {
-    if (!TagArea) return;
+    g_return_if_fail (TagArea != NULL);
 
-    // TAG Area (entries + buttons)
+    /* TAG Area (entries + buttons). */
     gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(TagArea)),activate);
 
     /*// TAG Area
@@ -4110,9 +4116,9 @@ Tag_Area_Set_Sensitive (gboolean activate)
 static void
 File_Area_Set_Sensitive (gboolean activate)
 {
-    if (!FileArea) return;
+    g_return_if_fail (FileArea != NULL);
 
-    // File Area
+    /* File Area. */
     gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(FileArea)),activate);
     /*gtk_widget_set_sensitive(GTK_WIDGET(FileEntry),activate);*/
 }
@@ -4122,10 +4128,10 @@ File_Area_Set_Sensitive (gboolean activate)
  */
 void Tag_Area_Display_Controls (ET_File *ETFile)
 {
-    if (!ETFile || !ETFile->ETFileDescription || !TitleLabel)
-        return;
+    g_return_if_fail (ETFile != NULL || ETFile->ETFileDescription != NULL ||
+                      TitleLabel != NULL);
 
-    // Commun controls for all tags
+    /* Common controls for all tags. */
     gtk_widget_show(GTK_WIDGET(TitleLabel));
     gtk_widget_show(GTK_WIDGET(TitleEntry));
     gtk_widget_show(GTK_WIDGET(TitleMButton));
@@ -4422,9 +4428,9 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
  */
 void Clear_Tag_Entry_Fields (void)
 {
-    //GtkTextBuffer *textbuffer;
+    /* GtkTextBuffer *textbuffer; */
 
-    if (!TitleEntry) return;
+    g_return_if_fail (TitleEntry != NULL);
 
     gtk_entry_set_text(GTK_ENTRY(TitleEntry),                       "");
     gtk_entry_set_text(GTK_ENTRY(ArtistEntry),                      "");
@@ -4436,8 +4442,8 @@ void Clear_Tag_Entry_Fields (void)
     gtk_entry_set_text(GTK_ENTRY(TrackTotalEntry),                  "");
     gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(GenreCombo))),       "");
     gtk_entry_set_text(GTK_ENTRY(CommentEntry),                     "");
-    //textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(CommentView));
-    //gtk_text_buffer_set_text(GTK_TEXT_BUFFER(textbuffer),           "", -1);
+    /* textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(CommentView));
+     * gtk_text_buffer_set_text(GTK_TEXT_BUFFER(textbuffer),           "", -1); */
     gtk_entry_set_text(GTK_ENTRY(ComposerEntry),                    "");
     gtk_entry_set_text(GTK_ENTRY(OrigArtistEntry),                  "");
     gtk_entry_set_text(GTK_ENTRY(CopyrightEntry),                   "");
@@ -4450,11 +4456,12 @@ void Clear_Tag_Entry_Fields (void)
 /*
  * Clear the entry of file area
  */
-void Clear_File_Entry_Field (void)
+void
+Clear_File_Entry_Field (void)
 {
-    if (!FileEntry) return;
+    g_return_if_fail (FileEntry != NULL);
 
-    gtk_entry_set_text(GTK_ENTRY(FileEntry),"");
+    gtk_entry_set_text (GTK_ENTRY (FileEntry),"");
 }
 
 
@@ -4463,7 +4470,7 @@ void Clear_File_Entry_Field (void)
  */
 void Clear_Header_Fields (void)
 {
-    if (!VersionValueLabel) return;
+    g_return_if_fail (VersionValueLabel != NULL);
 
     /* Default values are MPs data */
     gtk_label_set_text(GTK_LABEL(VersionLabel),        _("Encoder:"));
diff --git a/src/et_core.c b/src/et_core.c
index dda114a..c965a34 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -230,7 +230,7 @@ ET_Get_File_Description (const gchar *filename)
 /*
  * Returns TRUE if the file is supported, else returns FALSE
  */
-gboolean ET_File_Is_Supported (gchar *filename)
+gboolean ET_File_Is_Supported (const gchar *filename)
 {
     if (ET_Get_File_Description(filename)->FileType != UNKNOWN_FILE)
         return TRUE;
@@ -1057,7 +1057,7 @@ GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
  */
 void ET_Sort_Displayed_File_List_And_Update_UI (ET_Sorting_Type Sorting_Type)
 {
-    if (!ETCore->ETFileList) return;
+    g_return_if_fail (ETCore->ETFileList != NULL);
 
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
@@ -2011,7 +2011,7 @@ gboolean ET_Free_File_List (void)
 {
     GList *list = NULL;
 
-    if (!ETCore || !ETCore->ETFileList) return FALSE;
+    g_return_val_if_fail (ETCore != NULL || ETCore->ETFileList != NULL, FALSE);
 
     list = g_list_last(ETCore->ETFileList);
     while (list)
@@ -2035,10 +2035,22 @@ gboolean ET_Free_File_List_Item (ET_File *ETFile)
     if (ETFile)
     {
         /* Frees the lists */
-        ET_Free_File_Name_List(ETFile->FileNameList);
-        ET_Free_File_Name_List(ETFile->FileNameListBak);
-        ET_Free_File_Tag_List (ETFile->FileTagList);
-        ET_Free_File_Tag_List (ETFile->FileTagListBak);
+        if (ETFile->FileNameList)
+        {
+            ET_Free_File_Name_List(ETFile->FileNameList);
+        }
+        if (ETFile->FileNameListBak)
+        {
+            ET_Free_File_Name_List(ETFile->FileNameListBak);
+        }
+        if (ETFile->FileTagList)
+        {
+            ET_Free_File_Tag_List (ETFile->FileTagList);
+        }
+        if (ETFile->FileTagListBak)
+        {
+            ET_Free_File_Tag_List (ETFile->FileTagListBak);
+        }
         /* Frees infos of ETFileInfo */
         ET_Free_File_Info_Item (ETFile->ETFileInfo);
         g_free(ETFile->ETFileExtension);
@@ -2056,7 +2068,7 @@ gboolean ET_Free_File_Name_List (GList *FileNameList)
 {
     GList *list;
 
-    if (!FileNameList) return FALSE;
+    g_return_val_if_fail (FileNameList != NULL, FALSE);
 
     list = g_list_last(FileNameList);
     while (list)
@@ -2078,7 +2090,7 @@ gboolean ET_Free_File_Name_List (GList *FileNameList)
  */
 gboolean ET_Free_File_Name_Item (File_Name *FileName)
 {
-    if (!FileName) return FALSE;
+    g_return_val_if_fail (FileName != NULL, FALSE);
 
     g_free(FileName->value);
     g_free(FileName->value_utf8);
@@ -2097,7 +2109,7 @@ ET_Free_File_Tag_List (GList *FileTagList)
 {
     GList *list;
 
-    if (!FileTagList) return FALSE;
+    g_return_val_if_fail (FileTagList != NULL, FALSE);
 
     list = g_list_last(FileTagList);
     while (list)
@@ -2140,7 +2152,7 @@ ET_Free_File_Tag_Item_Other_Field (File_Tag *FileTag)
  */
 gboolean ET_Free_File_Tag_Item (File_Tag *FileTag)
 {
-    if (!FileTag) return FALSE;
+    g_return_val_if_fail (FileTag != NULL, FALSE);
 
     g_free(FileTag->title);
     g_free(FileTag->artist);
@@ -2173,7 +2185,7 @@ gboolean ET_Free_File_Tag_Item (File_Tag *FileTag)
 static gboolean
 ET_Free_File_Info_Item (ET_File_Info *ETFileInfo)
 {
-    if (!ETFileInfo) return FALSE;
+    g_return_val_if_fail (ETFileInfo != NULL, FALSE);
 
     g_free(ETFileInfo->mpc_profile);
     g_free(ETFileInfo->mpc_version);
@@ -2192,7 +2204,8 @@ ET_Free_History_File_List (void)
 {
     GList *list;
 
-    if (!ETCore || !ETCore->ETHistoryFileList) return FALSE;
+    g_return_val_if_fail (ETCore != NULL || ETCore->ETHistoryFileList != NULL,
+                          FALSE);
 
     ETCore->ETHistoryFileList = g_list_first(ETCore->ETHistoryFileList);
     list = ETCore->ETHistoryFileList;
@@ -2214,7 +2227,8 @@ ET_Free_History_File_List (void)
 static gboolean
 ET_Free_Displayed_File_List (void)
 {
-    if (!ETCore || !ETCore->ETFileDisplayedList) return FALSE;
+    g_return_val_if_fail (ETCore != NULL ||
+                          ETCore->ETFileDisplayedList != NULL, FALSE);
 
     ETCore->ETFileDisplayedList = g_list_first(ETCore->ETFileDisplayedList);
     ETCore->ETFileDisplayedList = NULL;
@@ -2233,7 +2247,8 @@ ET_Free_Artist_Album_File_List (void)
     GList *AlbumList;
     GList *etfilelist;
 
-    if (!ETCore || !ETCore->ETArtistAlbumFileList) return FALSE;
+    g_return_val_if_fail (ETCore != NULL ||
+                          ETCore->ETArtistAlbumFileList != NULL, FALSE);
 
     ArtistList = ETCore->ETArtistAlbumFileList;
     while (ArtistList)
@@ -2294,8 +2309,9 @@ gboolean ET_Copy_File_Tag_Item (ET_File *ETFile, File_Tag *FileTag)
 {
     File_Tag *FileTagCur;
 
-    if (!ETFile || !ETFile->FileTag || !(File_Tag *)(ETFile->FileTag)->data || !FileTag)
-        return FALSE;
+    g_return_val_if_fail (ETFile != NULL || ETFile->FileTag != NULL ||
+                          (File_Tag *)(ETFile->FileTag)->data != NULL ||
+                          FileTag != NULL, FALSE);
 
     /* The data to duplicate to FileTag */
     FileTagCur = (File_Tag *)(ETFile->FileTag)->data;
@@ -2467,8 +2483,7 @@ gboolean ET_Copy_File_Tag_Item (ET_File *ETFile, File_Tag *FileTag)
  */
 gboolean ET_Set_Filename_File_Name_Item (File_Name *FileName, gchar *filename_utf8, gchar *filename)
 {
-    if (!FileName)
-        return FALSE;
+    g_return_val_if_fail (FileName != FALSE, FALSE);
 
     if (filename_utf8 && filename)
     {
@@ -2500,7 +2515,7 @@ gboolean ET_Set_Filename_File_Name_Item (File_Name *FileName, gchar *filename_ut
  */
 gboolean ET_Set_Field_File_Tag_Item (gchar **FileTagField, const gchar *value)
 {
-    if (!FileTagField) return FALSE;
+    g_return_val_if_fail (FileTagField != NULL, FALSE);
 
     if (*FileTagField != NULL)
     {
@@ -2525,7 +2540,7 @@ gboolean ET_Set_Field_File_Tag_Item (gchar **FileTagField, const gchar *value)
  */
 gboolean ET_Set_Field_File_Tag_Picture (Picture **FileTagField, Picture *pic)
 {
-    if (!FileTagField) return FALSE;
+    g_return_val_if_fail (FileTagField != NULL, FALSE);
 
     if (*FileTagField != NULL)
     {
@@ -2555,9 +2570,9 @@ void ET_Display_File_Data_To_UI (ET_File *ETFile)
     gchar *cur_filename_utf8;
     gchar *msg;
 
-    if (!ETFile
-    ||  !((GList *)ETFile->FileNameCur)->data ) // For the case where ETFile is an "empty" structure
-        return;
+    g_return_if_fail (ETFile != NULL ||
+                      ((GList *)ETFile->FileNameCur)->data != NULL);
+                      /* For the case where ETFile is an "empty" structure. */
 
     cur_filename      = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value;
     cur_filename_utf8 = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value_utf8;
@@ -2697,7 +2712,7 @@ ET_Display_File_And_List_Status_To_UI (ET_File *ETFile)
     gchar *text;
     gchar *cur_filename;
 
-    if (!ETFile) return;
+    g_return_if_fail (ETFile != NULL);
 
     cur_filename = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value;
 
@@ -2740,7 +2755,7 @@ ET_Display_Filename_To_UI (ET_File *ETFile)
     gchar *dirname_utf8;
     gchar *text;
 
-    if (!ETFile) return;
+    g_return_if_fail (ETFile != NULL);
 
     new_filename_utf8 = ((File_Name *)((GList *)ETFile->FileNameNew)->data)->value_utf8;
 
@@ -3729,7 +3744,7 @@ gboolean ET_Save_File_Tag_To_HD (ET_File *ETFile)
     struct utimbuf utimbufbuf;
     gboolean file_set_properties;
 
-    if (!ETFile) return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     cur_filename      = ((File_Name *)(ETFile->FileNameCur)->data)->value;
     cur_filename_utf8 = ((File_Name *)(ETFile->FileNameCur)->data)->value_utf8;
@@ -3898,7 +3913,7 @@ gboolean ET_Manage_Changes_Of_File_Data (ET_File *ETFile, File_Name *FileName, F
 {
     gboolean undo_added = FALSE;
 
-    if (!ETFile) return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     /*
      * Detect changes of filename and generate the filename undo list
@@ -3987,8 +4002,7 @@ gboolean ET_Detect_Changes_Of_File_Tag (File_Tag *FileTag1, File_Tag *FileTag2)
     Picture *pic1;
     Picture *pic2;
 
-    if ( !FileTag1 && !FileTag2 )
-        return FALSE;
+    g_return_val_if_fail (FileTag1 != NULL && FileTag2 != NULL, FALSE);
 
     if ( ( FileTag1 && !FileTag2)
       || (!FileTag1 &&  FileTag2) )
@@ -4179,7 +4193,7 @@ ET_Add_File_To_History_List (ET_File *ETFile)
 {
     ET_History_File *ETHistoryFile;
 
-    if (!ETFile) return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     ETHistoryFile = g_malloc0(sizeof(ET_History_File));
     ETHistoryFile->ETFile = ETFile;
@@ -4206,8 +4220,7 @@ gboolean ET_Undo_File_Data (ET_File *ETFile)
     gboolean has_filetag_undo_data  = FALSE;
     guint    filename_key, filetag_key, undo_key;
 
-    if (!ETFile)
-        return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     /* Find the valid key */
     if (ETFile->FileNameNew->prev && ETFile->FileNameNew->data)
@@ -4249,7 +4262,7 @@ gboolean ET_File_Data_Has_Undo_Data (ET_File *ETFile)
     gboolean has_filename_undo_data = FALSE;
     gboolean has_filetag_undo_data  = FALSE;
 
-    if (!ETFile) return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     if (ETFile->FileNameNew && ETFile->FileNameNew->prev) has_filename_undo_data = TRUE;
     if (ETFile->FileTag && ETFile->FileTag->prev)         has_filetag_undo_data  = TRUE;
@@ -4267,8 +4280,7 @@ gboolean ET_Redo_File_Data (ET_File *ETFile)
     gboolean has_filetag_redo_data  = FALSE;
     guint    filename_key, filetag_key, undo_key;
 
-    if (!ETFile)
-        return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     /* Find the valid key */
     if (ETFile->FileNameNew->next && ETFile->FileNameNew->next->data)
@@ -4310,7 +4322,7 @@ gboolean ET_File_Data_Has_Redo_Data (ET_File *ETFile)
     gboolean has_filename_redo_data = FALSE;
     gboolean has_filetag_redo_data  = FALSE;
 
-    if (!ETFile) return FALSE;
+    g_return_val_if_fail (ETFile != NULL, FALSE);
 
     if (ETFile->FileNameNew && ETFile->FileNameNew->next) has_filename_redo_data = TRUE;
     if (ETFile->FileTag && ETFile->FileTag->next)         has_filetag_redo_data  = TRUE;
@@ -4328,7 +4340,8 @@ ET_File *ET_Undo_History_File_Data (void)
     ET_File *ETFile;
     ET_History_File *ETHistoryFile;
 
-    if (!ETCore->ETHistoryFileList || !ET_History_File_List_Has_Undo_Data()) return NULL;
+    g_return_val_if_fail (ETCore->ETHistoryFileList != NULL ||
+                          !ET_History_File_List_Has_Undo_Data (), NULL);
 
     ETHistoryFile = (ET_History_File *)ETCore->ETHistoryFileList->data;
     ETFile        = (ET_File *)ETHistoryFile->ETFile;
@@ -4403,7 +4416,7 @@ gboolean ET_Check_If_File_Is_Saved (ET_File *ETFile)
     File_Tag  *FileTag     = NULL;
     File_Name *FileNameNew = NULL;
 
-    if (!ETFile) return TRUE;
+    g_return_val_if_fail (ETFile != NULL, TRUE);
 
     if (ETFile->FileTag)
         FileTag     = ETFile->FileTag->data;
@@ -4687,12 +4700,13 @@ gboolean ET_File_Name_Convert_Character (gchar *filename_utf8)
  * Returns the number of file in the directory of the selected file.
  * Parameter "path" should be in UTF-8
  */
-guint ET_Get_Number_Of_Files_In_Directory (gchar *path_utf8)
+guint
+ET_Get_Number_Of_Files_In_Directory (const gchar *path_utf8)
 {
     GList *etfilelist;
     guint  count = 0;
 
-    if (!path_utf8) return count;
+    g_return_val_if_fail (path_utf8 != NULL, count);
 
     etfilelist = g_list_first(ETCore->ETFileList);
     while (etfilelist)
diff --git a/src/et_core.h b/src/et_core.h
index 563e512..089cf35 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -357,7 +357,7 @@ void ET_Core_Initialize (void);
 void ET_Core_Free       (void);
 void ET_Core_Destroy    (void);
 
-gboolean ET_File_Is_Supported            (gchar *filename);
+gboolean ET_File_Is_Supported (const gchar *filename);
 GList   *ET_Add_File_To_File_List        (gchar *filename);
 gboolean ET_Remove_File_From_File_List   (ET_File *ETFile);
 
@@ -406,7 +406,7 @@ void     ET_Mark_File_Name_As_Saved              (ET_File *ETFile);
 void     ET_Update_Directory_Name_Into_File_List (gchar* last_path, gchar *new_path);
 gboolean ET_File_Name_Convert_Character          (gchar *filename_utf8);
 gchar   *ET_File_Name_Generate                   (ET_File *ETFile, gchar *new_file_name);
-guint    ET_Get_Number_Of_Files_In_Directory     (gchar *path_utf8);
+guint ET_Get_Number_Of_Files_In_Directory (const gchar *path_utf8);
 
 gboolean ET_Detect_Changes_Of_File_Tag          (File_Tag  *FileTag1,  File_Tag  *FileTag2);
 
diff --git a/src/log.c b/src/log.c
index 11f2a3a..79f96e0 100644
--- a/src/log.c
+++ b/src/log.c
@@ -195,7 +195,7 @@ Log_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter)
      */
     GtkTreePath *rowPath;
 
-    if (!treeModel) return;
+    g_return_if_fail (treeModel != NULL);
 
     rowPath = gtk_tree_model_get_path(treeModel, rowIter);
     gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(LogList), rowPath, NULL, FALSE, 0, 0);
diff --git a/src/misc.c b/src/misc.c
index b0feb90..f5e90c9 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -387,19 +387,20 @@ gchar *Get_Active_Combo_Box_Item (GtkComboBox *combo)
  * Event attached to an entry to disable another widget (for example: a button)
  * when the entry is empty
  */
-void Entry_Changed_Disable_Object(GtkWidget *widget_to_disable, GtkEditable *source_widget)
+void
+Entry_Changed_Disable_Object (GtkWidget *widget_to_disable,
+                              GtkEditable *source_widget)
 {
-    gchar *text = NULL;
+    const gchar *text;
+
+    g_return_if_fail (widget_to_disable != NULL || source_widget != NULL);
 
-    if (!widget_to_disable || !source_widget) return;
+    text = gtk_entry_get_text (GTK_ENTRY (source_widget));
 
-    text = gtk_editable_get_chars(GTK_EDITABLE(source_widget),0,-1);
     if (!text || strlen(text)<1)
         gtk_widget_set_sensitive(widget_to_disable,FALSE);
     else
         gtk_widget_set_sensitive(widget_to_disable,TRUE);
-
-    g_free(text);
 }
 
 /*
@@ -466,7 +467,7 @@ gboolean Parse_Date (void)
     time_t t;
     struct tm t0;
 
-    if (!DATE_AUTO_COMPLETION) return FALSE;
+    g_return_val_if_fail (DATE_AUTO_COMPLETION, FALSE);
 
     /* Get the info entered by user */
     year = gtk_entry_get_text(GTK_ENTRY(YearEntry));
@@ -508,7 +509,7 @@ void Load_Genres_List_To_UI (void)
     guint i;
     GtkTreeIter iter;
 
-    if (!GenreComboModel) return;
+    g_return_if_fail (GenreComboModel != NULL);
 
     gtk_list_store_append(GTK_LIST_STORE(GenreComboModel), &iter);
     gtk_list_store_set(GTK_LIST_STORE(GenreComboModel), &iter, MISC_COMBO_TEXT, "", -1);
@@ -534,7 +535,8 @@ void Load_Track_List_To_UI (void)
     GtkTreeIter iter;
     gchar *text;
 
-    if (!ETCore->ETFileDisplayedList || !TrackEntryComboModel) return;
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                      TrackEntryComboModel != NULL);
 
     // Number mini of items
     //if ((len=ETCore->ETFileDisplayedList_Length) < 30)
@@ -992,7 +994,7 @@ void Run_Audio_Player_Using_Selection (void)
     ET_File *etfile;
     GtkTreeSelection *selection;
 
-    if (!BrowserList) return;
+    g_return_if_fail (BrowserList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
     selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
@@ -1021,7 +1023,7 @@ void Run_Audio_Player_Using_Browser_Artist_List (void)
     GList *AlbumList, *etfilelist;
     GList *concatenated_list = NULL;
 
-    if (!BrowserArtistList) return;
+    g_return_if_fail (BrowserArtistList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserArtistList));
     if (!gtk_tree_selection_get_selected(selection, &artistListModel, &iter))
@@ -1054,7 +1056,7 @@ void Run_Audio_Player_Using_Browser_Album_List (void)
     GtkTreeModel *albumListModel;
     GList *etfilelist;
 
-    if (!BrowserAlbumList) return;
+    g_return_if_fail (BrowserAlbumList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserAlbumList));
     if (!gtk_tree_selection_get_selected(selection, &albumListModel, &iter))
@@ -1195,23 +1197,22 @@ Get_File_Size (const gchar *filename)
 {
     struct stat statbuf;
 
-    if (filename)
-    {
-        stat(filename,&statbuf);
-        return statbuf.st_size;
-    }else
-    {
-        return 0;
-    }
+    g_return_val_if_fail (filename != NULL, 0);
+
+    stat (filename, &statbuf);
+
+    return statbuf.st_size;
 }
 
 /*
  * Delete spaces at the end and the beginning of the string
  */
-void Strip_String (gchar *string)
+void
+Strip_String (gchar *string)
 {
-    if (!string) return;
-    string = g_strstrip(string);
+    g_return_if_fail (string != NULL);
+
+    string = g_strstrip (string);
 }
 
 
@@ -3480,7 +3481,7 @@ Load_Filename_List_Insert_Blank_Line (GtkWidget *treeview)
     GtkTreeIter *temp;
     GtkTreeModel *model;
 
-    if (!treeview) return;
+    g_return_if_fail (treeview != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
 
@@ -3538,7 +3539,7 @@ Load_Filename_List_Delete_Line (GtkWidget *treeview)
     GtkTreeModel *model;
     gboolean rowafter;
 
-    if (!treeview) return;
+    g_return_if_fail (treeview != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
 
@@ -3573,7 +3574,7 @@ Load_Filename_List_Move_Up (GtkWidget *treeview)
     GtkTreeModel *treemodel;
     gboolean valid;
 
-    if (!treeview) return;
+    g_return_if_fail (treeview != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
@@ -3627,7 +3628,7 @@ Load_Filename_List_Move_Down (GtkWidget *treeview)
     GtkTreeModel *treemodel;
     gboolean valid;
 
-    if (!treeview) return;
+    g_return_if_fail (treeview != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
@@ -3670,7 +3671,7 @@ Load_Filename_List_Move_Down (GtkWidget *treeview)
 static void
 Load_Filename_List_Reload (GtkWidget *treeview)
 {
-    if (!treeview) return;
+    g_return_if_fail (treeview != NULL);
 
     if (GTK_TREE_VIEW(treeview) == GTK_TREE_VIEW(LoadFileContentList))
     {
@@ -3693,7 +3694,7 @@ Load_Filename_Update_Text_Line(GtkWidget *entry, GtkWidget *list)
     GtkTreeModel *model;
     gboolean hasSelectedRows = FALSE;
 
-    if (!list || !entry) return;
+    g_return_if_fail (entry != NULL || list != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
     hasSelectedRows = gtk_tree_selection_get_selected(selection, &model, &SelectedRow);
diff --git a/src/picture.c b/src/picture.c
index aa4facc..74d501c 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -155,7 +155,7 @@ void Picture_Clear_Button_Clicked (GObject *object)
     gpointer proxy;
     gint n = 0;
 
-    if (!PictureEntryView) return;
+    g_return_if_fail (PictureEntryView != NULL);
 
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(PictureEntryView));
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(PictureEntryView));
@@ -283,7 +283,7 @@ void Picture_Add_Button_Clicked (GObject *object)
     static gchar *init_dir = NULL;
     gint response;
 
-    if (!PictureEntryView) return;
+    g_return_if_fail (PictureEntryView != NULL);
 
     parent_window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object)));
     if (!gtk_widget_is_toplevel(GTK_WIDGET(parent_window)))
@@ -398,8 +398,7 @@ void Picture_Properties_Button_Clicked (GObject *object)
     gint response;
     Picture_Type pic_type;
 
-
-    if (!PictureEntryView) return;
+    g_return_if_fail (PictureEntryView != NULL);
 
     parent_window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object)));
     if (!gtk_widget_is_toplevel(GTK_WIDGET(parent_window)))
@@ -603,8 +602,7 @@ void Picture_Save_Button_Clicked (GObject *object)
     GtkTreeModel *model;
     gint selection_nbr, selection_i = 1;
 
-
-    if (!PictureEntryView) return;
+    g_return_if_fail (PictureEntryView != NULL);
 
     parent_window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object)));
     if (!gtk_widget_is_toplevel(GTK_WIDGET(parent_window)))
@@ -938,7 +936,7 @@ void PictureEntry_Update (Picture *pic, gboolean select_it)
     GdkPixbufLoader *loader = 0;
     GError *error = NULL;
     
-    if (!pic || !PictureEntryView) return;
+    g_return_if_fail (pic != NULL && PictureEntryView != NULL);
 
     if (!pic->data)
     {
diff --git a/src/prefs.c b/src/prefs.c
index 5a3d12d..43675be 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -1944,7 +1944,7 @@ static void
 Scanner_Convert_Check_Button_Toggled_1 (GtkWidget *object_rec,
                                         GtkWidget *object_emi)
 {
-    if (!object_rec || !object_emi) return;
+    g_return_if_fail (object_rec != NULL || object_emi != NULL);
 
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object_emi)) == TRUE)
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object_rec),!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object_emi)));
diff --git a/src/scan.c b/src/scan.c
index 994ab10..5620c6f 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -312,7 +312,9 @@ Scan_Tag_With_Mask (ET_File *ETFile)
     gchar *filename_utf8;
     File_Tag *FileTag;
 
-    if (!ScannerWindow || !ScanTagMaskCombo || !ETFile) return;
+    g_return_if_fail (ScannerWindow != NULL || ScanTagMaskCombo != NULL ||
+                      ETFile != NULL);
+
     mask = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(ScanTagMaskCombo)))));
     if (!mask) return;
 
@@ -396,7 +398,7 @@ Scan_Generate_New_Tag_From_Mask (ET_File *ETFile, gchar *mask)
     guint file_splitted_index;
     Scan_Mask_Item *mask_item;
 
-    if (!ETFile || !mask) return NULL;
+    g_return_val_if_fail (ETFile != NULL || mask != NULL, NULL);
 
     filename_utf8 = g_strdup(((File_Name *)((GList *)ETFile->FileNameNew)->data)->value_utf8);
     if (!filename_utf8) return NULL;
@@ -662,7 +664,8 @@ Scan_Rename_File_With_Mask (ET_File *ETFile)
     gchar *mask = NULL;
     File_Name *FileName;
 
-    if (!ScannerWindow || !RenameFileMaskCombo || !ETFile) return;
+    g_return_if_fail (ScannerWindow != NULL || RenameFileMaskCombo != NULL ||
+                      ETFile != NULL);
 
     mask = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameFileMaskCombo)))));
     if (!mask) return;
@@ -745,8 +748,7 @@ gchar *Scan_Generate_New_Filename_From_Mask (ET_File *ETFile, gchar *mask, gbool
     File_Mask_Item *mask_item_next;
     gint counter = 0;
 
-
-    if (!ETFile || !mask) return NULL;
+    g_return_val_if_fail (ETFile != NULL || mask != NULL, NULL);
 
     /*
      * Check for a directory in the mask
@@ -1114,8 +1116,7 @@ Scan_Process_Fields (ET_File *ETFile)
     gchar     *filename_utf8;
     gchar     *string;
 
-
-    if (!ScannerWindow || !ETFile) return;
+    g_return_if_fail (ScannerWindow != NULL || ETFile != NULL);
 
     st_filename = (File_Name *)ETFile->FileNameNew->data;
     st_filetag  = (File_Tag  *)ETFile->FileTag->data;
@@ -3070,7 +3071,7 @@ ScannerWindow_Key_Press (GtkWidget *window, GdkEvent *event)
  */
 void Scan_Select_Mode_And_Run_Scanner (ET_File *ETFile)
 {
-    if (!ScannerWindow || !ETFile) return;
+    g_return_if_fail (ScannerWindow != NULL || ETFile != NULL);
 
     if (gtk_combo_box_get_active(GTK_COMBO_BOX(ScannerOptionCombo)) == SCANNER_FILL_TAG)
     {
@@ -3381,7 +3382,7 @@ Scan_Check_Editor_Mask (GtkWidget *widget_to_show_hide,
 static void
 Scan_Toggle_Legend_Button (void)
 {
-    if (!LegendButton || !LegendFrame) return;
+    g_return_if_fail (LegendButton != NULL || LegendFrame != NULL);
 
     if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(LegendButton)) )
         gtk_widget_show_all(LegendFrame);
@@ -3397,7 +3398,8 @@ Scan_Toggle_Mask_Editor_Button (void)
     GtkTreeSelection *selection;
     GtkTreeIter iter;
 
-    if (!MaskEditorButton || !MaskEditorFrame || !MaskEditorList) return;
+    g_return_if_fail (MaskEditorButton != NULL || MaskEditorFrame != NULL ||
+                      MaskEditorList != NULL);
 
     if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(MaskEditorButton)) )
     {
@@ -3635,7 +3637,7 @@ Mask_Editor_List_New (void)
     GtkTreeSelection *selection;
     GtkTreeModel *treemodel;
 
-    if (!MaskEditorList) return;
+    g_return_if_fail (MaskEditorList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(MaskEditorList));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(MaskEditorList));
@@ -3661,7 +3663,7 @@ Mask_Editor_List_Duplicate (void)
     GtkTreeModel *treeModel;
     gboolean valid;
 
-    if (!MaskEditorList) return;
+    g_return_if_fail (MaskEditorList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(MaskEditorList));
     selectedRows = gtk_tree_selection_get_selected_rows(selection, NULL);
@@ -3771,7 +3773,7 @@ Mask_Editor_List_Remove (void)
     GtkTreeIter iter;
     GtkTreeModel *treemodel;
 
-    if (!MaskEditorList) return;
+    g_return_if_fail (MaskEditorList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(MaskEditorList));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(MaskEditorList));
@@ -3817,7 +3819,7 @@ Mask_Editor_List_Move_Up (void)
     GtkTreeModel *treemodel;
     gboolean valid;
 
-    if (!MaskEditorList) return;
+    g_return_if_fail (MaskEditorList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(MaskEditorList));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(MaskEditorList));
@@ -3871,7 +3873,7 @@ Mask_Editor_List_Move_Down (void)
     GtkTreeModel *treemodel;
     gboolean valid;
 
-    if (!MaskEditorList) return;
+    g_return_if_fail (MaskEditorList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(MaskEditorList));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(MaskEditorList));
@@ -3920,7 +3922,7 @@ Mask_Editor_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter)
      */
     GtkTreePath *rowPath;
 
-    if (!treeModel) return;
+    g_return_if_fail (treeModel != NULL);
 
     rowPath = gtk_tree_model_get_path(treeModel, rowIter);
     gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(MaskEditorList), rowPath, NULL, FALSE, 0, 0);
@@ -4025,7 +4027,7 @@ Mask_Editor_Entry_Changed (void)
     const gchar* text;
     gboolean valid;
 
-    if (!MaskEditorList) return;
+    g_return_if_fail (MaskEditorList != NULL);
 
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(MaskEditorList));
     treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(MaskEditorList));



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