[gimp] Bug 729326 - Errors found using a static code analysis program cppcheck



commit 5ec413a5e8d256b7e2611d02309797efb998cfea
Author: Rickard <rick i7>
Date:   Wed Apr 30 00:36:00 2014 +0200

    Bug 729326 - Errors found using a static code analysis program cppcheck
    
    Fixed some memory and file leaks. And removed some code and variables
    that are not used.

 app/actions/dynamics-editor-actions.c  |   10 ----------
 app/core/gimpdrawable-bucket-fill.c    |    2 +-
 app/menus/plug-in-menus.c              |   11 +++++++----
 app/vectors/gimpvectors.c              |    2 +-
 app/widgets/gimplanguagestore-parser.c |    4 +++-
 app/widgets/gimppdbdialog.c            |    1 -
 libgimpbase/gimpreloc.c                |    2 +-
 libgimpwidgets/test-eevl.c             |   13 ++++++-------
 modules/controller-dx-dinput.c         |    7 +++----
 modules/gimpinputdevicestore-dx.c      |    2 ++
 10 files changed, 24 insertions(+), 30 deletions(-)
---
diff --git a/app/actions/dynamics-editor-actions.c b/app/actions/dynamics-editor-actions.c
index bacab34..f0bf14d 100644
--- a/app/actions/dynamics-editor-actions.c
+++ b/app/actions/dynamics-editor-actions.c
@@ -73,18 +73,8 @@ dynamics_editor_actions_update (GimpActionGroup *group,
                                 gpointer         user_data)
 {
   GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data);
-  GimpData       *data;
-  gboolean        editable    = FALSE;
   gboolean        edit_active = FALSE;
 
