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.
This commit is contained in:
Rickard 2014-04-30 00:36:00 +02:00 committed by Michael Natterer
parent 26738b9ff3
commit 5ec413a5e8
10 changed files with 24 additions and 30 deletions

View File

@ -73,18 +73,8 @@ dynamics_editor_actions_update (GimpActionGroup *group,
gpointer user_data) gpointer user_data)
{ {
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data);
GimpData *data;
gboolean editable = FALSE;
gboolean edit_active = 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); edit_active = gimp_data_editor_get_edit_active (data_editor);
#define SET_SENSITIVE(action,condition) \ #define SET_SENSITIVE(action,condition) \

View File

@ -75,7 +75,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
gdouble y, gdouble y,
GError **error) GError **error)
{ {
GimpRGB color; GimpRGB color = { 0, };
GimpPattern *pattern = NULL; GimpPattern *pattern = NULL;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);

View File

@ -495,12 +495,15 @@ plug_in_menus_build_path (GimpUIManager *manager,
gchar *menu_item_name; gchar *menu_item_name;
menu_item_name = strrchr (parent_menu_path, '/'); menu_item_name = strrchr (parent_menu_path, '/');
*menu_item_name++ = '\0';
if (menu_item_name) if (menu_item_name)
{
*menu_item_name++ = '\0';
parent_action_path = plug_in_menus_build_path (manager, parent_action_path = plug_in_menus_build_path (manager,
ui_path, merge_id, ui_path, merge_id,
parent_menu_path, TRUE); parent_menu_path, TRUE);
}
if (parent_action_path) if (parent_action_path)
{ {

View File

@ -1044,7 +1044,7 @@ gimp_vectors_bounds (GimpVectors *vectors,
vectors->bounds_empty = TRUE; vectors->bounds_empty = TRUE;
vectors->bounds_x1 = vectors->bounds_x2 = 0.0; 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); for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
stroke; stroke;

View File

@ -92,7 +92,7 @@ void
gimp_language_store_parser_init (void) gimp_language_store_parser_init (void)
{ {
GHashTable *base_lang_list; GHashTable *base_lang_list;
gchar *current_env = g_strdup (g_getenv ("LANGUAGE")); gchar *current_env;
GDir *locales_dir; GDir *locales_dir;
GHashTableIter lang_iter; GHashTableIter lang_iter;
gpointer key; gpointer key;
@ -103,6 +103,8 @@ gimp_language_store_parser_init (void)
return; return;
} }
current_env = g_strdup (g_getenv ("LANGUAGE"));
l10n_lang_list = g_hash_table_new_full (g_str_hash, g_str_equal, l10n_lang_list = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free, (GDestroyNotify) g_free,
(GDestroyNotify) g_free); (GDestroyNotify) g_free);

View File

@ -119,7 +119,6 @@ gimp_pdb_dialog_class_init (GimpPdbDialogClass *klass)
object_class->constructed = gimp_pdb_dialog_constructed; object_class->constructed = gimp_pdb_dialog_constructed;
object_class->dispose = gimp_pdb_dialog_dispose; 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;
object_class->set_property = gimp_pdb_dialog_set_property;
dialog_class->response = gimp_pdb_dialog_response; dialog_class->response = gimp_pdb_dialog_response;

View File

@ -137,7 +137,7 @@ _br_find_exe (GimpBinrelocInitError *error)
/* Get rid of newline character. */ /* Get rid of newline character. */
buf_size = strlen (line); buf_size = strlen (line);
if (buf_size <= 0) { if (buf_size == 0) {
/* Huh? An empty string? */ /* Huh? An empty string? */
fclose (f); fclose (f);
g_free (line); g_free (line);

View File

@ -114,13 +114,12 @@ main(void)
{ {
const gchar *test = cases[i].string; const gchar *test = cases[i].string;
GimpEevlQuantity should = cases[i].result; GimpEevlQuantity should = cases[i].result;
gboolean success = FALSE;
GimpEevlQuantity result = { 0, -1 }; GimpEevlQuantity result = { 0, -1 };
gboolean should_succeed = cases[i].should_succeed; gboolean should_succeed = cases[i].should_succeed;
GError *error = NULL; GError *error = NULL;
const gchar *error_pos = 0; const gchar *error_pos = 0;
success = gimp_eevl_evaluate (test, gimp_eevl_evaluate (test,
test_units, test_units,
&result, &result,
NULL, NULL,

View File

@ -648,16 +648,15 @@ dx_dinput_event_dispatch (GSource *source,
GimpController *controller = &input->parent_instance; GimpController *controller = &input->parent_instance;
const DIDATAFORMAT * const format = input->format; const DIDATAFORMAT * const format = input->format;
const DIOBJECTDATAFORMAT *rgodf = format->rgodf; const DIOBJECTDATAFORMAT *rgodf = format->rgodf;
HRESULT hresult;
guchar *data; guchar *data;
gint i; gint i;
GimpControllerEvent cevent = { 0, }; GimpControllerEvent cevent = { 0, };
data = g_alloca (format->dwDataSize); data = g_alloca (format->dwDataSize);
if (FAILED ((hresult = IDirectInputDevice8_GetDeviceState (input->didevice8, if (FAILED (IDirectInputDevice8_GetDeviceState (input->didevice8,
format->dwDataSize, format->dwDataSize,
data)))) data)))
{ {
return TRUE; return TRUE;
} }

View File

@ -143,6 +143,7 @@ aux_window_filter (GdkXEvent *xevent,
GdkEvent *event, GdkEvent *event,
gpointer data) gpointer data)
{ {
#if 0
GimpInputDeviceStore *store = (GimpInputDeviceStore *) data; GimpInputDeviceStore *store = (GimpInputDeviceStore *) data;
const MSG *msg = (MSG *) xevent; const MSG *msg = (MSG *) xevent;
@ -150,6 +151,7 @@ aux_window_filter (GdkXEvent *xevent,
switch (msg->message) switch (msg->message)
{ {
} }
#endif
return GDK_FILTER_REMOVE; return GDK_FILTER_REMOVE;
} }