[balsa/wip/gmime3: 21/197] Add assertions for clang-static-analyzer



commit a6751deedc64cdd9c1fb21f2a54ccb23451eaae6
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri Jun 30 13:24:01 2017 -0400

    Add assertions for clang-static-analyzer
    
    Add assertions to remove some clang-static-analyzer false positives
    
        * libbalsa/imap-server.c (lb_imap_server_info_free): assert that
        info is non-NULL.
        * libbalsa/mailbox_imap.c (imap_expunge_cb): assert that
        msg_info is non-NULL;
        (get_struct_from_cache): assert that message->headers is
        non-NULL.
        * libbalsa/mailbox_local.c (libbalsa_mailbox_local_set_path):
        assert that klass is non-NULL.

 ChangeLog                |   14 ++++++++++++++
 libbalsa/imap-server.c   |    2 ++
 libbalsa/mailbox_imap.c  |    3 +++
 libbalsa/mailbox_local.c |    6 ++++--
 4 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ce4c446..1405d6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2017-06-30  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Add assertions to remove some clang-static-analyzer false
+       positives
+
+       * libbalsa/imap-server.c (lb_imap_server_info_free): assert that
+       info is non-NULL.
+       * libbalsa/mailbox_imap.c (imap_expunge_cb): assert that
+       msg_info is non-NULL;
+       (get_struct_from_cache): assert that message->headers is
+       non-NULL.
+       * libbalsa/mailbox_local.c (libbalsa_mailbox_local_set_path):
+       assert that klass is non-NULL.
+
 2017-06-28  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Assert that a child widget is non-NULL
diff --git a/libbalsa/imap-server.c b/libbalsa/imap-server.c
index 6bb83a8..4c072cb 100644
--- a/libbalsa/imap-server.c
+++ b/libbalsa/imap-server.c
@@ -349,6 +349,8 @@ lb_imap_server_info_new(LibBalsaServer *server)
 static void
 lb_imap_server_info_free(struct handle_info *info)
 {
+    g_assert(info != NULL);
+
     imap_handle_force_disconnect(info->handle);
     g_object_unref(info->handle);
     g_free(info);
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 957ce88..0ec27f6 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -943,6 +943,8 @@ imap_expunge_cb(ImapMboxHandle *handle, unsigned seqno,
     for (i = seqno - 1; i < mimap->messages_info->len; i++) {
        struct message_info *msg_info =
            &g_array_index(mimap->messages_info, struct message_info, i);
+
+        g_assert(msg_info != NULL);
        if (msg_info->message)
            msg_info->message->msgno = i + 1;
     }
@@ -2206,6 +2208,7 @@ get_struct_from_cache(LibBalsaMailbox *mailbox, LibBalsaMessage *message,
                                             message->mime_msg);
     }
     if(flags & LB_FETCH_RFC822_HEADERS) {
+        g_assert(message->headers != NULL);
         message->headers->user_hdrs = 
             libbalsa_message_user_hdrs_from_gmime(message->mime_msg);
         message->has_all_headers = 1;
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 1894087..4f6d47f 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -234,12 +234,14 @@ libbalsa_mailbox_local_set_path(LibBalsaMailboxLocal * mailbox,
                                 const gchar * path, gboolean create)
 {
     int i;
-    LibBalsaMailboxLocalClass *klass =
-        LIBBALSA_MAILBOX_LOCAL_GET_CLASS(mailbox);
+    LibBalsaMailboxLocalClass *klass;
 
     g_return_val_if_fail(LIBBALSA_IS_MAILBOX_LOCAL(mailbox), -1);
     g_return_val_if_fail(path != NULL, -1);
 
+    klass = LIBBALSA_MAILBOX_LOCAL_GET_CLASS(mailbox);
+    g_assert(klass != NULL);
+
     if (LIBBALSA_MAILBOX(mailbox)->url != NULL) {
         const gchar *cur_path = libbalsa_mailbox_local_get_path(mailbox);
         if (strcmp(path, cur_path) == 0)


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