summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-12-21 16:38:28 +0100
committerraveit65 <[email protected]>2021-01-07 18:37:10 +0100
commit98759f7bed3768ef150dcd41f97f87cbb84be8b1 (patch)
tree9d36f1a67229a67a117c1f9583dafbe9d1b55a8b /src
parentfacddb5353b18d19c8a5b4f62b11ac0f6e666724 (diff)
downloadengrampa-98759f7bed3768ef150dcd41f97f87cbb84be8b1.tar.bz2
engrampa-98759f7bed3768ef150dcd41f97f87cbb84be8b1.tar.xz
Remove cppcheck warnings about the variable scope can be reduced
Diffstat (limited to 'src')
-rw-r--r--src/eggfileformatchooser.c23
-rw-r--r--src/eggtreemultidnd.c10
-rw-r--r--src/file-data.c19
-rw-r--r--src/file-utils.c2
-rw-r--r--src/fr-archive.c3
-rw-r--r--src/fr-command-cpio.c8
-rw-r--r--src/fr-command-iso.c8
-rw-r--r--src/fr-command-lha.c19
-rw-r--r--src/fr-command-rpm.c9
-rw-r--r--src/fr-window.c26
-rw-r--r--src/gtk-utils.c5
11 files changed, 75 insertions, 57 deletions
diff --git a/src/eggfileformatchooser.c b/src/eggfileformatchooser.c
index 9161ea4..5addee3 100644
--- a/src/eggfileformatchooser.c
+++ b/src/eggfileformatchooser.c
@@ -99,11 +99,9 @@ egg_file_format_filter_info_new (const gchar *name,
static void
egg_file_format_filter_info_free (gpointer boxed)
{
- EggFileFormatFilterInfo *self;
-
if (boxed)
{
- self = boxed;
+ EggFileFormatFilterInfo *self = boxed;
g_hash_table_unref (self->extension_set);
g_slist_free_full (self->extension_list, g_free);
@@ -164,7 +162,6 @@ egg_file_format_filter_add_extensions (GtkFileFilter *filter,
GString *filter_name;
gchar **strings;
gchar **ptr;
- gchar *pattern;
g_assert (NULL != extensions);
@@ -185,7 +182,7 @@ egg_file_format_filter_add_extensions (GtkFileFilter *filter,
strings = g_strsplit (extensions, ", ", -1);
for (ptr = strings; *ptr; ptr++)
{
- pattern = g_strdup_printf ("*%s", *ptr);
+ gchar *pattern = g_strdup_printf ("*%s", *ptr);
if (filter_name)
{
@@ -211,7 +208,6 @@ static void
selection_changed_cb (GtkTreeSelection *selection,
EggFileFormatChooser *self)
{
- gchar *label;
gchar *name;
GtkFileFilter *filter;
@@ -221,6 +217,8 @@ selection_changed_cb (GtkTreeSelection *selection,
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
+ gchar *label;
+
gtk_tree_model_get (model, &iter, MODEL_COLUMN_NAME, &name, -1);
label = g_strdup_printf (_("File _Format: %s"), name);
@@ -298,7 +296,6 @@ static gboolean
accept_filename (gchar *extensions,
const gchar *filename)
{
- const gchar *extptr;
gchar *saveptr;
gchar *token;
gsize length;
@@ -308,6 +305,8 @@ accept_filename (gchar *extensions,
for (token = strtok_r (extensions, ",", &saveptr); NULL != token;
token = strtok_r (NULL, ",", &saveptr))
{
+ const gchar *extptr;
+
token = g_strstrip (token);
extptr = filename + length - strlen (token) - 1;
@@ -636,14 +635,14 @@ chooser_response_cb (GtkDialog *dialog,
gpointer data)
{
EggFileFormatChooser *self;
- gchar *filename, *basename;
- gchar *message;
- guint format;
self = EGG_FILE_FORMAT_CHOOSER (data);
if (EGG_IS_POSITIVE_RESPONSE (response_id))
{
+ gchar *filename, *basename;
+ guint format;
+
filename = gtk_file_chooser_get_filename (self->priv->chooser);
basename = g_filename_display_basename (filename);
g_free (filename);
@@ -653,6 +652,7 @@ chooser_response_cb (GtkDialog *dialog,
if (0 == format)
{
+ gchar *message;
message = g_strdup_printf (
_("The program was not able to find out the file format "
@@ -892,7 +892,6 @@ get_icon_name (const gchar *mime_type)
{
static gboolean first_call = TRUE;
gchar *name = NULL;
- gchar *s;
if (first_call)
{
@@ -903,6 +902,8 @@ get_icon_name (const gchar *mime_type)
if (mime_type)
{
+ gchar *s;
+
name = g_strconcat ("mate-mime-", mime_type, NULL);
for(s = name; *s; ++s)
diff --git a/src/eggtreemultidnd.c b/src/eggtreemultidnd.c
index f3d4534..87ad555 100644
--- a/src/eggtreemultidnd.c
+++ b/src/eggtreemultidnd.c
@@ -304,7 +304,6 @@ egg_tree_multi_drag_motion_event (GtkWidget *widget,
GList *path_list = NULL;
GtkTreeSelection *selection;
GtkTreeModel *model;
- GdkDragContext *context;
stop_drag_check (widget);
@@ -318,10 +317,11 @@ egg_tree_multi_drag_motion_event (GtkWidget *widget,
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list))
{
- GtkTargetList *target_list;
- GtkTreePath *tree_path;
- int cell_x;
- int cell_y;
+ GdkDragContext *context;
+ GtkTargetList *target_list;
+ GtkTreePath *tree_path;
+ int cell_x;
+ int cell_y;
target_list = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
context = gtk_drag_begin_with_coordinates (widget,
diff --git a/src/file-data.c b/src/file-data.c
index 53a6f85..911a5e9 100644
--- a/src/file-data.c
+++ b/src/file-data.c
@@ -147,9 +147,9 @@ int
find_path_in_file_data_array (GPtrArray *array,
const char *path)
{
- int path_l;
- int left, right, p, cmp = -1;
- FileData *fd;
+ int path_l;
+ int left;
+ int right;
if (path == NULL)
return -1;
@@ -158,16 +158,23 @@ find_path_in_file_data_array (GPtrArray *array,
left = 0;
right = array->len;
while (left < right) {
+ FileData *fd;
+ int p;
+ int cmp;
+
p = left + ((right - left) / 2);
fd = (FileData *) g_ptr_array_index (array, p);
-
cmp = strcmp (path, fd->original_path);
if (cmp != 0) {
/* consider '/path/to/dir' and '/path/to/dir/' the same path */
+ int original_path_l;
+
+ original_path_l = strlen (fd->original_path);
- int original_path_l = strlen (fd->original_path);
if ((path_l == original_path_l - 1) && (fd->original_path[original_path_l - 1] == '/')) {
- int cmp2 = strncmp (path, fd->original_path, original_path_l - 1);
+ int cmp2;
+
+ cmp2 = strncmp (path, fd->original_path, original_path_l - 1);
if (cmp2 == 0)
cmp = cmp2;
}
diff --git a/src/file-utils.c b/src/file-utils.c
index 15864d6..a967cb4 100644
--- a/src/file-utils.c
+++ b/src/file-utils.c
@@ -903,12 +903,12 @@ get_temp_work_dir (const char *parent_folder)
{
guint64 max_size = 0;
char *best_folder = NULL;
- int i;
char *template;
char *result = NULL;
if (parent_folder == NULL) {
/* find the folder with more free space. */
+ int i;
for (i = 0; try_folder[i] != NULL; i++) {
char *folder;
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 029d6fb..3d53f58 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -3335,10 +3335,11 @@ get_extract_here_destination (GFile *file,
char *desired_destination;
char *destination = NULL;
int n = 1;
- GFile *directory;
desired_destination = get_desired_destination_for_archive (file);
do {
+ GFile *directory;
+
*error = NULL;
g_free (destination);
diff --git a/src/fr-command-cpio.c b/src/fr-command-cpio.c
index 457de72..1b380ad 100644
--- a/src/fr-command-cpio.c
+++ b/src/fr-command-cpio.c
@@ -49,19 +49,21 @@ mktime_from_string (char *month,
char *mday,
char *year)
{
- static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
struct tm tm = {0, };
tm.tm_isdst = -1;
if (month != NULL) {
+ static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
int i;
- for (i = 0; i < 12; i++)
+
+ for (i = 0; i < 12; i++) {
if (strcmp (months[i], month) == 0) {
tm.tm_mon = i;
break;
}
+ }
}
tm.tm_mday = atoi (mday);
if (strchr (year, ':') != NULL) {
diff --git a/src/fr-command-iso.c b/src/fr-command-iso.c
index 3be83db..ccc2333 100644
--- a/src/fr-command-iso.c
+++ b/src/fr-command-iso.c
@@ -47,19 +47,21 @@ mktime_from_string (char *month,
char *mday,
char *year)
{
- static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
struct tm tm = {0, };
tm.tm_isdst = -1;
if (month != NULL) {
+ static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
int i;
- for (i = 0; i < 12; i++)
+
+ for (i = 0; i < 12; i++) {
if (strcmp (months[i], month) == 0) {
tm.tm_mon = i;
break;
}
+ }
}
tm.tm_mday = atoi (mday);
tm.tm_year = atoi (year) - 1900;
diff --git a/src/fr-command-lha.c b/src/fr-command-lha.c
index 0adfcc1..9996bba 100644
--- a/src/fr-command-lha.c
+++ b/src/fr-command-lha.c
@@ -48,27 +48,29 @@ mktime_from_string (char *month,
char *mday,
char *time_or_year)
{
- static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- struct tm tm = {0, };
- char **fields;
+ struct tm tm = {0, };
tm.tm_isdst = -1;
/* date */
if (month != NULL) {
+ static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
int i;
- for (i = 0; i < 12; i++)
+
+ for (i = 0; i < 12; i++) {
if (strcmp (months[i], month) == 0) {
tm.tm_mon = i;
break;
}
+ }
}
tm.tm_mday = atoi (mday);
if (strchr (time_or_year, ':') == NULL)
tm.tm_year = atoi (time_or_year) - 1900;
else {
+ char **fields;
time_t now;
struct tm *tm_now;
@@ -97,7 +99,7 @@ split_line_lha (char *line)
{
char **fields;
int n_fields = 7;
- const char *scan, *field_end;
+ const char *scan;
int i;
fields = g_new0 (char *, n_fields + 1);
@@ -128,8 +130,9 @@ split_line_lha (char *line)
scan = eat_spaces (line);
for (; i < n_fields; i++) {
- field_end = strchr (scan, ' ');
- if (field_end != NULL) {
+ const char *field_end;
+
+ if (NULL != (field_end = strchr (scan, ' '))) {
fields[i] = g_strndup (scan, field_end - scan);
scan = eat_spaces (field_end);
}
diff --git a/src/fr-command-rpm.c b/src/fr-command-rpm.c
index 3c5c755..5fff8d7 100644
--- a/src/fr-command-rpm.c
+++ b/src/fr-command-rpm.c
@@ -49,19 +49,22 @@ mktime_from_string (char *month,
char *mday,
char *year)
{
- static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
struct tm tm = {0, };
tm.tm_isdst = -1;
if (month != NULL) {
+ static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+
int i;
- for (i = 0; i < 12; i++)
+
+ for (i = 0; i < 12; i++) {
if (strcmp (months[i], month) == 0) {
tm.tm_mon = i;
break;
}
+ }
} else
tm.tm_mon = 0;
diff --git a/src/fr-window.c b/src/fr-window.c
index 2d2cea6..b2ab22b 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -2261,16 +2261,13 @@ static void change_button_label (FrWindow *window,
GTK_ICON_SIZE_BUTTON));
}
}
-static void fr_state_switch (FrWindow *window)
+
+static void
+fr_state_switch (FrWindow *window)
{
- int ret;
- if (window->archive->process != NULL)
- {
- ret = start_switch_state (window->archive->process);
- if (ret == 0)
- {
- change_button_label (window, window->priv->pd_state_button);
- }
+ if ((window->archive->process != NULL) &&
+ ((start_switch_state (window->archive->process) == 0))) {
+ change_button_label (window, window->priv->pd_state_button);
}
}
@@ -4308,7 +4305,7 @@ get_xds_atom_value (GdkDragContext *context)
{
gint actual_length;
char *data;
- char *ret;
+ char *ret = NULL;
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (gdk_drag_context_get_source_window (context) != NULL, NULL);
@@ -4321,10 +4318,9 @@ get_xds_atom_value (GdkDragContext *context)
/* add not included \0 to the end of the string */
ret = g_strndup ((gchar *) data, actual_length);
g_free (data);
- return ret;
}
- return NULL;
+ return ret;
}
@@ -4711,10 +4707,11 @@ fr_window_delete_event_cb (GtkWidget *caller,
static gboolean
is_single_click_policy (FrWindow *window)
{
- char *value;
gboolean result = FALSE;
if (window->priv->settings_caja) {
+ char *value;
+
value = g_settings_get_string (window->priv->settings_caja, CAJA_CLICK_POLICY);
result = (value != NULL) && (strncmp (value, "single", 6) == 0);
g_free (value);
@@ -4732,7 +4729,6 @@ filename_cell_data_func (GtkTreeViewColumn *column,
FrWindow *window)
{
char *text;
- GtkTreePath *path;
PangoUnderline underline;
gtk_tree_model_get (model, iter,
@@ -4740,6 +4736,8 @@ filename_cell_data_func (GtkTreeViewColumn *column,
-1);
if (window->priv->single_click) {
+ GtkTreePath *path;
+
path = gtk_tree_model_get_path (model, iter);
if ((window->priv->list_hover_path == NULL)
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index d021147..ea64bd0 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -254,11 +254,9 @@ _gtk_error_dialog_new (GtkWindow *parent,
GtkWidget *expander;
GtkWidget *content_area;
GtkWidget *action_area;
- GtkTextBuffer *text_buf;
GtkTextIter iter;
GList *scan;
char *escaped_message, *markup_text;
- va_list args;
gboolean view_output = (row_output != NULL);
dialog = gtk_dialog_new_with_buttons ("",
@@ -287,6 +285,7 @@ _gtk_error_dialog_new (GtkWindow *parent,
escaped_message = g_markup_escape_text (primary_text, -1);
if (secondary_text != NULL) {
+ va_list args;
char *secondary_message;
char *escaped_secondary_message;
@@ -309,6 +308,8 @@ _gtk_error_dialog_new (GtkWindow *parent,
g_free (escaped_message);
if (view_output) {
+ GtkTextBuffer *text_buf;
+
gtk_widget_set_size_request (dialog, 500, -1);
/* Expander */