[sheepdog] [PATCH] md: trim last slashes from paths

MORITA Kazutaka morita.kazutaka at gmail.com
Wed Apr 17 17:13:23 CEST 2013


At Wed, 17 Apr 2013 20:05:00 +0800,
Liu Yuan wrote:
> 
> +static inline void trim_last_slash(char *path)
> +{
> +	while (path[strlen(path) - 1] == '/')
> +		path[strlen(path) - 1] = '\0';
> +}
> +

This cannot handle a zero-length string.  Although we don't pass "" to
this function currently, adding

    if (path[0] == '\0')
        return;

before the while loop looks better to me.

Thanks,

Kazutaka



More information about the sheepdog mailing list