[Xfce4-commits] <midori:master> Address missing NULL checks and dead code found by clang

Christian Dywan noreply at xfce.org
Wed Apr 17 01:18:01 CEST 2013


Updating branch refs/heads/master
         to 4d388d735da227997c1be4b33a85249e39c6a85b (commit)
       from d5b99b0d9bfd2807be4a0eee19ef7914d261a9b8 (commit)

commit 4d388d735da227997c1be4b33a85249e39c6a85b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Apr 17 01:16:24 2013 +0200

    Address missing NULL checks and dead code found by clang

 extensions/addons.c                |   14 ++++++++++----
 extensions/feed-panel/feed-atom.c  |    1 -
 extensions/feed-panel/feed-panel.c |    1 -
 extensions/feed-panel/feed-parse.c |    2 ++
 katze/katze-http-cookies.c         |    2 +-
 katze/katze-utils.c                |    4 ++--
 midori/midori-array.c              |    2 --
 midori/midori-browser.c            |    5 ++---
 midori/midori-locationaction.c     |    6 ++----
 midori/midori-platform.h           |    6 +++---
 midori/midori-view.c               |    2 +-
 panels/midori-history.c            |    1 -
 12 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/extensions/addons.c b/extensions/addons.c
index e157840..57770bc 100644
--- a/extensions/addons.c
+++ b/extensions/addons.c
@@ -929,10 +929,16 @@ js_metadata_from_file (const gchar* filename,
                 /* We don't support these, so abort here */
                 g_free (line);
                 g_io_channel_shutdown (channel, false, 0);
-                g_slist_free (*includes);
-                g_slist_free (*excludes);
-                *includes = NULL;
-                *excludes = NULL;
+                if (includes != NULL)
+                {
+                    g_slist_free (*includes);
+                    *includes = NULL;
+                }
+                if (excludes != NULL)
+                {
+                    g_slist_free (*excludes);
+                    *excludes = NULL;
+                }
                 return FALSE;
             }
              else if (includes && g_str_has_prefix (line, "// @include"))
diff --git a/extensions/feed-panel/feed-atom.c b/extensions/feed-panel/feed-atom.c
index 0cf14c3..7b4f537 100644
--- a/extensions/feed-panel/feed-atom.c
+++ b/extensions/feed-panel/feed-atom.c
@@ -95,7 +95,6 @@ atom_get_link (KatzeItem* item,
     gboolean newishtml;
     gboolean newlink;
 
-    newlink = FALSE;
     oldtype = (gchar*)katze_item_get_meta_string (item, "feedpanel:linktype");
     oldrel = (gchar*)katze_item_get_meta_string (item, "feedpanel:linkrel");
 
diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c
index a34a212..8a08107 100644
--- a/extensions/feed-panel/feed-panel.c
+++ b/extensions/feed-panel/feed-panel.c
@@ -705,7 +705,6 @@ feed_panel_get_toolbar (MidoriViewable* viewable)
 static void
 feed_panel_finalize (GObject* object)
 {
-    FeedPanel* panel = FEED_PANEL (object);
 }
 
 static void
diff --git a/extensions/feed-panel/feed-parse.c b/extensions/feed-panel/feed-parse.c
index 9963d0e..c19f5c0 100644
--- a/extensions/feed-panel/feed-parse.c
+++ b/extensions/feed-panel/feed-parse.c
@@ -219,6 +219,8 @@ feed_parse_doc (xmlDocPtr   doc,
                     feed_parse_node (fparser);
             }
         }
+        else
+            isvalid = FALSE;
 
         fparser->error = NULL;
         fparser->doc = NULL;
