diff --git a/classify.c b/classify.c index 587e040..09cd299 100644 --- a/classify.c +++ b/classify.c @@ -104,6 +104,8 @@ static struct irq_info *add_one_irq_to_db(const char *devpath, int irq) FILE *fd; char *lcpu_mask; GList *entry; + ssize_t ret; + size_t blen; /* * First check to make sure this isn't a duplicate entry @@ -178,13 +180,12 @@ assign_node: goto assign_affinity_hint; } lcpu_mask = NULL; - rc = fscanf(fd, "%as", &lcpu_mask); + ret = getline(&lcpu_mask, &blen, fd); fclose(fd); - if (!lcpu_mask || !rc) { + if (ret <= 0) { cpus_setall(new->cpumask); } else { - cpumask_parse_user(lcpu_mask, strlen(lcpu_mask), - new->cpumask); + cpumask_parse_user(lcpu_mask, ret, new->cpumask); } free(lcpu_mask); @@ -195,12 +196,11 @@ assign_affinity_hint: if (!fd) goto out; lcpu_mask = NULL; - rc = fscanf(fd, "%as", &lcpu_mask); + ret = getline(&lcpu_mask, &blen, fd); fclose(fd); - if (!lcpu_mask) + if (ret <= 0) goto out; - cpumask_parse_user(lcpu_mask, strlen(lcpu_mask), - new->affinity_hint); + cpumask_parse_user(lcpu_mask, ret, new->affinity_hint); free(lcpu_mask); out: if (debug_mode) diff --git a/numa.c b/numa.c index 5bf03b9..a4d61f8 100644 --- a/numa.c +++ b/numa.c @@ -55,9 +55,10 @@ static void add_one_node(const char *nodename) { char path[PATH_MAX]; struct topo_obj *new; - char *cpustr; + char *cpustr = NULL; FILE *f; - int ret; + ssize_t ret; + size_t blen; new = calloc(1, sizeof(struct topo_obj)); if (!new) @@ -67,11 +68,11 @@ static void add_one_node(const char *nodename) if (ferror(f)) { cpus_clear(new->mask); } else { - ret = fscanf(f, "%as", &cpustr); - if (!ret || !cpustr) { + ret = getline(&cpustr, &blen, f); + if (ret <= 0) { cpus_clear(new->mask); } else { - cpumask_parse_user(cpustr, strlen(cpustr), new->mask); + cpumask_parse_user(cpustr, ret, new->mask); free(cpustr); } }