[balsa] Do not cast argument of g_object_ref()



commit fed3c1568aa70ff42aecc9ea9408cba57a7b79b9
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Aug 10 19:21:41 2019 -0400

    Do not cast argument of g_object_ref()
    
    In calls to g_object_ref(), do not cast object using G_OBJECT(object).
    
    The macro now casts the return value to the type of the
    argument, so casting away its actual type is unhelpful.
    
    * libbalsa/mailbox_imap.c (imap_exists_cb):
    * libbalsa/rfc3156.c (libbalsa_sign_encrypt_mime_object):
    * libbalsa/send.c (libbalsa_fill_msg_queue_item_from_queu):
    * src/balsa-message.c (message_recheck_crypto_cb):
    * src/balsa-print-object-header.c (balsa_print_object_header_new_real):
    * src/folder-conf.c (create_imap_folder_dialog):
    * src/print-gtk.c (message_print):
    * src/sendmsg-window.c (sw_buffer_swap):

 ChangeLog                       | 18 ++++++++++++++++++
 libbalsa/mailbox_imap.c         |  3 +--
 libbalsa/rfc3156.c              |  3 +--
 libbalsa/send.c                 |  2 +-
 src/balsa-message.c             |  8 ++------
 src/balsa-print-object-header.c |  3 +--
 src/folder-conf.c               |  4 ++--
 src/print-gtk.c                 |  2 +-
 src/sendmsg-window.c            |  2 +-
 9 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b13c9febe..22de82972 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2019-08-10  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       In calls to g_object_ref(), do not cast object using
+       G_OBJECT(object).
+
+       The macro now casts the return value to the type of the
+       argument, so casting away its actual type is unhelpful.
+
+       * libbalsa/mailbox_imap.c (imap_exists_cb):
+       * libbalsa/rfc3156.c (libbalsa_sign_encrypt_mime_object):
+       * libbalsa/send.c (libbalsa_fill_msg_queue_item_from_queu):
+       * src/balsa-message.c (message_recheck_crypto_cb):
+       * src/balsa-print-object-header.c
+       (balsa_print_object_header_new_real):
+       * src/folder-conf.c (create_imap_folder_dialog):
+       * src/print-gtk.c (message_print):
+       * src/sendmsg-window.c (sw_buffer_swap):
+
 2019-08-09  Peter Bloomfield  <pbloomfield bellsouth net>
 
        In calls to g_object_[gs]et(), do not cast object using
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 6f1dd5525..933dcef70 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -872,8 +872,7 @@ imap_exists_idle(gpointer data)
 static void
 imap_exists_cb(ImapMboxHandle *handle, LibBalsaMailboxImap *mimap)
 {
-    g_object_ref(G_OBJECT(mimap));
-    g_idle_add(imap_exists_idle, mimap);
+    g_idle_add(imap_exists_idle, g_object_ref(mimap));
 }
 
 static void
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 81d002daf..41cd9b43b 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -306,8 +306,7 @@ libbalsa_sign_encrypt_mime_object(GMimeObject ** content,
        return FALSE;
 
     /* we want to be able to restore */
-    signed_object = *content;
-    g_object_ref(G_OBJECT(signed_object));
+    signed_object = g_object_ref(*content);
 
     if (!libbalsa_sign_mime_object(&signed_object, rfc822_signer, protocol,
                                   parent, error))
diff --git a/libbalsa/send.c b/libbalsa/send.c
index dd63de210..cb8550f84 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1754,7 +1754,7 @@ libbalsa_fill_msg_queue_item_from_queu(LibBalsaMessage  *message,
         g_mime_stream_reset(mqi->stream);
         g_object_unref(G_OBJECT(msg_stream));
 
-        g_object_ref(G_OBJECT(mqi->orig));
+        g_object_ref(mqi->orig);
         result = LIBBALSA_MESSAGE_CREATE_OK;
     }
 
diff --git a/src/balsa-message.c b/src/balsa-message.c
index ca5f998c2..b3b364626 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -3237,17 +3237,13 @@ message_recheck_crypto_cb(GtkWidget * button, BalsaMessage * bm)
     BalsaPartInfo * info;
     gboolean has_focus = bm->focus_state != BALSA_MESSAGE_FOCUS_STATE_NO;
 
-    g_return_if_fail(bm != NULL);
-
-    message = bm->message;
-    g_return_if_fail(message != NULL);
+    message = g_object_ref(bm->message);
 
     select_part(bm, NULL);
     balsa_message_clear_tree(bm);
 
-    g_object_ref(G_OBJECT(message));
     if (!libbalsa_message_body_ref(message, TRUE, TRUE)) {
-       g_object_unref(G_OBJECT(message));
+       g_object_unref(message);
         return;
     }
 
diff --git a/src/balsa-print-object-header.c b/src/balsa-print-object-header.c
index b255fe27d..68c055322 100644
--- a/src/balsa-print-object-header.c
+++ b/src/balsa-print-object-header.c
@@ -182,8 +182,7 @@ balsa_print_object_header_new_real(GList * list,
                g_error_free(err);
 
            if (f_widget) {
-               face = gtk_image_get_pixbuf(GTK_IMAGE(f_widget));
-               g_object_ref(G_OBJECT(face));
+               face = g_object_ref(gtk_image_get_pixbuf(GTK_IMAGE(f_widget)));
                gtk_widget_destroy(f_widget);
            }
        }
diff --git a/src/folder-conf.c b/src/folder-conf.c
index 236b1216c..92c76d01f 100644
--- a/src/folder-conf.c
+++ b/src/folder-conf.c
@@ -331,10 +331,10 @@ create_imap_folder_dialog(LibBalsaServer  *server,
                        libbalsa_information(LIBBALSA_INFORMATION_ERROR,
                                              _("Cannot list IMAP folders: %s"),
                                              error->message);
-                       g_clear_error(&error);
+                       g_error_free(error);
                        return NULL;
                } else {
-                       g_object_ref(G_OBJECT(*store));
+                       g_object_ref(store);
                }
        }
 
diff --git a/src/print-gtk.c b/src/print-gtk.c
index bc515d4bb..533e46604 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -742,7 +742,7 @@ message_print(LibBalsaMessage * msg, GtkWindow * parent)
     print = gtk_print_operation_new();
     g_assert(print != NULL);
 
-    g_object_ref(G_OBJECT(msg));
+    g_object_ref(msg);
 
     gtk_print_operation_set_n_pages(print, 1);
     gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 1defed754..fc8187a05 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -5923,7 +5923,7 @@ sw_buffer_swap(BalsaSendmsg * bsmsg, gboolean undo)
 #endif                          /* HAVE_GTKSPELL */
 
     sw_buffer_signals_disconnect(bsmsg);
-    g_object_ref(G_OBJECT(buffer));
+    g_object_ref(buffer);
     gtk_text_view_set_buffer(GTK_TEXT_VIEW(bsmsg->text), bsmsg->buffer2);
 #if HAVE_GTKSPELL
     if (had_spell)


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