[linux-cifs-client] [PATCH 01/10] cifs: add function to get length of NULL termination in bytes

Christoph Hellwig hch at infradead.org
Wed Apr 29 15:02:37 GMT 2009


On Wed, Apr 29, 2009 at 09:29:11AM -0400, Jeff Layton wrote:
>  /*
> + * null_charlen - return length of null character for codepage
> + * @codepage - codepage for which to return length of NULL terminator
> + *
> + * Since we can't guarantee that the null terminator will be a particular
> + * length, we have to check against the codepage. If there's a problem
> + * determining it, assume a single-byte NULL terminator.
> + */
> +static inline int
> +null_charlen(const struct nls_table *codepage)
> +{
> +	int charlen;
> +	char tmp[NLS_MAX_CHARSET_SIZE];
> +
> +	charlen = codepage->uni2char(0, tmp, NLS_MAX_CHARSET_SIZE);
> +
> +	return charlen > 0 ? charlen : 1;
> +}

Add this to include/linux/nls.h instead?



More information about the linux-cifs-client mailing list