Re: [PATCH 01/10] cifs: add function to get length of NULL termination in bytes
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.file-systems.cifs |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 29 Apr 2009 11:02:37 -0400 Christoph Hellwig <[email protected]> wrote: > 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? > Makes sense. What I may do is move it there and then hardwire this function to just return '1' for now. It looks like all of the existing charsets that are in the kernel use single-byte null termination. At a later point in time, if multibyte null terminators are needed, we can change this to do something different and the callers should "just work". -- Jeff Layton <[email protected]>