|
@@ -131,53 +131,48 @@ static int parse_local_cpus(lub_list_t *irqs, const char *sysfs_path,
|
|
unsigned int num, lub_list_t *pxms)
|
|
unsigned int num, lub_list_t *pxms)
|
|
{
|
|
{
|
|
char path[PATH_MAX];
|
|
char path[PATH_MAX];
|
|
- FILE *fd;
|
|
|
|
|
|
+ FILE *fd = NULL;
|
|
char *str = NULL;
|
|
char *str = NULL;
|
|
size_t sz;
|
|
size_t sz;
|
|
cpumask_t local_cpus;
|
|
cpumask_t local_cpus;
|
|
irq_t *irq = NULL;
|
|
irq_t *irq = NULL;
|
|
cpumask_t cpumask;
|
|
cpumask_t cpumask;
|
|
|
|
+ int ret = -1;
|
|
|
|
+
|
|
|
|
+ irq = irq_list_search(irqs, num);
|
|
|
|
+ if (!irq)
|
|
|
|
+ return ret;
|
|
|
|
|
|
cpus_init(local_cpus);
|
|
cpus_init(local_cpus);
|
|
cpus_init(cpumask);
|
|
cpus_init(cpumask);
|
|
|
|
|
|
- irq = irq_list_search(irqs, num);
|
|
|
|
- if (!irq) {
|
|
|
|
- cpus_free(local_cpus);
|
|
|
|
- cpus_free(cpumask);
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/* Find proximity in config file. */
|
|
/* Find proximity in config file. */
|
|
if (!pxm_search(pxms, sysfs_path, &cpumask)) {
|
|
if (!pxm_search(pxms, sysfs_path, &cpumask)) {
|
|
cpus_copy(irq->local_cpus, cpumask);
|
|
cpus_copy(irq->local_cpus, cpumask);
|
|
- cpus_free(local_cpus);
|
|
|
|
- cpus_free(cpumask);
|
|
|
|
- return 0;
|
|
|
|
|
|
+ ret = 0; /* success */
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
|
|
|
|
snprintf(path, sizeof(path),
|
|
snprintf(path, sizeof(path),
|
|
"%s/%s/local_cpus", SYSFS_PCI_PATH, sysfs_path);
|
|
"%s/%s/local_cpus", SYSFS_PCI_PATH, sysfs_path);
|
|
path[sizeof(path) - 1] = '\0';
|
|
path[sizeof(path) - 1] = '\0';
|
|
- if (!(fd = fopen(path, "r"))){
|
|
|
|
- cpus_free(local_cpus);
|
|
|
|
- cpus_free(cpumask);
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- if (getline(&str, &sz, fd) < 0) {
|
|
|
|
- fclose(fd);
|
|
|
|
- cpus_free(local_cpus);
|
|
|
|
- cpus_free(cpumask);
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- fclose(fd);
|
|
|
|
|
|
+ if (!(fd = fopen(path, "r")))
|
|
|
|
+ goto error;
|
|
|
|
+ if (getline(&str, &sz, fd) < 0)
|
|
|
|
+ goto error;
|
|
cpumask_parse_user(str, strlen(str), local_cpus);
|
|
cpumask_parse_user(str, strlen(str), local_cpus);
|
|
cpus_and(irq->local_cpus, irq->local_cpus, local_cpus);
|
|
cpus_and(irq->local_cpus, irq->local_cpus, local_cpus);
|
|
|
|
+ ret = 0; /* success */
|
|
|
|
+
|
|
|
|
+error:
|
|
|
|
+ if (fd)
|
|
|
|
+ fclose(fd);
|
|
|
|
+ if (str)
|
|
|
|
+ free(str);
|
|
cpus_free(local_cpus);
|
|
cpus_free(local_cpus);
|
|
cpus_free(cpumask);
|
|
cpus_free(cpumask);
|
|
- free(str);
|
|
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
static int parse_sysfs(lub_list_t *irqs, lub_list_t *pxms)
|
|
static int parse_sysfs(lub_list_t *irqs, lub_list_t *pxms)
|