From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756879Ab1I2PhQ (ORCPT ); Thu, 29 Sep 2011 11:37:16 -0400 Received: from perches-mx.perches.com ([206.117.179.246]:51778 "EHLO labridge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755201Ab1I2PhP (ORCPT ); Thu, 29 Sep 2011 11:37:15 -0400 Message-ID: <1317310634.1854.25.camel@Joe-Laptop> Subject: Re: [PATCHv4] fat: don't use custom hex_to_bin() From: Joe Perches To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, OGAWA Hirofumi Date: Thu, 29 Sep 2011 08:37:14 -0700 In-Reply-To: References: <87ipob8l4l.fsf@devron.myhome.or.jp> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.1.92- Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2011-09-29 at 18:10 +0300, Andy Shevchenko wrote: > diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c [] > @@ -526,28 +526,16 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, > *outlen += 1) > { > if (escape && (*ip == ':')) { > + u8 uc[2]; > + > if (i > len - 5) > return -EINVAL; > - ec = 0; > - for (k = 1; k < 5; k++) { > - nc = ip[k]; > - ec <<= 4; > - if (nc >= '0' && nc <= '9') { > - ec |= nc - '0'; > - continue; > - } > - if (nc >= 'a' && nc <= 'f') { > - ec |= nc - ('a' - 10); > - continue; > - } > - if (nc >= 'A' && nc <= 'F') { > - ec |= nc - ('A' - 10); > - continue; > - } > + > + if (hex2bin(uc, ip + 1, 2) < 0) > return -EINVAL; > - } > - *op++ = ec & 0xFF; > - *op++ = ec >> 8; > + > + *(wchar_t *)op++ = uc[0] << 8 | uc[1]; perhaps: __le16 foo; if (hex2bin((u8 *)&foo, ip + 1, 2) < 0) return -EINVAL; *(u16 *)op = le16_to_cpu(foo); op += 2;