[gdk-pixbuf] PNM: assert and assume that the module callbacks are non-NULL



commit c8be25b84c6e3c4191b93a7843a181d8ba7b06aa
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Nov 28 19:24:30 2017 -0600

    PNM: assert and assume that the module callbacks are non-NULL

 gdk-pixbuf/io-pnm.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/gdk-pixbuf/io-pnm.c b/gdk-pixbuf/io-pnm.c
index d6f3e216c..91e7dca67 100644
--- a/gdk-pixbuf/io-pnm.c
+++ b/gdk-pixbuf/io-pnm.c
@@ -824,6 +824,10 @@ gdk_pixbuf__pnm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
 {
        PnmLoaderContext *context;
        
+       g_assert (size_func != NULL);
+       g_assert (prepared_func != NULL);
+       g_assert (updated_func != NULL);
+
        context = g_try_malloc (sizeof (PnmLoaderContext));
        if (!context) {
                g_set_error_literal (error, GDK_PIXBUF_ERROR, 
@@ -954,7 +958,7 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data,
                        context->got_header = TRUE;
                }
 
-               if (context->size_func) {
+               {
                        gint w = context->width;
                        gint h = context->height;
                        (*context->size_func) (&w, &h, context->user_data);
@@ -1015,10 +1019,9 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data,
                        context->rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
                        
                        /* Notify the client that we are ready to go */
-                       if (context->prepared_func)
-                               (* context->prepared_func) (context->pixbuf,
-                                                           NULL,
-                                                           context->user_data);
+                       (* context->prepared_func) (context->pixbuf,
+                                                   NULL,
+                                                   context->user_data);
                }
                
                /* if we got here we're reading image data */
@@ -1029,7 +1032,7 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data,
                                break;
                        } else if (retval == PNM_FATAL_ERR) {
                                return FALSE;
-                       } else if (retval == PNM_OK && context->updated_func) { 
+                       } else if (retval == PNM_OK) {  
                                /* send updated signal */
                                (* context->updated_func) (context->pixbuf,
                                                           0, 


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