Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ static const char *
go_to_end_of_serialized_string (const char *non_serialized_data,
const char *already_serialized_part, size_t *offset)
{
size_t calculated_offset;
const char *semi_ptr = strchr (non_serialized_data + 1, SRLZ_DELIM_C);
const size_t calculated_offset =
(semi_ptr - non_serialized_data) + 1 + strlen (already_serialized_part);

calculated_offset = (semi_ptr - non_serialized_data) + 1 + strlen (already_serialized_part);
if (calculated_offset >= strlen (non_serialized_data))
return NULL;

Expand Down Expand Up @@ -149,17 +149,16 @@ mc_deserialize_str (const char prefix, const char *data, GError **error)

{
char buffer[BUF_TINY];
char *semi_ptr;
size_t semi_offset;

semi_ptr = strchr (data + 1, SRLZ_DELIM_C);
const char *semi_ptr = strchr (data + 1, SRLZ_DELIM_C);
if (semi_ptr == NULL)
{
g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Length delimiter '%c' doesn't exists",
SRLZ_DELIM_C);
return NULL;
}
semi_offset = semi_ptr - (data + 1);

const size_t semi_offset = semi_ptr - (data + 1);
if (semi_offset >= BUF_TINY)
{
g_set_error (error, MC_ERROR, 0, FUNC_NAME ": Too big string length");
Expand Down
4 changes: 2 additions & 2 deletions lib/strutil/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ str_replace_all (const char *haystack, const char *needle, const char *replaceme
{
size_t needle_len, replacement_len;
GString *return_str = NULL;
char *needle_in_str;
const char *needle_in_str;

needle_len = strlen (needle);
replacement_len = strlen (replacement);
Expand All @@ -73,7 +73,7 @@ str_replace_all (const char *haystack, const char *needle, const char *replaceme

if (str_is_char_escaped (haystack, needle_in_str))
{
char *backslash = needle_in_str - 1;
const char *backslash = needle_in_str - 1;

if (haystack != backslash)
g_string_append_len (return_str, haystack, backslash - haystack);
Expand Down
5 changes: 2 additions & 3 deletions lib/vfs/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ vfs_path_from_str_deprecated_parser (char *path)

while ((class = _vfs_split_with_semi_skip_count (path, &local, &op, 0)) != NULL)
{
char *url_params;
element = g_new0 (vfs_path_element_t, 1);
element->class = class;
if (local == NULL)
Expand All @@ -357,10 +356,10 @@ vfs_path_from_str_deprecated_parser (char *path)
element->dir.converter =
(element->encoding != NULL) ? str_crt_conv_from (element->encoding) : INVALID_CONV;

url_params = strchr (op, ':'); // skip VFS prefix
const char *url_params = strchr (op, ':'); // skip VFS prefix
if (url_params != NULL)
{
*url_params = '\0';
path[url_params - path] = '\0'; // truncate the path
url_params++;
vfs_path_url_split (element, url_params);
}
Expand Down
6 changes: 2 additions & 4 deletions src/filemanager/find.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,17 +1169,15 @@ find_ignore_dir_search (const char *dir, size_t len)
break;
case 1: // dir is absolute, ignore_dir is relative
{
char *d;

d = strstr (dir, *ignore_dir);
const char *d = strstr (dir, *ignore_dir);
if (d != NULL && IS_PATH_SEP (d[-1]) && (d[ilen] == '\0' || IS_PATH_SEP (d[ilen])))
return TRUE;
}
break;
case 2: // dir is relative, ignore_dir is absolute
// FIXME: skip this case
break;
default: // this cannot occurs
default: // this cannot occur
return FALSE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/filemanager/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,7 @@ chdir_other_panel (WPanel *panel)
{
const file_entry_t *entry;
vfs_path_t *new_dir_vpath;
char *curr_entry = NULL;
const char *curr_entry = NULL;
WPanel *p;

entry = panel_current_entry (panel);
Expand Down
30 changes: 19 additions & 11 deletions src/vfs/extfs/extfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ extfs_find_entry_int (struct vfs_s_inode *dir, const char *name, GSList *list, i
{
struct vfs_s_entry *pent, *pdir;
const char *p, *name_end;
char *q;
char *name_copy;
char c = PATH_SEP;
struct extfs_super_t *super;

Expand All @@ -246,17 +246,21 @@ extfs_find_entry_int (struct vfs_s_inode *dir, const char *name, GSList *list, i

super = EXTFS_SUPER (dir->super);
pent = dir->ent;
p = name;
name_end = name + strlen (name);

const size_t name_len = strlen (name);

name_copy = g_strndup (name, name_len);
p = name_copy;
name_end = name_copy + name_len;

while ((pent != NULL) && (c != '\0') && (*p != '\0'))
{
q = strchr (p, PATH_SEP);
const char *q = strchr (p, PATH_SEP);
if (q == NULL)
q = (char *) name_end;
q = name_end;

c = *q;
*q = '\0';
name_copy[q - name_copy] = '\0';

if (DIR_IS_DOTDOT (p))
pent = pent->dir != NULL ? pent->dir->ent : NULL;
Expand All @@ -267,14 +271,14 @@ extfs_find_entry_int (struct vfs_s_inode *dir, const char *name, GSList *list, i
pent = extfs_resolve_symlinks_int (pent, list);
if (pent == NULL)
{
*q = c;
g_free (name_copy);
return NULL;
}

if (!S_ISDIR (pent->ino->st.st_mode))
{
*q = c;
notadir = TRUE;
g_free (name_copy);
return NULL;
}

Expand All @@ -283,9 +287,9 @@ extfs_find_entry_int (struct vfs_s_inode *dir, const char *name, GSList *list, i
pent = pl != NULL ? VFS_ENTRY (pl->data) : NULL;
if (pent != NULL && q + 1 > name_end)
{
// Hack: I keep the original semanthic unless q+1 would break in the strchr
*q = c;
// Hack: I keep the original semantic unless q+1 would break in the strchr
notadir = !S_ISDIR (pent->ino->st.st_mode);
g_free (name_copy);
return pent;
}

Expand All @@ -297,12 +301,16 @@ extfs_find_entry_int (struct vfs_s_inode *dir, const char *name, GSList *list, i
}

// Next iteration
*q = c;
name_copy[q - name_copy] = c;
if (c != '\0')
p = q + 1;
}

g_free (name_copy);

if (pent == NULL)
my_errno = ENOENT;

return pent;
}

Expand Down
Loading