lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1276611938-28464-1-git-send-email-andy.shevchenko@gmail.com>
Date:	Tue, 15 Jun 2010 17:25:38 +0300
From:	Andy Shevchenko <andy.shevchenko@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Andy Shevchenko <ext-andriy.shevchenko@...ia.com>,
	Greg Kroah-Hartman <gregkh@...e.de>, devel@...verdev.osuosl.org
Subject: [PATCH] staging: don't use custom hex_to_bin() implementation

From: Andy Shevchenko <ext-andriy.shevchenko@...ia.com>

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@...ia.com>
Cc: Greg Kroah-Hartman <gregkh@...e.de>
Cc: devel@...verdev.osuosl.org
---
 drivers/staging/comedi/drivers/jr3_pci.c |   17 +++++++++--------
 drivers/staging/rtl8192su/r8192S_Efuse.c |   19 +------------------
 2 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index d330b18..51f4c5c 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -48,6 +48,7 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
 #include <linux/jiffies.h>
 #include <linux/slab.h>
 #include <linux/timer.h>
+#include <linux/kernel.h>
 #include "comedi_pci.h"
 #include "jr3_pci.h"
 
@@ -399,14 +400,14 @@ int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val)
 		}
 		/*  Collect value */
 		*val = 0;
-		for (; *pos < size && isxdigit(data[*pos]); (*pos)++) {
-			char ch = tolower(data[*pos]);
-			result = 1;
-			if ('0' <= ch && ch <= '9') {
-				*val = (*val << 4) + (ch - '0');
-			} else if ('a' <= ch && ch <= 'f') {
-				*val = (*val << 4) + (ch - 'a' + 10);
-			}
+		for (; *pos < size; (*pos)++) {
+			int value;
+			value = hex_to_bin(data[*pos]);
+			if (value >= 0) {
+				result = 1;
+				*val = (*val << 4) + value;
+			} else
+				break;
 		}
 	}
 	return result;
diff --git a/drivers/staging/rtl8192su/r8192S_Efuse.c b/drivers/staging/rtl8192su/r8192S_Efuse.c
index f0ce656..1e1d55e 100644
--- a/drivers/staging/rtl8192su/r8192S_Efuse.c
+++ b/drivers/staging/rtl8192su/r8192S_Efuse.c
@@ -1848,22 +1848,6 @@ bool IsHexDigit(	char chTmp)
 	}
 }
 
-//
-//	Description:
-//		Translate a character to hex digit.
-//
-u32 MapCharToHexDigit(char chTmp)
-{
-	if(chTmp >= '0' && chTmp <= '9')
-		return (chTmp - '0');
-	else if(chTmp >= 'a' && chTmp <= 'f')
-		return (10 + (chTmp - 'a'));
-	else if(chTmp >= 'A' && chTmp <= 'F')
-		return (10 + (chTmp - 'A'));
-	else
-		return 0;
-}
-
 /*-----------------------------------------------------------------------------
  * Function:	efuse_ParsingMap
  *
@@ -1917,8 +1901,7 @@ efuse_ParsingMap(char* szStr,u32* pu4bVal,u32* pu4bMove)
 	// Parse each digit.
 	do
 	{
-		(*pu4bVal) <<= 4;
-		*pu4bVal += MapCharToHexDigit(*szScan);
+		*pu4bVal = (*pu4bVal << 4) + hex_to_bin(*szScan);
 
 		szScan++;
 		(*pu4bMove)++;
-- 
1.6.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