Changes by: flatcap
Update of /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions
In directory usw-pr-cvs1:/tmp/cvs-serv6668
Modified Files:
ldm.c
Log Message:
hex routines -> sscanf, following the discussion on lkml
Index: ldm.c
===================================================================
RCS file: /cvsroot/linux-ntfs/dynamic-disk/linux/fs/partitions/ldm.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -U2 -r1.58 -r1.59
--- ldm.c 17 Feb 2002 22:16:13 -0000 1.58
+++ ldm.c 22 Feb 2002 14:35:05 -0000 1.59
@@ -82,32 +82,4 @@
#endif
/**
- * ldm_parse_hexbyte - Convert a ASCII hex number to a byte
- * @src: Pointer to at least 2 characters to convert.
- *
- * Return: integer in the range [0,255] on success
- * -1 on error.
- */
-static int ldm_parse_hexbyte (const u8 *src)
-{
- unsigned int a, b, c; /* For correct wrapping */
- int h;
-
- BUG_ON (!src);
-
- /* high part */
- if ((a = src[0] - '0') <= '9'-'0') h = a;
- else if ((b = src[0] - 'A') <= 'F'-'A') h = b+10;
- else if ((c = src[0] - 'a') <= 'f'-'a') h = c+10;
- else return -1;
- h = h << 4;
-
- /* low part */
- if ((a = src[1] - '0') <= '9'-'0') return h | a;
- else if ((b = src[1] - 'A') <= 'F'-'A') return h | (b+10);
- else if ((c = src[1] - 'a') <= 'f'-'a') return h | (c+10);
- return -1;
-}
-
-/**
* ldm_parse_guid - Convert GUID from ASCII to binary
* @src: A 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
@@ -121,6 +93,5 @@
static BOOL ldm_parse_guid (const u8 *src, u8 *dest)
{
- static const int size[] = { 4, 2, 2, 2, 6 };
- int i, j, v;
+ u16 *tmp;
BUG_ON (!src || !dest);
@@ -130,14 +101,7 @@
return FALSE;
- for (j = 0; j < 5; j++, src++) {
- for (i = 0; i < size[j]; i++, src+=2, dest++) {
- v = ldm_parse_hexbyte (src);
- if (v < 0)
- return FALSE;
- *dest = v;
- }
- }
-
- return TRUE;
+ tmp = (u16*) dest;
+ return (8 == sscanf (src, "%04hx%04hx-%04hx-%04hx-%04hx-%04hx%04hx%04hx",
+ tmp, tmp+1, tmp+2, tmp+3, tmp+4, tmp+5, tmp+6, tmp+7));
}
|