lscpu: (arm) cleanup code
* check for strtol() errors * fix indention * fix coding style Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
8229df2093
commit
af808dfa6d
|
@ -189,15 +189,22 @@ void arm_cpu_decode(struct lscpu_desc *desc)
|
||||||
{
|
{
|
||||||
int j, impl, part;
|
int j, impl, part;
|
||||||
const struct id_part *parts = NULL;
|
const struct id_part *parts = NULL;
|
||||||
char buf[8];
|
char *end;
|
||||||
|
|
||||||
if (desc->vendor == NULL || desc->model == NULL)
|
if (desc->vendor == NULL || desc->model == NULL)
|
||||||
return;
|
return;
|
||||||
if ((strncmp(desc->vendor,"0x",2) ||
|
if ((strncmp(desc->vendor,"0x",2) || strncmp(desc->model,"0x",2) ))
|
||||||
strncmp(desc->model,"0x",2) ))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
impl=(int)strtol(desc->vendor, NULL, 0);
|
errno = 0;
|
||||||
part=(int)strtol(desc->model, NULL, 0);
|
impl = (int) strtol(desc->vendor, &end, 0);
|
||||||
|
if (errno || desc->vendor == end)
|
||||||
|
return;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
part = (int) strtol(desc->model, &end, 0);
|
||||||
|
if (errno || desc->model == end)
|
||||||
|
return;
|
||||||
|
|
||||||
for (j = 0; hw_implementer[j].id != -1; j++) {
|
for (j = 0; hw_implementer[j].id != -1; j++) {
|
||||||
if (hw_implementer[j].id == impl) {
|
if (hw_implementer[j].id == impl) {
|
||||||
|
@ -206,6 +213,7 @@ void arm_cpu_decode(struct lscpu_desc *desc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts == NULL)
|
if (parts == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -217,10 +225,20 @@ void arm_cpu_decode(struct lscpu_desc *desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print out the rXpY string for ARM cores */
|
/* Print out the rXpY string for ARM cores */
|
||||||
if (impl == 0x41 && desc->revision != NULL &&
|
if (impl == 0x41 && desc->revision && desc->stepping) {
|
||||||
desc->stepping != NULL) {
|
int revision, variant;
|
||||||
int revision = atoi(desc->revision);
|
char buf[8];
|
||||||
int variant = (int)strtol(desc->stepping, NULL, 0);
|
|
||||||
|
errno = 0;
|
||||||
|
revision = (int) strtol(desc->revision, &end, 10);
|
||||||
|
if (errno || desc->revision == end)
|
||||||
|
return;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
variant = (int) strtol(desc->stepping, &end, 0);
|
||||||
|
if (errno || desc->stepping == end)
|
||||||
|
return;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "r%dp%d", variant, revision);
|
snprintf(buf, sizeof(buf), "r%dp%d", variant, revision);
|
||||||
desc->stepping = xstrdup(buf);
|
desc->stepping = xstrdup(buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue