[gdk-pixbuf] tiff: Simplify gdk_pixbuf__tiff_image_stop_load() function



commit 6069c7b1d804f55c7fd592a66cfb12bf665849dc
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jul 13 18:52:01 2017 +0200

    tiff: Simplify gdk_pixbuf__tiff_image_stop_load() function
    
    Set a default value for retval, use g_clear_object() and add a reason
    behind the "error && !*error" check.

 gdk-pixbuf/io-tiff.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c
index 4d10ef0..fb5d550 100644
--- a/gdk-pixbuf/io-tiff.c
+++ b/gdk-pixbuf/io-tiff.c
@@ -454,7 +454,7 @@ gdk_pixbuf__tiff_image_stop_load (gpointer data,
 {
         TiffContext *context = data;
         TIFF *tiff;
-        gboolean retval;
+        gboolean retval = FALSE;
         
         g_return_val_if_fail (data != NULL, FALSE);
 
@@ -470,20 +470,18 @@ gdk_pixbuf__tiff_image_stop_load (gpointer data,
                                      GDK_PIXBUF_ERROR,
                                      GDK_PIXBUF_ERROR_FAILED,
                                      _("Failed to load TIFF image"));
-                retval = FALSE;
         } else {
                 GdkPixbuf *pixbuf;
                 
                 pixbuf = tiff_image_parse (tiff, context, error);
-                if (pixbuf)
-                        g_object_unref (pixbuf);
-                retval = pixbuf != NULL;
+                retval = (pixbuf != NULL);
+                g_clear_object (&pixbuf);
+                /* tiff_image_parse() can return NULL on success in a particular case */
                 if (!retval && error && !*error) {
                         g_set_error_literal (error,
                                              GDK_PIXBUF_ERROR,
                                              GDK_PIXBUF_ERROR_FAILED,
                                              _("Failed to load TIFF image"));
-                                retval = FALSE;
                 }
         }
 


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