cpuidtool: Style cleanup

This commit is contained in:
Alexander von Gluck IV 2012-06-04 11:05:36 -05:00
parent 548b1a4988
commit 966df2f98b

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,29 +24,33 @@
// 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;
fact = 1;
// Run until no more character to convert
for (i = szlen - 1; i>=0 ;i--) {
if (isxdigit(*(xs+i))) {
if (*(xs+i)>=97) {
xv = ( *(xs+i) - 97) + 10;
} else if ( *(xs+i) >= 65) {
xv = (*(xs+i) - 65) + 10;
} else {
xv = *(xs+i) - 48;
}
for (i = szlen - 1; i>=0; i--) {
if (isxdigit(*(xs + i))) {
if (*(xs + i) >= 97)
xv = (*(xs + i) - 97) + 10;
else if (*(xs + i) >= 65)
xv = (*(xs + i) - 65) + 10;
else
xv = *(xs + i) - 48;
*result += (xv * fact);
fact *= 16;
} else {