cpuidtool: Style cleanup

This commit is contained in:
Alexander von Gluck IV
2012-06-04 11:05:36 -05:00
parent 548b1a4988
commit 966df2f98b
+13 -9
View File
@@ -7,12 +7,12 @@
*/
/*
* Pass an Intel CPUID in hex, and get out a CPUID for OS.h
* Pass a standard CPUID in hex, and get out a CPUID for OS.h
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -24,14 +24,18 @@
// Converts a hexadecimal string to integer
static int xtoi(const char* xs, unsigned int* result)
static int
xtoi(const char* xs, unsigned int* result)
{
size_t szlen = strlen(xs);
int i, xv, fact;
int i;
int xv;
int fact;
if (szlen > 0) {
// Converting more than 32bit hexadecimal value?
if (szlen>8) return 2; // exit
if (szlen > 8)
return 2;
// Begin conversion here
*result = 0;
@@ -40,13 +44,13 @@ static int xtoi(const char* xs, unsigned int* result)
// Run until no more character to convert
for (i = szlen - 1; i>=0; i--) {
if (isxdigit(*(xs + i))) {
if (*(xs+i)>=97) {
if (*(xs + i) >= 97)
xv = (*(xs + i) - 97) + 10;
} else if ( *(xs+i) >= 65) {
else if (*(xs + i) >= 65)
xv = (*(xs + i) - 65) + 10;
} else {
else
xv = *(xs + i) - 48;
}
*result += (xv * fact);
fact *= 16;
} else {