From patchwork Thu Mar 31 21:36:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 680211 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2VLaqAp001147 for ; Thu, 31 Mar 2011 21:36:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755034Ab1CaVg6 (ORCPT ); Thu, 31 Mar 2011 17:36:58 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:53989 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756885Ab1CaVg6 (ORCPT ); Thu, 31 Mar 2011 17:36:58 -0400 Received: by mail-vx0-f174.google.com with SMTP id 39so2254483vxi.19 for ; Thu, 31 Mar 2011 14:36:58 -0700 (PDT) Received: by 10.52.69.243 with SMTP id h19mr4270167vdu.207.1301607417939; Thu, 31 Mar 2011 14:36:57 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-075-177-180-210.nc.res.rr.com [75.177.180.210]) by mx.google.com with ESMTPS id b24sm836751vby.7.2011.03.31.14.36.56 (version=SSLv3 cipher=OTHER); Thu, 31 Mar 2011 14:36:57 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: dhowells@redhat.com, linux-cifs@vger.kernel.org Subject: [PATCH 5/5] cifs: clean up various nits in unicode routines Date: Thu, 31 Mar 2011 17:36:45 -0400 Message-Id: <1301607405-4379-6-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1301607405-4379-1-git-send-email-jlayton@redhat.com> References: <1301607405-4379-1-git-send-email-jlayton@redhat.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 31 Mar 2011 21:36:59 +0000 (UTC) diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index 9dd2682..e7ffade 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c @@ -90,7 +90,7 @@ cifs_mapchar(char *target, const __u16 src_char, const struct nls_table *cp, case UNI_COLON: *target = ':'; break; - case UNI_ASTERIK: + case UNI_ASTERISK: *target = '*'; break; case UNI_QUESTION: @@ -264,40 +264,39 @@ cifs_strndup_from_ucs(const char *src, const int maxlen, const bool is_unicode, * names are little endian 16 bit Unicode on the wire */ int -cifsConvertToUCS(__le16 *target, const char *source, int maxlen, +cifsConvertToUCS(__le16 *target, const char *source, int srclen, const struct nls_table *cp, int mapChars) { int i, j, charlen; - int len_remaining = maxlen; char src_char; - __u16 temp; + __le16 temp; if (!mapChars) return cifs_strtoUCS(target, source, PATH_MAX, cp); - for (i = 0, j = 0; i < maxlen; j++) { + for (i = 0, j = 0; i < srclen; j++) { src_char = source[i]; switch (src_char) { case 0: - put_unaligned_le16(0, &target[j]); + put_unaligned(0, &target[j]); goto ctoUCS_out; case ':': - temp = UNI_COLON; + temp = cpu_to_le16(UNI_COLON); break; case '*': - temp = UNI_ASTERIK; + temp = cpu_to_le16(UNI_ASTERISK); break; case '?': - temp = UNI_QUESTION; + temp = cpu_to_le16(UNI_QUESTION); break; case '<': - temp = UNI_LESSTHAN; + temp = cpu_to_le16(UNI_LESSTHAN); break; case '>': - temp = UNI_GRTRTHAN; + temp = cpu_to_le16(UNI_GRTRTHAN); break; case '|': - temp = UNI_PIPE; + temp = cpu_to_le16(UNI_PIPE); break; /* * FIXME: We can not handle remapping backslash (UNI_SLASH) @@ -305,17 +304,18 @@ cifsConvertToUCS(__le16 *target, const char *source, int maxlen, * as they use backslash as separator. */ default: - charlen = cp->char2uni(source+i, len_remaining, - &temp); + charlen = cp->char2uni(source + i, srclen - i, + (wchar_t *)&temp); + temp = cpu_to_le16(temp); + /* * if no match, use question mark, which at least in * some cases serves as wild card */ if (charlen < 1) { - temp = 0x003f; + temp = cpu_to_le16(0x003f); charlen = 1; } - len_remaining -= charlen; /* * character may take more than one byte in the source * string, but will take exactly two bytes in the @@ -324,9 +324,8 @@ cifsConvertToUCS(__le16 *target, const char *source, int maxlen, i += charlen; continue; } - put_unaligned_le16(temp, &target[j]); + put_unaligned(temp, &target[j]); i++; /* move to next char in source string */ - len_remaining--; } ctoUCS_out: diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h index cc9628b..e00f677 100644 --- a/fs/cifs/cifs_unicode.h +++ b/fs/cifs/cifs_unicode.h @@ -44,7 +44,7 @@ * reserved symbols (along with \ and /), otherwise illegal to store * in filenames in NTFS */ -#define UNI_ASTERIK (__u16) ('*' + 0xF000) +#define UNI_ASTERISK (__u16) ('*' + 0xF000) #define UNI_QUESTION (__u16) ('?' + 0xF000) #define UNI_COLON (__u16) (':' + 0xF000) #define UNI_GRTRTHAN (__u16) ('>' + 0xF000)