-  data = data_editor->data;
-
-  if (data)
-    {
-      if (data_editor->data_editable)
-        editable = TRUE;
-    }
-
   edit_active = gimp_data_editor_get_edit_active (data_editor);
 
 #define SET_SENSITIVE(action,condition) \
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index caebaac..13c7ba9 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -75,7 +75,7 @@ gimp_drawable_bucket_fill (GimpDrawable         *drawable,
                            gdouble               y,
                            GError              **error)
 {
-  GimpRGB      color;
+  GimpRGB      color   = { 0, };
   GimpPattern *pattern = NULL;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c
index 289b088..1091e1c 100644
--- a/app/menus/plug-in-menus.c
+++ b/app/menus/plug-in-menus.c
@@ -495,12 +495,15 @@ plug_in_menus_build_path (GimpUIManager *manager,
       gchar *menu_item_name;
 
       menu_item_name = strrchr (parent_menu_path, '/');
-      *menu_item_name++ = '\0';
 
       if (menu_item_name)
-        parent_action_path = plug_in_menus_build_path (manager,
-                                                       ui_path, merge_id,
-                                                       parent_menu_path, TRUE);
+        {
+          *menu_item_name++ = '\0';
+
+          parent_action_path = plug_in_menus_build_path (manager,
+                                                         ui_path, merge_id,
+                                                         parent_menu_path, TRUE);
+        }
 
       if (parent_action_path)
         {
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index cd1812c..f588093 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -1044,7 +1044,7 @@ gimp_vectors_bounds (GimpVectors *vectors,
 
       vectors->bounds_empty = TRUE;
       vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
-      vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
+      vectors->bounds_y1 = vectors->bounds_y2 = 0.0;
 
       for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
            stroke;
diff --git a/app/widgets/gimplanguagestore-parser.c b/app/widgets/gimplanguagestore-parser.c
index 7d2fcf8..e756468 100644
--- a/app/widgets/gimplanguagestore-parser.c
+++ b/app/widgets/gimplanguagestore-parser.c
@@ -92,7 +92,7 @@ void
 gimp_language_store_parser_init (void)
 {
   GHashTable     *base_lang_list;
-  gchar          *current_env    = g_strdup (g_getenv ("LANGUAGE"));
+  gchar          *current_env;
   GDir           *locales_dir;
   GHashTableIter  lang_iter;
   gpointer        key;
@@ -103,6 +103,8 @@ gimp_language_store_parser_init (void)
       return;
     }
 
+  current_env = g_strdup (g_getenv ("LANGUAGE"));
+
   l10n_lang_list = g_hash_table_new_full (g_str_hash, g_str_equal,
                                           (GDestroyNotify) g_free,
                                           (GDestroyNotify) g_free);
diff --git a/app/widgets/gimppdbdialog.c b/app/widgets/gimppdbdialog.c
index c7c93cf..dde48ce 100644
--- a/app/widgets/gimppdbdialog.c
+++ b/app/widgets/gimppdbdialog.c
@@ -119,7 +119,6 @@ gimp_pdb_dialog_class_init (GimpPdbDialogClass *klass)
   object_class->constructed  = gimp_pdb_dialog_constructed;
   object_class->dispose      = gimp_pdb_dialog_dispose;
   object_class->set_property = gimp_pdb_dialog_set_property;
-  object_class->set_property = gimp_pdb_dialog_set_property;
 
   dialog_class->response     = gimp_pdb_dialog_response;
 
diff --git a/libgimpbase/gimpreloc.c b/libgimpbase/gimpreloc.c
index 763f3cc..c00d64c 100644
--- a/libgimpbase/gimpreloc.c
+++ b/libgimpbase/gimpreloc.c
@@ -137,7 +137,7 @@ _br_find_exe (GimpBinrelocInitError *error)
 
         /* Get rid of newline character. */
         buf_size = strlen (line);
-        if (buf_size <= 0) {
+        if (buf_size == 0) {
                 /* Huh? An empty string? */
                 fclose (f);
                 g_free (line);
diff --git a/libgimpwidgets/test-eevl.c b/libgimpwidgets/test-eevl.c
index a41eacc..8addac8 100644
--- a/libgimpwidgets/test-eevl.c
+++ b/libgimpwidgets/test-eevl.c
@@ -114,18 +114,17 @@ main(void)
     {
       const gchar     *test           = cases[i].string;
       GimpEevlQuantity should         = cases[i].result;
-      gboolean         success        = FALSE;
       GimpEevlQuantity result         = { 0, -1 };
       gboolean         should_succeed = cases[i].should_succeed;
       GError          *error          = NULL;
       const gchar     *error_pos      = 0;
 
-      success = gimp_eevl_evaluate (test,
-                                    test_units,
-                                    &result,
-                                    NULL,
-                                    &error_pos,
-                                    &error);
+      gimp_eevl_evaluate (test,
+                          test_units,
+                          &result,
+                          NULL,
+                          &error_pos,
+                          &error);
 
       g_print ("%s = %lg (%d): ", test, result.value, result.dimension);
       if (error || error_pos)
diff --git a/modules/controller-dx-dinput.c b/modules/controller-dx-dinput.c
index a6bdb04..e192edb 100644
--- a/modules/controller-dx-dinput.c
+++ b/modules/controller-dx-dinput.c
@@ -648,16 +648,15 @@ dx_dinput_event_dispatch (GSource     *source,
   GimpController                  *controller = &input->parent_instance;
   const DIDATAFORMAT * const       format = input->format;
   const DIOBJECTDATAFORMAT        *rgodf = format->rgodf;
-  HRESULT                          hresult;
   guchar                          *data;
   gint                             i;
   GimpControllerEvent              cevent = { 0, };
 
   data = g_alloca (format->dwDataSize);
 
-  if (FAILED ((hresult = IDirectInputDevice8_GetDeviceState (input->didevice8,
-                                                             format->dwDataSize,
-                                                             data))))
+  if (FAILED (IDirectInputDevice8_GetDeviceState (input->didevice8,
+                                                  format->dwDataSize,
+                                                  data)))
     {
       return TRUE;
     }
diff --git a/modules/gimpinputdevicestore-dx.c b/modules/gimpinputdevicestore-dx.c
index 2917f01..9269258 100644
--- a/modules/gimpinputdevicestore-dx.c
+++ b/modules/gimpinputdevicestore-dx.c
@@ -143,6 +143,7 @@ aux_window_filter (GdkXEvent *xevent,
                    GdkEvent  *event,
                    gpointer   data)
 {
+#if 0
   GimpInputDeviceStore *store = (GimpInputDeviceStore *) data;
   const MSG *msg = (MSG *) xevent;
 
@@ -150,6 +151,7 @@ aux_window_filter (GdkXEvent *xevent,
   switch (msg->message)
     {
     }
+#endif
 
   return GDK_FILTER_REMOVE;
 }


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