[balsa/popover: 1/19] balsa-message: Fix a scan-build report



commit be9b2fcf5273c11928e570b0c9201f939c729f0c
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon May 11 16:16:13 2020 -0400

    balsa-message: Fix a scan-build report
    
    * src/balsa-message.c (display_face): Fix a scan-build report
      when building with compface = false; the value store in x_face was
      never read.

 ChangeLog           |  5 +++++
 src/balsa-message.c | 52 ++++++++++++++++++++++++++--------------------------
 2 files changed, 31 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e25157aec..ef5abac5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-11  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       * src/balsa-message.c (display_face): Fix a scan-build report
+         when building with compface = false.
+
 2020-05-10  Pawel Salek  <pawsa0 gmail com>
 
        * NEWS, configure.ac, meson.build: release balsa-2.6.1
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 00238a784..ffda8a846 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1522,42 +1522,42 @@ static void
 display_face(BalsaMessage * balsa_message)
 {
     GtkWidget *face_box;
-    const gchar *face, *x_face = NULL;
-    GError *err = NULL;
-    GtkWidget *image;
 
     face_box = balsa_message->face_box;
     gtk_widget_hide(face_box);
     gtk_container_foreach(GTK_CONTAINER(face_box),
                           (GtkCallback) gtk_widget_destroy, NULL);
 
-    if (!balsa_message->message
-        || !((face = libbalsa_message_get_user_header(balsa_message->message, "Face"))
-             || (x_face =
-                 libbalsa_message_get_user_header(balsa_message->message,
-                                                  "X-Face")))) {
-        return;
-    }
+    if (balsa_message->message != NULL) {
+        const gchar *face;
+        GError *err = NULL;
+        GtkWidget *image = NULL;
 
-    if (face)
-        image = libbalsa_get_image_from_face_header(face, &err);
-    else {
+        face = libbalsa_message_get_user_header(balsa_message->message, "Face");
+        if (face != NULL) {
+            image = libbalsa_get_image_from_face_header(face, &err);
+        } else {
 #if HAVE_COMPFACE
-        image = libbalsa_get_image_from_x_face_header(x_face, &err);
-#else                           /* HAVE_COMPFACE */
-        return;
+            const gchar *x_face;
+
+            x_face = libbalsa_message_get_user_header(balsa_message->message, "X-Face");
+            if (x_face != NULL)
+                image = libbalsa_get_image_from_x_face_header(x_face, &err);
 #endif                          /* HAVE_COMPFACE */
-    }
-    if (err) {
-        balsa_information(LIBBALSA_INFORMATION_WARNING,
-                /* Translators: please do not translate Face. */
-                          _("Error loading Face: %s"), err->message);
-        g_error_free(err);
-        return;
-    }
+        }
 
-    gtk_box_pack_start(GTK_BOX(face_box), image, FALSE, FALSE, 0);
-    gtk_widget_show_all(face_box);
+        if (err != NULL) {
+            balsa_information(LIBBALSA_INFORMATION_WARNING,
+                    /* Translators: please do not translate Face. */
+                              _("Error loading Face: %s"), err->message);
+            g_error_free(err);
+        }
+
+        if (image != NULL) {
+            gtk_box_pack_start(GTK_BOX(face_box), image, FALSE, FALSE, 0);
+            gtk_widget_show_all(face_box);
+        }
+    }
 }
 
 static void


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