iucode_tool: optimize detection of base10 numeric names

Use a faster method to detect wether a directory name is made only of
decimal digits than strtoul()'ing it, since we don't need the value.
parent c7d73ca6
......@@ -2661,6 +2661,20 @@ static int xx_scan_handle_sig(const uint32_t id1, const uint32_t id2,
}
#ifdef USE_CPUID_DEVICE
static int is_base10_number(const char *s)
{
if (!s || !*s)
return 0;
while(*s) {
if (*s < '0' || *s > '9')
return 0;
s++;
}
return 1;
}
/* requires a kernel driver, and *really* hurts on very large systems */
static int xx_check_cpuid_devs(struct microcode_filter_entry ** const ucfp)
{
......@@ -2680,9 +2694,6 @@ static int xx_check_cpuid_devs(struct microcode_filter_entry ** const ucfp)
}
while (1) {
unsigned int cpu_number;
char *ep;
errno = 0;
d = readdir(cpudir);
if (!d) {
......@@ -2700,7 +2711,7 @@ static int xx_check_cpuid_devs(struct microcode_filter_entry ** const ucfp)
continue; /* next dentry */
/* must be [0-9]+, no trailling weirdness */
if (parse_u32(d->d_name, &ep, 10, &cpu_number) || !ep || *ep)
if (!is_base10_number(d->d_name))
continue; /* next dentry */
snprintf(cpuid_device, sizeof(cpuid_device),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment