Commit ff2f7fc0 authored by Paulo Alcantara (SUSE)'s avatar Paulo Alcantara (SUSE) Committed by Steve French

cifs: Merge is_path_valid() into get_normalized_path()

Just do the trivial path validation in get_normalized_path().
Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 345c1a4a
...@@ -75,13 +75,11 @@ static void refresh_cache_worker(struct work_struct *work); ...@@ -75,13 +75,11 @@ static void refresh_cache_worker(struct work_struct *work);
static DECLARE_DELAYED_WORK(refresh_task, refresh_cache_worker); static DECLARE_DELAYED_WORK(refresh_task, refresh_cache_worker);
static inline bool is_path_valid(const char *path) static int get_normalized_path(const char *path, char **npath)
{ {
return path && (strchr(path + 1, '\\') || strchr(path + 1, '/')); if (!path || strlen(path) < 3 || (*path != '\\' && *path != '/'))
} return -EINVAL;
static inline int get_normalized_path(const char *path, char **npath)
{
if (*path == '\\') { if (*path == '\\') {
*npath = (char *)path; *npath = (char *)path;
} else { } else {
...@@ -828,9 +826,6 @@ int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses, ...@@ -828,9 +826,6 @@ int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses,
char *npath; char *npath;
struct cache_entry *ce; struct cache_entry *ce;
if (unlikely(!is_path_valid(path)))
return -EINVAL;
rc = get_normalized_path(path, &npath); rc = get_normalized_path(path, &npath);
if (rc) if (rc)
return rc; return rc;
...@@ -875,9 +870,6 @@ int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref, ...@@ -875,9 +870,6 @@ int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
char *npath; char *npath;
struct cache_entry *ce; struct cache_entry *ce;
if (unlikely(!is_path_valid(path)))
return -EINVAL;
rc = get_normalized_path(path, &npath); rc = get_normalized_path(path, &npath);
if (rc) if (rc)
return rc; return rc;
...@@ -929,9 +921,6 @@ int dfs_cache_update_tgthint(const unsigned int xid, struct cifs_ses *ses, ...@@ -929,9 +921,6 @@ int dfs_cache_update_tgthint(const unsigned int xid, struct cifs_ses *ses,
struct cache_entry *ce; struct cache_entry *ce;
struct cache_dfs_tgt *t; struct cache_dfs_tgt *t;
if (unlikely(!is_path_valid(path)))
return -EINVAL;
rc = get_normalized_path(path, &npath); rc = get_normalized_path(path, &npath);
if (rc) if (rc)
return rc; return rc;
...@@ -989,7 +978,7 @@ int dfs_cache_noreq_update_tgthint(const char *path, ...@@ -989,7 +978,7 @@ int dfs_cache_noreq_update_tgthint(const char *path,
struct cache_entry *ce; struct cache_entry *ce;
struct cache_dfs_tgt *t; struct cache_dfs_tgt *t;
if (unlikely(!is_path_valid(path)) || !it) if (!it)
return -EINVAL; return -EINVAL;
rc = get_normalized_path(path, &npath); rc = get_normalized_path(path, &npath);
...@@ -1049,8 +1038,6 @@ int dfs_cache_get_tgt_referral(const char *path, ...@@ -1049,8 +1038,6 @@ int dfs_cache_get_tgt_referral(const char *path,
if (!it || !ref) if (!it || !ref)
return -EINVAL; return -EINVAL;
if (unlikely(!is_path_valid(path)))
return -EINVAL;
rc = get_normalized_path(path, &npath); rc = get_normalized_path(path, &npath);
if (rc) if (rc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment