[balsa/wip/gtk4: 191/351] g_strdup(NULL) returns NULL



commit 87a24efc39d3d7d01b3d4a60b2dc4875896573f9
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Feb 26 14:06:57 2018 -0500

    g_strdup(NULL) returns NULL

 libbalsa/address-book-rubrica.c |   14 ++++++++------
 libbalsa/misc.c                 |    4 +---
 libbalsa/rfc2445.c              |    2 +-
 libbalsa/server.c               |    4 +---
 src/filter-edit-dialog.c        |    7 +++----
 5 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/libbalsa/address-book-rubrica.c b/libbalsa/address-book-rubrica.c
index 69242c8..29205f6 100644
--- a/libbalsa/address-book-rubrica.c
+++ b/libbalsa/address-book-rubrica.c
@@ -735,8 +735,10 @@ static gchar *
 xml_node_get_text(xmlNodePtr node)
 {
     g_return_val_if_fail(node != NULL, NULL);
-    if ((node = node->children) && node->type == XML_TEXT_NODE)
+
+    if ((node = node->children) != NULL && node->type == XML_TEXT_NODE)
        return g_strdup((const gchar *) node->content);
+
     return NULL;
 }
 
@@ -747,14 +749,14 @@ xml_node_get_attr(xmlNodePtr node, const xmlChar * attname)
     xmlAttrPtr props;
 
     g_return_val_if_fail(node != NULL, NULL);
+
     props = node->properties;
-    while (props) {
+    while (props != NULL) {
        if (props->type == XML_ATTRIBUTE_NODE
            && !xmlStrcmp(props->name, attname) && props->children
-           && props->children->type == XML_TEXT_NODE)
-           return props->children->
-               content ? g_strdup((const gchar *) props->children->
-                                  content) : NULL;
+           && props->children->type == XML_TEXT_NODE) {
+           return g_strdup((const gchar *) props->children->content);
+        }
        props = props->next;
     }
 
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index 448e112..b3252b5 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -47,9 +47,7 @@
 static const gchar *libbalsa_get_codeset_name(const gchar *txt, 
                                              LibBalsaCodeset Codeset);
 #ifndef HAVE_STRUCT_UTSNAME_DOMAINNAME
-static int getdnsdomainname(char *s, size_t l);
-
-static int 
+static int
 getdnsdomainname (char *s, size_t l)
 {
   FILE *f;
diff --git a/libbalsa/rfc2445.c b/libbalsa/rfc2445.c
index e2af541..61f99c0 100644
--- a/libbalsa/rfc2445.c
+++ b/libbalsa/rfc2445.c
@@ -351,7 +351,7 @@ libbalsa_vcal_new_from_body(LibBalsaMessageBody * body)
     in_embedded = FALSE;
     for (k = 0; lines[k]; k++) {
        if (!event) {
-            if (!method && !g_ascii_strncasecmp("METHOD:", lines[k], 7))
+            if (method == NULL && g_str_has_prefix(lines[k], "METHOD:"))
                 method = g_strdup(lines[k] + 7);
            if (!g_ascii_strcasecmp("BEGIN:VEVENT", lines[k]))
                event = libbalsa_vevent_new();
diff --git a/libbalsa/server.c b/libbalsa/server.c
index ebf49d7..acea0dd 100644
--- a/libbalsa/server.c
+++ b/libbalsa/server.c
@@ -225,9 +225,7 @@ libbalsa_server_set_password(LibBalsaServer * server,
     g_return_if_fail(LIBBALSA_IS_SERVER(server));
 
     libbalsa_free_password(server->passwd);
-    if(passwd && passwd[0])
-       server->passwd = g_strdup(passwd);
-    else server->passwd = NULL;
+    server->passwd = g_strdup(passwd);
 }
 
 void
diff --git a/src/filter-edit-dialog.c b/src/filter-edit-dialog.c
index 68a4045..2ec9ebe 100644
--- a/src/filter-edit-dialog.c
+++ b/src/filter-edit-dialog.c
@@ -615,8 +615,8 @@ filters_edit_dialog(GtkWindow * parent)
        
        cpfil->name=g_strdup(fil->name);
        cpfil->flags=fil->flags;
-       if (fil->sound) cpfil->sound=g_strdup(fil->sound);
-       if (fil->popup_text) cpfil->popup_text=g_strdup(fil->popup_text);
+       cpfil->sound=g_strdup(fil->sound);
+       cpfil->popup_text=g_strdup(fil->popup_text);
        /* FIXME: cpfil->conditions_op=fil->conditions_op; */
        cpfil->flags=fil->flags;
 
@@ -642,8 +642,7 @@ filters_edit_dialog(GtkWindow * parent)
        fe_collect_user_headers(fil->condition);
 
        cpfil->action=fil->action;
-       if (fil->action_string)
-            cpfil->action_string=g_strdup(fil->action_string);
+        cpfil->action_string=g_strdup(fil->action_string);
 
         gtk_list_store_append(GTK_LIST_STORE(model), &iter);
         gtk_list_store_set(GTK_LIST_STORE(model), &iter,


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