Skip to content

Commit

Permalink
make convert_delimiter use strchr instead of open-coding it
Browse files Browse the repository at this point in the history
Take advantage of accelerated strchr() on arches that support it.

Also, no caller ever passes in a NULL pointer. Get rid of the unneeded
NULL pointer check.

Signed-off-by: Jeff Layton <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
smfrench committed Dec 5, 2012
1 parent b979aaa commit 1cc9bd6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1064,21 +1064,16 @@ static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
static inline void
convert_delimiter(char *path, char delim)
{
int i;
char old_delim;

if (path == NULL)
return;
char old_delim, *pos;

if (delim == '/')
old_delim = '\\';
else
old_delim = '/';

for (i = 0; path[i] != '\0'; i++) {
if (path[i] == old_delim)
path[i] = delim;
}
pos = path;
while ((pos = strchr(pos, old_delim)))
*pos = delim;
}

#ifdef CONFIG_CIFS_STATS
Expand Down

0 comments on commit 1cc9bd6

Please sign in to comment.