From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753526Ab1IWLc4 (ORCPT ); Fri, 23 Sep 2011 07:32:56 -0400 Received: from mga11.intel.com ([192.55.52.93]:40254 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753327Ab1IWLcz (ORCPT ); Fri, 23 Sep 2011 07:32:55 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.68,429,1312182000"; d="scan'208";a="69029591" From: Andy Shevchenko To: linux-kernel@vger.kernel.org Cc: Andy Shevchenko , OGAWA Hirofumi Subject: [PATCH] fat: don't use custom hex_to_bin() Date: Fri, 23 Sep 2011 14:32:12 +0300 Message-Id: X-Mailer: git-send-email 1.7.6.3 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Andy Shevchenko Cc: OGAWA Hirofumi --- fs/fat/namei_vfat.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index bb3f29c..09cec4c 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c @@ -21,6 +21,8 @@ #include #include #include +#include + #include "fat.h" /* @@ -505,7 +507,6 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, struct nls_table *nls) { const unsigned char *ip; - unsigned char nc; unsigned char *op; unsigned int ec; int i, k, fill; @@ -530,21 +531,10 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, 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; - } - return -EINVAL; + int val = hex_to_bin(ip[k]); + if (val < 0) + return -EINVAL; + ec = (ec << 4) | val; } *op++ = ec & 0xFF; *op++ = ec >> 8; -- 1.7.6.3