[gspell] Use g_clear_error()



commit 45fb1ce40f9098bbd897f43726b5765e542f3859
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Feb 4 12:32:48 2016 +0100

    Use g_clear_error()
    
    Even if nullifying the error variable is not needed, it is better to do
    so because if the code is modified in the future and the GError is
    re-used later in the function, there is a risk that the contributor
    doesn't nullify the GError, and when looking at the patch, everything
    could look fine.

 gspell/gspell-checker-dialog.c             |    3 +--
 gspell/gspell-inline-checker-text-buffer.c |    2 +-
 gspell/gspell-language.c                   |    2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/gspell/gspell-checker-dialog.c b/gspell/gspell-checker-dialog.c
index 9b67e37..5d50c2c 100644
--- a/gspell/gspell-checker-dialog.c
+++ b/gspell/gspell-checker-dialog.c
@@ -252,8 +252,7 @@ goto_next (GspellCheckerDialog *dialog)
        if (error != NULL)
        {
                show_error (dialog, error);
-               g_error_free (error);
-               error = NULL;
+               g_clear_error (&error);
        }
        else if (found)
        {
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index c2ca20e..93bc4ac 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -101,7 +101,7 @@ check_word (GspellInlineCheckerTextBuffer *spell,
        if (error != NULL)
        {
                g_warning ("Inline spell checker: %s", error->message);
-               g_error_free (error);
+               g_clear_error (&error);
        }
 
        if (!correctly_spelled)
diff --git a/gspell/gspell-language.c b/gspell/gspell-language.c
index d1c080c..42ecc95 100644
--- a/gspell/gspell-language.c
+++ b/gspell/gspell-language.c
@@ -248,7 +248,7 @@ iso_codes_parse (const GMarkupParser *parser,
        if (error != NULL)
        {
                g_warning ("%s: %s", basename, error->message);
-               g_error_free (error);
+               g_clear_error (&error);
        }
 }
 


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