summaryrefslogtreecommitdiff
path: root/src/file-data.c
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/file-data.c
parentfacddb5353b18d19c8a5b4f62b11ac0f6e666724 (diff)
downloadengrampa-98759f7bed3768ef150dcd41f97f87cbb84be8b1.tar.bz2
engrampa-98759f7bed3768ef150dcd41f97f87cbb84be8b1.tar.xz
Remove cppcheck warnings about the variable scope can be reduced
Diffstat (limited to 'src/file-data.c')
-rw-r--r--src/file-data.c19
1 files changed, 13 insertions, 6 deletions
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;
}