Browse Source

Fix PASS_BY_VALUE by coverity.com

Serj Kalichev 10 years ago
parent
commit
9813273169
2 changed files with 11 additions and 10 deletions
  1. 7 7
      balance.c
  2. 4 3
      cpu.c

+ 7 - 7
balance.c

@@ -76,7 +76,7 @@ static int move_irq_to_cpu(irq_t *irq, cpu_t *cpu)
 /* Search for the best CPU. Best CPU is a CPU with minimal load.
 /* Search for the best CPU. Best CPU is a CPU with minimal load.
    If several CPUs have the same load then the best CPU is a CPU
    If several CPUs have the same load then the best CPU is a CPU
    with minimal number of assigned IRQs */
    with minimal number of assigned IRQs */
-static cpu_t *choose_cpu(lub_list_t *cpus, cpumask_t cpumask, float threshold)
+static cpu_t *choose_cpu(lub_list_t *cpus, cpumask_t *cpumask, float threshold)
 {
 {
 	lub_list_node_t *iter;
 	lub_list_node_t *iter;
 	lub_list_t * min_cpus = NULL;
 	lub_list_t * min_cpus = NULL;
@@ -87,7 +87,7 @@ static cpu_t *choose_cpu(lub_list_t *cpus, cpumask_t cpumask, float threshold)
 	for (iter = lub_list_iterator_init(cpus); iter;
 	for (iter = lub_list_iterator_init(cpus); iter;
 		iter = lub_list_iterator_next(iter)) {
 		iter = lub_list_iterator_next(iter)) {
 		cpu = (cpu_t *)lub_list_node__get_data(iter);
 		cpu = (cpu_t *)lub_list_node__get_data(iter);
-		if (!cpu_isset(cpu->id, cpumask))
+		if (!cpu_isset(cpu->id, *cpumask))
 			continue;
 			continue;
 		if (cpu->load >= threshold)
 		if (cpu->load >= threshold)
 			continue;
 			continue;
@@ -117,7 +117,7 @@ static cpu_t *choose_cpu(lub_list_t *cpus, cpumask_t cpumask, float threshold)
 	return cpu;
 	return cpu;
 }
 }
 
 
-static int irq_set_affinity(irq_t *irq, cpumask_t cpumask)
+static int irq_set_affinity(irq_t *irq, cpumask_t *cpumask)
 {
 {
 	char path[PATH_MAX];
 	char path[PATH_MAX];
 	char buf[NR_CPUS + 1];
 	char buf[NR_CPUS + 1];
@@ -129,7 +129,7 @@ static int irq_set_affinity(irq_t *irq, cpumask_t cpumask)
 	sprintf(path, "%s/%u/smp_affinity", PROC_IRQ, irq->irq);
 	sprintf(path, "%s/%u/smp_affinity", PROC_IRQ, irq->irq);
 	if (!(fd = fopen(path, "w")))
 	if (!(fd = fopen(path, "w")))
 		return -1;
 		return -1;
-	cpumask_scnprintf(buf, sizeof(buf), cpumask);
+	cpumask_scnprintf(buf, sizeof(buf), *cpumask);
 	if ((fprintf(fd, "%s\n", buf) < 0) || (fflush(fd) == EOF)) {
 	if ((fprintf(fd, "%s\n", buf) < 0) || (fflush(fd) == EOF)) {
 		/* The affinity for some IRQ can't be changed. So don't
 		/* The affinity for some IRQ can't be changed. So don't
 		   consider such IRQs. The example is IRQ 0 - timer.
 		   consider such IRQs. The example is IRQ 0 - timer.
@@ -156,7 +156,7 @@ int balance(lub_list_t *cpus, lub_list_t *balance_irqs, float threshold)
 		irq = (irq_t *)lub_list_node__get_data(iter);
 		irq = (irq_t *)lub_list_node__get_data(iter);
 		/* Try to find local CPU to move IRQ to.
 		/* Try to find local CPU to move IRQ to.
 		   The local CPU is CPU with native NUMA node. */
 		   The local CPU is CPU with native NUMA node. */
-		cpu = choose_cpu(cpus, irq->local_cpus, threshold);
+		cpu = choose_cpu(cpus, &(irq->local_cpus), threshold);
 		/* If local CPU is not found then try to use
 		/* If local CPU is not found then try to use
 		   CPU from another NUMA node. It's better then
 		   CPU from another NUMA node. It's better then
 		   overloaded CPUs. */
 		   overloaded CPUs. */
@@ -166,7 +166,7 @@ int balance(lub_list_t *cpus, lub_list_t *balance_irqs, float threshold)
 /*		if (!cpu) {
 /*		if (!cpu) {
 			cpumask_t complement;
 			cpumask_t complement;
 			cpus_complement(complement, irq->local_cpus);
 			cpus_complement(complement, irq->local_cpus);
-			cpu = choose_cpu(cpus, complement, threshold);
+			cpu = choose_cpu(cpus, &complement, threshold);
 		}
 		}
 */
 */
 		if (cpu) {
 		if (cpu) {
@@ -192,7 +192,7 @@ int apply_affinity(lub_list_t *balance_irqs)
 		irq = (irq_t *)lub_list_node__get_data(iter);
 		irq = (irq_t *)lub_list_node__get_data(iter);
 		if (!irq->cpu)
 		if (!irq->cpu)
 			continue;
 			continue;
-		irq_set_affinity(irq, irq->cpu->cpumask);
+		irq_set_affinity(irq, &(irq->cpu->cpumask));
 	}
 	}
 	return 0;
 	return 0;
 }
 }

+ 4 - 3
cpu.c

@@ -65,7 +65,7 @@ static void cpu_free(cpu_t *cpu)
    We don't want to use HT for IRQ balancing. */
    We don't want to use HT for IRQ balancing. */
 static cpu_t * cpu_list_search_ht(lub_list_t *cpus,
 static cpu_t * cpu_list_search_ht(lub_list_t *cpus,
 	unsigned int package_id, unsigned int core_id,
 	unsigned int package_id, unsigned int core_id,
-	cpumask_t thread_siblings)
+	cpumask_t *thread_siblings)
 {
 {
 	lub_list_node_t *iter;
 	lub_list_node_t *iter;
 
 
@@ -75,7 +75,7 @@ static cpu_t * cpu_list_search_ht(lub_list_t *cpus,
 	   two CPUs with the same package and core ids but
 	   two CPUs with the same package and core ids but
 	   has no thread siblings. Don't consider such CPUs as
 	   has no thread siblings. Don't consider such CPUs as
 	   a hyper threading. */
 	   a hyper threading. */
-	if (cpus_weight(thread_siblings) < 2)
+	if (cpus_weight(*thread_siblings) < 2)
 		return NULL;
 		return NULL;
 
 
 	for (iter = lub_list_iterator_init(cpus); iter;
 	for (iter = lub_list_iterator_init(cpus); iter;
@@ -202,7 +202,8 @@ int scan_cpus(lub_list_t *cpus, int ht)
 		}
 		}
 
 
 		/* Don't use second thread of Hyper Threading */
 		/* Don't use second thread of Hyper Threading */
-		if (!ht && cpu_list_search_ht(cpus, package_id, core_id, thread_siblings))
+		if (!ht && cpu_list_search_ht(cpus, package_id, core_id,
+			&thread_siblings))
 			continue;
 			continue;
 
 
 		new = cpu_new(id);
 		new = cpu_new(id);