diff --git a/katze/katze-http-cookies.c b/katze/katze-http-cookies.c
index ac77130..5a2caad 100644
--- a/katze/katze-http-cookies.c
+++ b/katze/katze-http-cookies.c
@@ -267,7 +267,7 @@ katze_http_cookies_jar_changed_cb (SoupCookieJar*    jar,
     if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies"))
         http_cookies->counter++;
 
-    if (!http_cookies->timeout && (old_cookie || new_cookie->expires))
+    if (!http_cookies->timeout && (old_cookie || (new_cookie && new_cookie->expires)))
         http_cookies->timeout = midori_timeout_add_seconds (
             5, (GSourceFunc)katze_http_cookies_update_jar, http_cookies, NULL);
 }
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index fa4b767..39f65e8 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -1230,10 +1230,10 @@ katze_uri_entry_changed_cb (GtkWidget* entry,
         valid = midori_uri_is_ip_address (uri);
 
     #if GTK_CHECK_VERSION (3, 2, 0)
-    g_object_set_data (G_OBJECT (entry), "invalid", GINT_TO_POINTER (*uri && !valid));
+    g_object_set_data (G_OBJECT (entry), "invalid", GINT_TO_POINTER (uri && *uri && !valid));
     gtk_widget_queue_draw (entry);
     #else
-    if (*uri && !valid)
+    if (uri && *uri && !valid)
     {
         GdkColor bg_color = { 0 };
         GdkColor fg_color = { 0 };
diff --git a/midori/midori-array.c b/midori/midori-array.c
index 4911c89..65d12cc 100644
--- a/midori/midori-array.c
+++ b/midori/midori-array.c
@@ -210,8 +210,6 @@ katze_array_from_xmlDocPtr (KatzeArray* array,
     xmlNodePtr cur;
     KatzeItem* item;
 
-    cur = xmlDocGetRootElement (doc);
-
     if ((cur = xmlDocGetRootElement (doc)) == NULL)
     {
         /* Empty document */
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 4187f76..4ad67bf 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -856,7 +856,7 @@ midori_bookmark_folder_button_new (KatzeArray* array,
     db = g_object_get_data (G_OBJECT (array), "db");
     g_return_val_if_fail (db != NULL, NULL);
     n = 1;
-    result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
+    if ((result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL)) == SQLITE_OK)
     while ((result = sqlite3_step (statement)) == SQLITE_ROW)
     {
         const unsigned char* name = sqlite3_column_text (statement, 0);
@@ -6660,7 +6660,7 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
     const char* token_search = g_intern_static_string ("Search");
     const char* token_dontcare = g_intern_static_string ("Dontcare");
     const char* token_current = token_dontcare;
-    const char* token_last = token_dontcare;
+    const char* token_last;
 
     gtk_container_foreach (GTK_CONTAINER (browser->navigationbar),
         (GtkCallback)gtk_widget_destroy, NULL);
@@ -6707,7 +6707,6 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
 
                 toolitem = gtk_action_create_tool_item (GTK_ACTION (paned_action));
                 token_current = token_dontcare;
-                token_last = token_dontcare;
             }
             else if (token_current == token_dontcare && token_last != token_dontcare)
             {
diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index 290c29b..d51e197 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -478,7 +478,7 @@ midori_location_action_popup_position (MidoriLocationAction* action,
     GtkWidget* popup = action->popup;
     GtkWidget* widget = action->entry;
     GdkWindow* window = gtk_widget_get_window (widget);
-    gint wx, wy, x_border, y_border, items;
+    gint wx, wy, items;
     GtkRequisition menu_req;
     GtkRequisition widget_req;
     GdkScreen* screen;
@@ -504,8 +504,6 @@ midori_location_action_popup_position (MidoriLocationAction* action,
     wx += alloc.x;
     wy += alloc.y + (alloc.height - widget_req.height) / 2;
     #endif
-    /* _gtk_entry_get_borders (GTK_ENTRY (widget), &x_border, &y_border); */
-    x_border = y_border = 0;
 
     gtk_tree_view_column_cell_get_size (
         gtk_tree_view_get_column (GTK_TREE_VIEW (action->treeview), 0),
@@ -526,7 +524,7 @@ midori_location_action_popup_position (MidoriLocationAction* action,
         items = MIN (matches, ((monitor.y + wy) / height) - 1);
     else
         items = MIN (matches, ((toplevel_height - wy) / height) - 1);
-    width = MIN (alloc.width, monitor.width) - 2 * x_border;
+    width = MIN (alloc.width, monitor.width);
 
     gtk_tree_view_columns_autosize (GTK_TREE_VIEW (action->treeview));
     #if GTK_CHECK_VERSION (3, 0, 0)
diff --git a/midori/midori-platform.h b/midori/midori-platform.h
index dfce79f..cff300d 100644
--- a/midori/midori-platform.h
+++ b/midori/midori-platform.h
@@ -25,11 +25,11 @@
 
 #ifdef GDK_WINDOWING_QUARTZ
     #define MIDORI_EVENT_CONTEXT_MENU(evt) \
-        ((evt->button == 3) \
-        || (evt->button == 1 && (evt->state & GDK_CONTROL_MASK)))
+        ((evt && evt->button == 3) \
+        || (evt && evt->button == 1 && (evt->state & GDK_CONTROL_MASK)))
 #else
     #define MIDORI_EVENT_CONTEXT_MENU(evt) \
-        (evt->button == 3)
+        (evt && evt->button == 3)
 #endif
 
 #define MIDORI_EVENT_NEW_TAB(evt) \
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 1a44ed3..ad04e88 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -2924,7 +2924,7 @@ midori_view_populate_popup (MidoriView* view,
         gtk_menu_shell_append (menu_shell, menuitem);
 
         if (webkit_web_view_get_focused_frame (web_view) != webkit_web_view_get_main_frame (web_view))
-            menuitem = midori_view_insert_menu_item (menu_shell, -1,
+            midori_view_insert_menu_item (menu_shell, -1,
                 _("Open _Frame in New Tab"), NULL,
                 G_CALLBACK (midori_web_view_open_frame_in_new_tab_cb), widget);
 
diff --git a/panels/midori-history.c b/panels/midori-history.c
index e3921f8..e262d07 100644
--- a/panels/midori-history.c
+++ b/panels/midori-history.c
@@ -279,7 +279,6 @@ midori_history_read_from_db (MidoriHistory* history,
         result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
         filterstr = g_strdup_printf ("%%%s%%", filter);
         sqlite3_bind_text (statement, 1, filterstr, -1, g_free);
-        req_day = -1;
     }
     else if (req_day == 0)
     {


More information about the Xfce4-commits mailing list