diff mbox

[3/6] cifs: make convert_delimiter use strchr instead of open-coding it

Message ID 1353087414-32152-4-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Nov. 16, 2012, 5:36 p.m. UTC
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 <jlayton@redhat.com>
---
 fs/cifs/cifsglob.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Pavel Shilovsky Nov. 21, 2012, 3:18 p.m. UTC | #1
2012/11/16 Jeff Layton <jlayton@redhat.com>:
> 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 <jlayton@redhat.com>
> ---
>  fs/cifs/cifsglob.h | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index b141c90..414d93b 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -1066,21 +1066,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;
>  }
>
>  static inline char *
> --
> 1.7.11.7
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru>
diff mbox

Patch

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index b141c90..414d93b 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1066,21 +1066,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;
 }
 
 static inline char *