cpuidtool: Style cleanup
This commit is contained in:
parent
548b1a4988
commit
966df2f98b
|
@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,14 +24,18 @@
|
||||||
|
|
||||||
|
|
||||||
// Converts a hexadecimal string to integer
|
// 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);
|
size_t szlen = strlen(xs);
|
||||||
int i, xv, fact;
|
int i;
|
||||||
|
int xv;
|
||||||
|
int fact;
|
||||||
|
|
||||||
if (szlen > 0) {
|
if (szlen > 0) {
|
||||||
// Converting more than 32bit hexadecimal value?
|
// Converting more than 32bit hexadecimal value?
|
||||||
if (szlen>8) return 2; // exit
|
if (szlen > 8)
|
||||||
|
return 2;
|
||||||
|
|
||||||
// Begin conversion here
|
// Begin conversion here
|
||||||
*result = 0;
|
*result = 0;
|
||||||
|
@ -40,13 +44,13 @@ static int xtoi(const char* xs, unsigned int* result)
|
||||||
// Run until no more character to convert
|
// Run until no more character to convert
|
||||||
for (i = szlen - 1; i>=0; i--) {
|
for (i = szlen - 1; i>=0; i--) {
|
||||||
if (isxdigit(*(xs + i))) {
|
if (isxdigit(*(xs + i))) {
|
||||||
if (*(xs+i)>=97) {
|
if (*(xs + i) >= 97)
|
||||||
xv = (*(xs + i) - 97) + 10;
|
xv = (*(xs + i) - 97) + 10;
|
||||||
} else if ( *(xs+i) >= 65) {
|
else if (*(xs + i) >= 65)
|
||||||
xv = (*(xs + i) - 65) + 10;
|
xv = (*(xs + i) - 65) + 10;
|
||||||
} else {
|
else
|
||||||
xv = *(xs + i) - 48;
|
xv = *(xs + i) - 48;
|
||||||
}
|
|
||||||
*result += (xv * fact);
|
*result += (xv * fact);
|
||||||
fact *= 16;
|
fact *= 16;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue