[gnome-builder] fix some static analysis warnings



commit a135399c91f3105e6f4a2b599589b172014079d1
Author: Christian Hergert <christian hergert me>
Date:   Fri May 8 10:55:49 2015 -0700

    fix some static analysis warnings
    
    Mostly minor fixes such as unused variables

 contrib/egg/egg-state-machine.c              |    2 --
 libide/autotools/ide-makecache.c             |    2 --
 libide/c/ide-c-indenter.c                    |   13 ++-----------
 libide/clang/ide-clang-completion-provider.c |    2 +-
 libide/git/ide-git-vcs.c                     |    3 ++-
 libide/ide-source-snippet-parser.c           |    1 -
 src/editor/gb-editor-map-bin.c               |    1 -
 src/project-tree/gb-project-tree-builder.c   |    4 ----
 src/vim/gb-vim.c                             |   11 ++++++-----
 src/workbench/gb-workbench.c                 |    8 ++++++--
 tools/ide-list-files.c                       |    2 --
 11 files changed, 17 insertions(+), 32 deletions(-)
---
diff --git a/contrib/egg/egg-state-machine.c b/contrib/egg/egg-state-machine.c
index bb3e8f5..819fc38 100644
--- a/contrib/egg/egg-state-machine.c
+++ b/contrib/egg/egg-state-machine.c
@@ -217,7 +217,6 @@ egg_state_machine_transition (EggStateMachine  *self,
 {
   EggStateMachinePrivate *priv = egg_state_machine_get_instance_private (self);
   g_autofree gchar *old_state = NULL;
-  g_autofree gchar *new_state_copy = NULL;
   EggStateTransition ret = EGG_STATE_TRANSITION_IGNORED;
   g_autoptr(GError) local_error = NULL;
   gsize sequence;
@@ -232,7 +231,6 @@ egg_state_machine_transition (EggStateMachine  *self,
   /* Be careful with reentrancy. */
 
   old_state = g_strdup (priv->state);
-  new_state_copy = g_strdup (new_state);
   sequence = priv->sequence;
 
   g_signal_emit (self, gSignals [TRANSITION], 0, old_state, new_state, &local_error, &ret);
diff --git a/libide/autotools/ide-makecache.c b/libide/autotools/ide-makecache.c
index 6e57dad..16fee52 100644
--- a/libide/autotools/ide-makecache.c
+++ b/libide/autotools/ide-makecache.c
@@ -1365,7 +1365,6 @@ ide_makecache__get_targets_cb (GObject      *object,
   GError *error = NULL;
   GFile *file;
   FileFlagsLookup *lookup;
-  g_autofree gchar *path = NULL;
   g_autofree gchar *relative_path = NULL;
   gchar **argv;
 
@@ -1391,7 +1390,6 @@ ide_makecache__get_targets_cb (GObject      *object,
     }
 
   file = g_task_get_task_data (task);
-  path = g_file_get_path (file);
   relative_path = ide_makecache_get_relative_path (self, file);
 
   g_mutex_lock (&self->mutex);
diff --git a/libide/c/ide-c-indenter.c b/libide/c/ide-c-indenter.c
index b368a4d..f9a3b38 100644
--- a/libide/c/ide-c-indenter.c
+++ b/libide/c/ide-c-indenter.c
@@ -78,17 +78,15 @@ build_indent (IdeCIndenter *c,
 {
   GtkSourceView *view = (GtkSourceView *)c->view;
   guint tab_width = gtk_source_view_get_tab_width (view);
-  gint indent_width = gtk_source_view_get_indent_width (view);
   GtkTextIter iter;
   gunichar ch;
   guint i;
 
+  g_assert (tab_width > 0);
+
   if (!line_offset)
     return;
 
-  if (indent_width == -1)
-    indent_width = tab_width;
-
   gtk_text_buffer_get_iter_at_line (gtk_text_iter_get_buffer (matching_line),
                                     &iter,
                                     gtk_text_iter_get_line (matching_line));
@@ -559,11 +557,6 @@ c_indenter_indent (IdeCIndenter *c,
       GOTO (cleanup);
 
   /*
-   * Get our last non \n character entered.
-   */
-  ch = gtk_text_iter_get_char (iter);
-
-  /*
    * If we are in a c89 multi-line comment, try to match the previous comment
    * line. Function will leave iter at original position unless it matched.
    * If so, it will be at the beginning of the comment.
@@ -1008,8 +1001,6 @@ format_parameters (GtkTextIter *begin,
         max_type = MAX (max_type, strlen (p->type));
     }
 
-  str = g_string_new (NULL);
-
   ITER_INIT_LINE_START (&line_start, begin);
 
   gtk_text_iter_assign (&first_char, begin);
diff --git a/libide/clang/ide-clang-completion-provider.c b/libide/clang/ide-clang-completion-provider.c
index 8d8e6e6..d9cd3a8 100644
--- a/libide/clang/ide-clang-completion-provider.c
+++ b/libide/clang/ide-clang-completion-provider.c
@@ -220,7 +220,7 @@ ide_clang_completion_provider_complete_cb (GObject      *object,
       goto failure;
     }
 
-  g_clear_pointer (&self->last_results, g_ptr_array_free);
+  g_ptr_array_free (self->last_results, TRUE);
   self->last_results = g_ptr_array_ref (ar);
 
   gtk_source_completion_context_get_iter (state->context, &iter);
diff --git a/libide/git/ide-git-vcs.c b/libide/git/ide-git-vcs.c
index dddfe86..b9448b6 100644
--- a/libide/git/ide-git-vcs.c
+++ b/libide/git/ide-git-vcs.c
@@ -519,6 +519,7 @@ ide_git_vcs_reload__build_tree_cb (GObject      *object,
    */
   if (!self->loaded_files)
     {
+#if 0
       IdeContext *context;
       IdeProject *project;
       IdeProjectItem *root;
@@ -534,7 +535,7 @@ ide_git_vcs_reload__build_tree_cb (GObject      *object,
           ide_project_item_append (root, IDE_PROJECT_ITEM (files));
           ide_project_writer_unlock (project);
         }
-
+#endif
       self->loaded_files = TRUE;
     }
 
diff --git a/libide/ide-source-snippet-parser.c b/libide/ide-source-snippet-parser.c
index c0c849f..fde15b7 100644
--- a/libide/ide-source-snippet-parser.c
+++ b/libide/ide-source-snippet-parser.c
@@ -355,7 +355,6 @@ parse_dollar:
     {
       if (*line == '$')
         {
-          dollar = line;
           goto parse_dollar;
         }
       else
diff --git a/src/editor/gb-editor-map-bin.c b/src/editor/gb-editor-map-bin.c
index c3009fc..bfbf7ff 100644
--- a/src/editor/gb-editor-map-bin.c
+++ b/src/editor/gb-editor-map-bin.c
@@ -166,7 +166,6 @@ gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
 
   widget_class->size_allocate = gb_editor_map_bin_size_allocate;
 
-  container_class = GTK_CONTAINER_CLASS (klass);
   container_class->add = gb_editor_map_bin_add;
   container_class->remove = gb_editor_map_bin_remove;
 
diff --git a/src/project-tree/gb-project-tree-builder.c b/src/project-tree/gb-project-tree-builder.c
index faca609..53d3da1 100644
--- a/src/project-tree/gb-project-tree-builder.c
+++ b/src/project-tree/gb-project-tree-builder.c
@@ -77,8 +77,6 @@ build_project (GbProjectTreeBuilder *self,
 
   if (children)
     {
-      iter = g_sequence_get_begin_iter (children);
-
       for (iter = g_sequence_get_begin_iter (children);
            !g_sequence_iter_is_end (iter);
            iter = g_sequence_iter_next (iter))
@@ -166,8 +164,6 @@ build_files (GbProjectTreeBuilder *self,
                        (GCompareDataFunc) sort_files,
                        GINT_TO_POINTER (directories_first));
 
-      iter = g_sequence_get_begin_iter (children);
-
       for (iter = g_sequence_get_begin_iter (children);
            !g_sequence_iter_is_end (iter);
            iter = g_sequence_iter_next (iter))
diff --git a/src/vim/gb-vim.c b/src/vim/gb-vim.c
index 0ce1955..eee77e2 100644
--- a/src/vim/gb-vim.c
+++ b/src/vim/gb-vim.c
@@ -1130,12 +1130,10 @@ gb_vim_complete_edit_files (GtkSourceView *source_view,
   if (parent != NULL)
     {
       g_autoptr(GFileEnumerator) fe = NULL;
-      g_autofree gchar *parent_path = NULL;
       g_autofree gchar *relpath = NULL;
       GFileInfo *descendent;
       const gchar *slash;
 
-      parent_path = g_file_get_path (parent);
       relpath = g_file_get_relative_path (workdir, parent);
 
       if (relpath && g_str_has_prefix (relpath, "./"))
@@ -1145,7 +1143,12 @@ gb_vim_complete_edit_files (GtkSourceView *source_view,
           g_free (tmp);
         }
 
-      IDE_TRACE_MSG ("parent_path: %s", parent_path);
+#ifdef IDE_ENABLE_TRACE
+      {
+        g_autofree gchar *parent_path = g_file_get_path (parent);
+        IDE_TRACE_MSG ("parent_path: %s", parent_path);
+      }
+#endif
 
       if ((slash = strrchr (prefix, G_DIR_SEPARATOR)))
         prefix = slash + 1;
@@ -1220,8 +1223,6 @@ gb_vim_complete_colorscheme (const gchar *line,
   manager = gtk_source_style_scheme_manager_get_default ();
   scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
 
-  tmp = strchr (line, ' ');
-
   for (tmp = strchr (line, ' ');
        tmp && *tmp && g_unichar_isspace (g_utf8_get_char (tmp));
        tmp = g_utf8_next_char (tmp))
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 64b4f61..337bd4c 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -758,9 +758,9 @@ gb_workbench__builder_build_cb (GObject      *object,
                                 gpointer      user_data)
 {
   g_autoptr(GbWorkbench) self = user_data;
-  g_autoptr(IdeBuildResult) build_result = NULL;
   g_autoptr(GError) error = NULL;
   IdeBuilder *builder = (IdeBuilder *)object;
+  IdeBuildResult *build_result;
 
   g_assert (IDE_IS_BUILDER (builder));
   g_assert (GB_IS_WORKBENCH (self));
@@ -783,6 +783,8 @@ gb_workbench__builder_build_cb (GObject      *object,
       g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
       gtk_window_present (GTK_WINDOW (dialog));
     }
+
+  g_clear_object (&build_result);
 }
 
 void
@@ -861,13 +863,15 @@ gb_workbench_add_temporary_buffer (GbWorkbench *self)
 {
   IdeContext *context;
   IdeBufferManager *buffer_manager;
-  g_autoptr(IdeBuffer) buffer = NULL;
+  IdeBuffer *buffer;
 
   g_return_if_fail (GB_IS_WORKBENCH (self));
 
   context = gb_workbench_get_context (self);
   buffer_manager = ide_context_get_buffer_manager (context);
   buffer = ide_buffer_manager_create_buffer (buffer_manager);
+
+  g_clear_object (&buffer);
 }
 
 gboolean
diff --git a/tools/ide-list-files.c b/tools/ide-list-files.c
index 52ed55d..027e07a 100644
--- a/tools/ide-list-files.c
+++ b/tools/ide-list-files.c
@@ -69,8 +69,6 @@ walk_tree (IdeProjectItem *item,
 
   if (children)
     {
-      iter = g_sequence_get_begin_iter (children);
-
       for (iter = g_sequence_get_begin_iter (children);
            !g_sequence_iter_is_end (iter);
            iter = g_sequence_iter_next (iter))


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