linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations
@ 2016-09-10  9:30 SF Markus Elfring
  2016-09-10  9:35 ` [PATCH 1/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_performance_states() SF Markus Elfring
                   ` (31 more replies)
  0 siblings, 32 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:30 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 9 Sep 2016 20:15:05 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (30):
  Use kmalloc_array() in acpi_processor_get_performance_states()
  Improve two size determinations in acpi_processor_get_performance_states()
  Rename jump labels in acpi_processor_get_performance_states()
  Delete two unnecessary initialisations in acpi_processor_get_performance_states()
  Rename jump labels in acpi_processor_preregister_performance()
  Move a success indication in acpi_processor_preregister_performance()
  Rename jump labels in acpi_processor_get_psd()
  Delete two unnecessary initialisations in acpi_processor_get_psd()
  Improve a size determination in acpi_processor_get_psd()
  Rename jump labels in acpi_processor_get_performance_control()
  Delete two unnecessary initialisations in acpi_processor_get_performance_control()
  Rename jump labels in acpi_processor_ppc_notifier()
  Delete an unnecessary initialisation in acpi_processor_ppc_notifier()
  Delete an unnecessary initialisation in acpi_processor_get_performance_info()
  Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
  Use kmalloc_array() in acpi_processor_get_throttling_states()
  Improve another size determination in acpi_processor_get_throttling_states()
  Rename jump labels in acpi_processor_get_throttling_states()
  Delete two unnecessary initialisations in acpi_processor_get_throttling_states()
  Fix jump targets in acpi_processor_get_throttling_info()
  Rename jump labels in acpi_processor_get_tsd()
  Delete two unnecessary initialisations in acpi_processor_get_tsd()
  Improve a size determination in acpi_processor_get_tsd()
  Rename jump labels in acpi_processor_get_throttling_control()
  Delete two unnecessary initialisations in acpi_processor_get_throttling_control()
  Fix jump targets in acpi_processor_reevaluate_tstate()
  Delete an unnecessary initialisation in acpi_processor_reevaluate_tstate()
  Rename a jump label in acpi_processor_get_platform_limit()
  Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
  Improve jump targets in acpi_processor_update_tsd_coord()

 drivers/acpi/processor_perflib.c    |  87 +++++++++++++--------------
 drivers/acpi/processor_throttling.c | 116 ++++++++++++++++--------------------
 2 files changed, 93 insertions(+), 110 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 1/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_performance_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-10  9:35 ` SF Markus Elfring
  2016-09-10  9:36 ` [PATCH 2/30] ACPI-processor: Improve two size determinations " SF Markus Elfring
                   ` (30 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:35 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 10:20:10 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus reuse the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index bb01dea..78f9025 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -346,9 +346,9 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 			  pss->package.count));
 
 	pr->performance->state_count = pss->package.count;
-	pr->performance->states =
-	    kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
-		    GFP_KERNEL);
+	pr->performance->states = kmalloc_array(pss->package.count,
+						sizeof(*pr->performance->states),
+						GFP_KERNEL);
 	if (!pr->performance->states) {
 		result = -ENOMEM;
 		goto end;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 2/30] ACPI-processor: Improve two size determinations in acpi_processor_get_performance_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-10  9:35 ` [PATCH 1/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_performance_states() SF Markus Elfring
@ 2016-09-10  9:36 ` SF Markus Elfring
  2016-09-10 11:47   ` Borislav Petkov
  2016-09-10  9:40 ` [PATCH 03/30] ACPI-processor: Rename jump labels " SF Markus Elfring
                   ` (29 subsequent siblings)
  31 siblings, 1 reply; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:36 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 11:11:12 +0200

Replace the specification of a data structure by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 78f9025..004e24c 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -358,7 +358,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 
 		struct acpi_processor_px *px = &(pr->performance->states[i]);
 
-		state.length = sizeof(struct acpi_processor_px);
+		state.length = sizeof(*px);
 		state.pointer = px;
 
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
@@ -400,7 +400,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 				 * Copy this valid entry over last_invalid entry
 				 */
 				memcpy(&(pr->performance->states[last_invalid]),
-				       px, sizeof(struct acpi_processor_px));
+				       px,
+				       sizeof(*px));
 				++last_invalid;
 			}
 		}
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 03/30] ACPI-processor: Rename jump labels in acpi_processor_get_performance_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-10  9:35 ` [PATCH 1/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_performance_states() SF Markus Elfring
  2016-09-10  9:36 ` [PATCH 2/30] ACPI-processor: Improve two size determinations " SF Markus Elfring
@ 2016-09-10  9:40 ` SF Markus Elfring
  2016-09-10  9:41 ` [PATCH 04/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
                   ` (28 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:40 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 11:27:45 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 004e24c..49889b1 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -339,7 +339,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 	if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
 		printk(KERN_ERR PREFIX "Invalid _PSS data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n",
@@ -351,7 +351,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 						GFP_KERNEL);
 	if (!pr->performance->states) {
 		result = -ENOMEM;
-		goto end;
+		goto free_buffer;
 	}
 
 	for (i = 0; i < pr->performance->state_count; i++) {
@@ -369,7 +369,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 			ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
 			result = -EFAULT;
 			kfree(pr->performance->states);
-			goto end;
+			goto free_buffer;
 		}
 
 		amd_fixup_frequency(px, i);
@@ -417,8 +417,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 
 	if (last_invalid > 0)
 		pr->performance->state_count = last_invalid;
-
-      end:
+ free_buffer:
 	kfree(buffer.pointer);
 
 	return result;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 04/30] ACPI-processor: Delete two unnecessary initialisations in acpi_processor_get_performance_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2016-09-10  9:40 ` [PATCH 03/30] ACPI-processor: Rename jump labels " SF Markus Elfring
@ 2016-09-10  9:41 ` SF Markus Elfring
  2016-09-10  9:42 ` [PATCH 05/30] ACPI-processor: Rename jump labels in acpi_processor_preregister_performance() SF Markus Elfring
                   ` (27 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:41 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 11:48:52 +0200

The local variables "pss" and "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 49889b1..1ebe580 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -320,11 +320,11 @@ static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
 static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 {
 	int result = 0;
-	acpi_status status = AE_OK;
+	acpi_status status;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_buffer format = { sizeof("NNNNNN"), "NNNNNN" };
 	struct acpi_buffer state = { 0, NULL };
-	union acpi_object *pss = NULL;
+	union acpi_object *pss;
 	int i;
 	int last_invalid = -1;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 05/30] ACPI-processor: Rename jump labels in acpi_processor_preregister_performance()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (3 preceding siblings ...)
  2016-09-10  9:41 ` [PATCH 04/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
@ 2016-09-10  9:42 ` SF Markus Elfring
  2016-09-10  9:44 ` [PATCH 06/30] ACPI-processor: Move a success indication " SF Markus Elfring
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:42 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 12:38:40 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 1ebe580..2fc82e7 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -621,12 +621,12 @@ int acpi_processor_preregister_performance(
 
 		if (pr->performance) {
 			retval = -EBUSY;
-			goto err_out;
+			goto unlock;
 		}
 
 		if (!performance || !per_cpu_ptr(performance, i)) {
 			retval = -EINVAL;
-			goto err_out;
+			goto unlock;
 		}
 	}
 
@@ -644,7 +644,7 @@ int acpi_processor_preregister_performance(
 		}
 	}
 	if (retval)
-		goto err_ret;
+		goto clear_cpu;
 
 	/*
 	 * Now that we have _PSD data from all CPUs, lets setup P-state 
@@ -689,12 +689,12 @@ int acpi_processor_preregister_performance(
 
 			if (match_pdomain->num_processors != count_target) {
 				retval = -EINVAL;
-				goto err_ret;
+				goto clear_cpu;
 			}
 
 			if (pdomain->coord_type != match_pdomain->coord_type) {
 				retval = -EINVAL;
-				goto err_ret;
+				goto clear_cpu;
 			}
 
 			cpumask_set_cpu(j, covered_cpus);
@@ -719,8 +719,7 @@ int acpi_processor_preregister_performance(
 				     pr->performance->shared_cpu_map);
 		}
 	}
-
-err_ret:
+ clear_cpu:
 	for_each_possible_cpu(i) {
 		pr = per_cpu(processors, i);
 		if (!pr || !pr->performance)
@@ -734,8 +733,7 @@ err_ret:
 		}
 		pr->performance = NULL; /* Will be set for real in register */
 	}
-
-err_out:
+ unlock:
 	mutex_unlock(&performance_mutex);
 	free_cpumask_var(covered_cpus);
 	return retval;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 06/30] ACPI-processor: Move a success indication in acpi_processor_preregister_performance()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (4 preceding siblings ...)
  2016-09-10  9:42 ` [PATCH 05/30] ACPI-processor: Rename jump labels in acpi_processor_preregister_performance() SF Markus Elfring
@ 2016-09-10  9:44 ` SF Markus Elfring
  2016-09-10  9:45 ` [PATCH 07/30] ACPI-processor: Rename jump labels in acpi_processor_get_psd() SF Markus Elfring
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:44 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 13:03:56 +0200

The local variable "retval" was initialised with a zero at the beginning
as an indication for a successful function execution despite of
the possibility that following function calls could fail.
Move the desired assignment down to the source code place where some system
clean-up is performed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 2fc82e7..417e181 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -595,7 +595,7 @@ int acpi_processor_preregister_performance(
 		struct acpi_processor_performance __percpu *performance)
 {
 	int count_target;
-	int retval = 0;
+	int retval;
 	unsigned int i, j;
 	cpumask_var_t covered_cpus;
 	struct acpi_processor *pr;
@@ -719,6 +719,8 @@ int acpi_processor_preregister_performance(
 				     pr->performance->shared_cpu_map);
 		}
 	}
+
+	retval = 0;
  clear_cpu:
 	for_each_possible_cpu(i) {
 		pr = per_cpu(processors, i);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 07/30] ACPI-processor: Rename jump labels in acpi_processor_get_psd()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (5 preceding siblings ...)
  2016-09-10  9:44 ` [PATCH 06/30] ACPI-processor: Move a success indication " SF Markus Elfring
@ 2016-09-10  9:45 ` SF Markus Elfring
  2016-09-10  9:48 ` [PATCH 08/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
                   ` (24 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:45 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 13:50:41 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 417e181..c2813cc 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -545,13 +545,13 @@ static int acpi_processor_get_psd(struct acpi_processor	*pr)
 	if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
 		printk(KERN_ERR PREFIX "Invalid _PSD data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (psd->package.count != 1) {
 		printk(KERN_ERR PREFIX "Invalid _PSD data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	pdomain = &(pr->performance->domain_info);
@@ -564,19 +564,19 @@ static int acpi_processor_get_psd(struct acpi_processor	*pr)
 	if (ACPI_FAILURE(status)) {
 		printk(KERN_ERR PREFIX "Invalid _PSD data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
 		printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
 		printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL &&
@@ -584,9 +584,8 @@ static int acpi_processor_get_psd(struct acpi_processor	*pr)
 	    pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) {
 		printk(KERN_ERR PREFIX "Invalid _PSD:coord_type\n");
 		result = -EFAULT;
-		goto end;
 	}
-end:
+ free_buffer:
 	kfree(buffer.pointer);
 	return result;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 08/30] ACPI-processor: Delete two unnecessary initialisations in acpi_processor_get_psd()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (6 preceding siblings ...)
  2016-09-10  9:45 ` [PATCH 07/30] ACPI-processor: Rename jump labels in acpi_processor_get_psd() SF Markus Elfring
@ 2016-09-10  9:48 ` SF Markus Elfring
  2016-09-10  9:50 ` [PATCH 09/30] ACPI-processor: Improve a size determination " SF Markus Elfring
                   ` (23 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:48 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 13:55:52 +0200

The local variables "psd" and "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index c2813cc..3f94279 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -529,11 +529,11 @@ EXPORT_SYMBOL(acpi_processor_notify_smm);
 static int acpi_processor_get_psd(struct acpi_processor	*pr)
 {
 	int result = 0;
-	acpi_status status = AE_OK;
+	acpi_status status;
 	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
 	struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
 	struct acpi_buffer state = {0, NULL};
-	union acpi_object  *psd = NULL;
+	union acpi_object  *psd;
 	struct acpi_psd_package *pdomain;
 
 	status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 09/30] ACPI-processor: Improve a size determination in acpi_processor_get_psd()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (7 preceding siblings ...)
  2016-09-10  9:48 ` [PATCH 08/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
@ 2016-09-10  9:50 ` SF Markus Elfring
  2016-09-10  9:51 ` [PATCH 10/30] ACPI-processor: Rename jump labels in acpi_processor_get_performance_control() SF Markus Elfring
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:50 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 18:48:37 +0200

Replace the specification of a data structure by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 3f94279..b7e2f51 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -556,7 +556,7 @@ static int acpi_processor_get_psd(struct acpi_processor	*pr)
 
 	pdomain = &(pr->performance->domain_info);
 
-	state.length = sizeof(struct acpi_psd_package);
+	state.length = sizeof(*pdomain);
 	state.pointer = pdomain;
 
 	status = acpi_extract_package(&(psd->package.elements[0]),
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 10/30] ACPI-processor: Rename jump labels in acpi_processor_get_performance_control()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (8 preceding siblings ...)
  2016-09-10  9:50 ` [PATCH 09/30] ACPI-processor: Improve a size determination " SF Markus Elfring
@ 2016-09-10  9:51 ` SF Markus Elfring
  2016-09-10  9:52 ` [PATCH 11/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
                   ` (21 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:51 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 18:50:48 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index b7e2f51..3a48c3a 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -240,7 +240,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
 	    || (pct->package.count != 2)) {
 		printk(KERN_ERR PREFIX "Invalid _PCT data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	/*
@@ -254,7 +254,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
 	    || (obj.buffer.pointer == NULL)) {
 		printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 	memcpy(&pr->performance->control_register, obj.buffer.pointer,
 	       sizeof(struct acpi_pct_register));
@@ -270,13 +270,12 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
 	    || (obj.buffer.pointer == NULL)) {
 		printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	memcpy(&pr->performance->status_register, obj.buffer.pointer,
 	       sizeof(struct acpi_pct_register));
-
-      end:
+ free_buffer:
 	kfree(buffer.pointer);
 
 	return result;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 11/30] ACPI-processor: Delete two unnecessary initialisations in acpi_processor_get_performance_control()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (9 preceding siblings ...)
  2016-09-10  9:51 ` [PATCH 10/30] ACPI-processor: Rename jump labels in acpi_processor_get_performance_control() SF Markus Elfring
@ 2016-09-10  9:52 ` SF Markus Elfring
  2016-09-10  9:54 ` [PATCH 12/30] ACPI-processor: Rename jump labels in acpi_processor_ppc_notifier() SF Markus Elfring
                   ` (20 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:52 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:01:36 +0200

The local variables "pct" and "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 3a48c3a..07e5e59 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -223,9 +223,9 @@ void acpi_processor_ppc_exit(void)
 static int acpi_processor_get_performance_control(struct acpi_processor *pr)
 {
 	int result = 0;
-	acpi_status status = 0;
+	acpi_status status;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *pct = NULL;
+	union acpi_object *pct;
 	union acpi_object obj = { 0 };
 
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 12/30] ACPI-processor: Rename jump labels in acpi_processor_ppc_notifier()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (10 preceding siblings ...)
  2016-09-10  9:52 ` [PATCH 11/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
@ 2016-09-10  9:54 ` SF Markus Elfring
  2016-09-10  9:55 ` [PATCH 13/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
                   ` (19 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:54 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:04:05 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 07e5e59..86256bd 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -90,18 +90,17 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
 
 	pr = per_cpu(processors, policy->cpu);
 	if (!pr || !pr->performance)
-		goto out;
+		goto unlock;
 
 	ppc = (unsigned int)pr->performance_platform_limit;
 
 	if (ppc >= pr->performance->state_count)
-		goto out;
+		goto unlock;
 
 	cpufreq_verify_within_limits(policy, 0,
 				     pr->performance->states[ppc].
 				     core_frequency * 1000);
-
-      out:
+ unlock:
 	mutex_unlock(&performance_mutex);
 
 	return 0;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 13/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_ppc_notifier()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (11 preceding siblings ...)
  2016-09-10  9:54 ` [PATCH 12/30] ACPI-processor: Rename jump labels in acpi_processor_ppc_notifier() SF Markus Elfring
@ 2016-09-10  9:55 ` SF Markus Elfring
  2016-09-10  9:55 ` [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations Paolo Bonzini
                   ` (18 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:55 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:06:18 +0200

The local variable "ppc" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 86256bd..43f8eef 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -73,7 +73,7 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
 {
 	struct cpufreq_policy *policy = data;
 	struct acpi_processor *pr;
-	unsigned int ppc = 0;
+	unsigned int ppc;
 
 	if (event == CPUFREQ_START && ignore_ppc <= 0) {
 		ignore_ppc = 0;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (12 preceding siblings ...)
  2016-09-10  9:55 ` [PATCH 13/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-10  9:55 ` Paolo Bonzini
  2016-09-10  9:56 ` [PATCH 14/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_performance_info() SF Markus Elfring
                   ` (17 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Paolo Bonzini @ 2016-09-10  9:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-acpi, Len Brown, Rafael J. Wysocki, LKML, kernel-janitors

I have nothing to do with ACPI.  Please stop spamming me, or you'll end
up on a kill file...

Paolo

----- Original Message -----
> From: "SF Markus Elfring" <elfring@users.sourceforge.net>
> To: linux-acpi@vger.kernel.org, "Len Brown" <lenb@kernel.org>, "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: "LKML" <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org, "Julia Lawall" <julia.lawall@lip6.fr>,
> "Paolo Bonzini" <pbonzini@redhat.com>
> Sent: Saturday, September 10, 2016 11:30:08 AM
> Subject: [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 9 Sep 2016 20:15:05 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (30):
>   Use kmalloc_array() in acpi_processor_get_performance_states()
>   Improve two size determinations in acpi_processor_get_performance_states()
>   Rename jump labels in acpi_processor_get_performance_states()
>   Delete two unnecessary initialisations in
>   acpi_processor_get_performance_states()
>   Rename jump labels in acpi_processor_preregister_performance()
>   Move a success indication in acpi_processor_preregister_performance()
>   Rename jump labels in acpi_processor_get_psd()
>   Delete two unnecessary initialisations in acpi_processor_get_psd()
>   Improve a size determination in acpi_processor_get_psd()
>   Rename jump labels in acpi_processor_get_performance_control()
>   Delete two unnecessary initialisations in
>   acpi_processor_get_performance_control()
>   Rename jump labels in acpi_processor_ppc_notifier()
>   Delete an unnecessary initialisation in acpi_processor_ppc_notifier()
>   Delete an unnecessary initialisation in
>   acpi_processor_get_performance_info()
>   Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
>   Use kmalloc_array() in acpi_processor_get_throttling_states()
>   Improve another size determination in
>   acpi_processor_get_throttling_states()
>   Rename jump labels in acpi_processor_get_throttling_states()
>   Delete two unnecessary initialisations in
>   acpi_processor_get_throttling_states()
>   Fix jump targets in acpi_processor_get_throttling_info()
>   Rename jump labels in acpi_processor_get_tsd()
>   Delete two unnecessary initialisations in acpi_processor_get_tsd()
>   Improve a size determination in acpi_processor_get_tsd()
>   Rename jump labels in acpi_processor_get_throttling_control()
>   Delete two unnecessary initialisations in
>   acpi_processor_get_throttling_control()
>   Fix jump targets in acpi_processor_reevaluate_tstate()
>   Delete an unnecessary initialisation in acpi_processor_reevaluate_tstate()
>   Rename a jump label in acpi_processor_get_platform_limit()
>   Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
>   Improve jump targets in acpi_processor_update_tsd_coord()
> 
>  drivers/acpi/processor_perflib.c    |  87 +++++++++++++--------------
>  drivers/acpi/processor_throttling.c | 116
>  ++++++++++++++++--------------------
>  2 files changed, 93 insertions(+), 110 deletions(-)
> 
> --
> 2.10.0
> 
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 14/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_performance_info()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (13 preceding siblings ...)
  2016-09-10  9:55 ` [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations Paolo Bonzini
@ 2016-09-10  9:56 ` SF Markus Elfring
  2016-09-10  9:57 ` [PATCH 15/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_platform_limit() SF Markus Elfring
                   ` (16 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:56 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:09:32 +0200

The local variable "result" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 43f8eef..de82338 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -423,7 +423,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 
 int acpi_processor_get_performance_info(struct acpi_processor *pr)
 {
-	int result = 0;
+	int result;
 
 	if (!pr || !pr->performance || !pr->handle)
 		return -EINVAL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 15/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (14 preceding siblings ...)
  2016-09-10  9:56 ` [PATCH 14/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_performance_info() SF Markus Elfring
@ 2016-09-10  9:57 ` SF Markus Elfring
  2016-09-10  9:58 ` [PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states() SF Markus Elfring
                   ` (15 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:57 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:12:06 +0200

The local variable "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_perflib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index de82338..bab5a564d 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -112,7 +112,7 @@ static struct notifier_block acpi_ppc_notifier_block = {
 
 static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
 {
-	acpi_status status = 0;
+	acpi_status status;
 	unsigned long long ppc = 0;
 
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (15 preceding siblings ...)
  2016-09-10  9:57 ` [PATCH 15/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_platform_limit() SF Markus Elfring
@ 2016-09-10  9:58 ` SF Markus Elfring
  2016-09-10  9:59 ` [PATCH 17/30] ACPI-processor: Improve another size determination " SF Markus Elfring
                   ` (14 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:58 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:15:02 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus reuse the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index c72e648..0a46b7f 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -533,9 +533,10 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 			  tss->package.count));
 
 	pr->throttling.state_count = tss->package.count;
-	pr->throttling.states_tss =
-	    kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
-		    GFP_KERNEL);
+	pr->throttling.states_tss = kmalloc_array(tss->package.count,
+						  sizeof(*pr->
+							 throttling.states_tss),
+						  GFP_KERNEL);
 	if (!pr->throttling.states_tss) {
 		result = -ENOMEM;
 		goto end;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 17/30] ACPI-processor: Improve another size determination in acpi_processor_get_throttling_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (16 preceding siblings ...)
  2016-09-10  9:58 ` [PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states() SF Markus Elfring
@ 2016-09-10  9:59 ` SF Markus Elfring
  2016-09-10 10:00 ` [PATCH 18/30] ACPI-processor: Rename jump labels " SF Markus Elfring
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:59 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:19:27 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 0a46b7f..c5ddf96 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -548,7 +548,7 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 		    (struct acpi_processor_tx_tss *)&(pr->throttling.
 						      states_tss[i]);
 
-		state.length = sizeof(struct acpi_processor_tx_tss);
+		state.length = sizeof(*tx);
 		state.pointer = tx;
 
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 18/30] ACPI-processor: Rename jump labels in acpi_processor_get_throttling_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (17 preceding siblings ...)
  2016-09-10  9:59 ` [PATCH 17/30] ACPI-processor: Improve another size determination " SF Markus Elfring
@ 2016-09-10 10:00 ` SF Markus Elfring
  2016-09-10 10:01 ` [PATCH 19/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
                   ` (12 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:00 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 19:26:33 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index c5ddf96..665e8de 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -526,7 +526,7 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 	if (!tss || (tss->type != ACPI_TYPE_PACKAGE)) {
 		printk(KERN_ERR PREFIX "Invalid _TSS data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
@@ -539,7 +539,7 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 						  GFP_KERNEL);
 	if (!pr->throttling.states_tss) {
 		result = -ENOMEM;
-		goto end;
+		goto free_buffer;
 	}
 
 	for (i = 0; i < pr->throttling.state_count; i++) {
@@ -559,7 +559,7 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 			ACPI_EXCEPTION((AE_INFO, status, "Invalid _TSS data"));
 			result = -EFAULT;
 			kfree(pr->throttling.states_tss);
-			goto end;
+			goto free_buffer;
 		}
 
 		if (!tx->freqpercentage) {
@@ -567,11 +567,10 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 			       "Invalid _TSS data: freq is zero\n");
 			result = -EFAULT;
 			kfree(pr->throttling.states_tss);
-			goto end;
+			goto free_buffer;
 		}
 	}
-
-      end:
+ free_buffer:
 	kfree(buffer.pointer);
 
 	return result;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 19/30] ACPI-processor: Delete two unnecessary initialisations in acpi_processor_get_throttling_states()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (18 preceding siblings ...)
  2016-09-10 10:00 ` [PATCH 18/30] ACPI-processor: Rename jump labels " SF Markus Elfring
@ 2016-09-10 10:01 ` SF Markus Elfring
  2016-09-10 10:02 ` [PATCH 20/30] ACPI-processor: Fix jump targets in acpi_processor_get_throttling_info() SF Markus Elfring
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:01 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 20:00:43 +0200

The local variables "tss" and "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 665e8de..8847bca 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -507,11 +507,11 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 {
 	int result = 0;
-	acpi_status status = AE_OK;
+	acpi_status status;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
 	struct acpi_buffer state = { 0, NULL };
-	union acpi_object *tss = NULL;
+	union acpi_object *tss;
 	int i;
 
 	status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 20/30] ACPI-processor: Fix jump targets in acpi_processor_get_throttling_info()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (19 preceding siblings ...)
  2016-09-10 10:01 ` [PATCH 19/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
@ 2016-09-10 10:02 ` SF Markus Elfring
  2016-09-10 10:03 ` [PATCH 21/30] ACPI-processor: Rename jump labels in acpi_processor_get_tsd() SF Markus Elfring
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:02 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 20:32:46 +0200

1. Adjust jump targets according to the current Linux coding
   style convention.

2. Delete a duplicate check then at the end.

3. Omit the explicit initialisation for the local variable "result"
   at the beginning which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 8847bca..24bd97f 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -1184,7 +1184,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
 
 int acpi_processor_get_throttling_info(struct acpi_processor *pr)
 {
-	int result = 0;
+	int result;
 	struct acpi_processor_throttling *pthrottling;
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -1249,7 +1249,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
 
 	result = acpi_processor_get_throttling(pr);
 	if (result)
-		goto end;
+		goto disable_throttling;
 
 	if (pr->throttling.state) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -1257,13 +1257,11 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
 				  pr->throttling.state));
 		result = acpi_processor_set_throttling(pr, 0, false);
 		if (result)
-			goto end;
+			goto disable_throttling;
 	}
-
-      end:
-	if (result)
-		pr->flags.throttling = 0;
-
+	return 0;
+ disable_throttling:
+	pr->flags.throttling = 0;
 	return result;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 21/30] ACPI-processor: Rename jump labels in acpi_processor_get_tsd()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (20 preceding siblings ...)
  2016-09-10 10:02 ` [PATCH 20/30] ACPI-processor: Fix jump targets in acpi_processor_get_throttling_info() SF Markus Elfring
@ 2016-09-10 10:03 ` SF Markus Elfring
  2016-09-10 10:04 ` [PATCH 22/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
                   ` (9 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:03 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 20:50:12 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 24bd97f..2e3ef48 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -605,13 +605,13 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
 	if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) {
 		printk(KERN_ERR PREFIX "Invalid _TSD data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (tsd->package.count != 1) {
 		printk(KERN_ERR PREFIX "Invalid _TSD data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	pdomain = &(pr->throttling.domain_info);
@@ -624,19 +624,19 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
 	if (ACPI_FAILURE(status)) {
 		printk(KERN_ERR PREFIX "Invalid _TSD data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) {
 		printk(KERN_ERR PREFIX "Unknown _TSD:num_entries\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if (pdomain->revision != ACPI_TSD_REV0_REVISION) {
 		printk(KERN_ERR PREFIX "Unknown _TSD:revision\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	pthrottling = &pr->throttling;
@@ -654,8 +654,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
 		pthrottling->tsd_valid_flag = 0;
 		pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
 	}
-
-      end:
+ free_buffer:
 	kfree(buffer.pointer);
 	return result;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 22/30] ACPI-processor: Delete two unnecessary initialisations in acpi_processor_get_tsd()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (21 preceding siblings ...)
  2016-09-10 10:03 ` [PATCH 21/30] ACPI-processor: Rename jump labels in acpi_processor_get_tsd() SF Markus Elfring
@ 2016-09-10 10:04 ` SF Markus Elfring
  2016-09-10 10:05 ` [PATCH 23/30] ACPI-processor: Improve a size determination " SF Markus Elfring
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:04 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 20:52:33 +0200

The local variables "tsd" and "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 2e3ef48..ea1e959 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -582,11 +582,11 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 static int acpi_processor_get_tsd(struct acpi_processor *pr)
 {
 	int result = 0;
-	acpi_status status = AE_OK;
+	acpi_status status;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
 	struct acpi_buffer state = { 0, NULL };
-	union acpi_object *tsd = NULL;
+	union acpi_object *tsd;
 	struct acpi_tsd_package *pdomain;
 	struct acpi_processor_throttling *pthrottling;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 23/30] ACPI-processor: Improve a size determination in acpi_processor_get_tsd()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (22 preceding siblings ...)
  2016-09-10 10:04 ` [PATCH 22/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
@ 2016-09-10 10:05 ` SF Markus Elfring
  2016-09-10 10:06 ` [PATCH 24/30] ACPI-processor: Rename jump labels in acpi_processor_get_throttling_control() SF Markus Elfring
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:05 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 20:55:45 +0200

Replace the specification of a data structure by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index ea1e959..dcebb4b2 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -616,7 +616,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
 
 	pdomain = &(pr->throttling.domain_info);
 
-	state.length = sizeof(struct acpi_tsd_package);
+	state.length = sizeof(*pdomain);
 	state.pointer = pdomain;
 
 	status = acpi_extract_package(&(tsd->package.elements[0]),
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 24/30] ACPI-processor: Rename jump labels in acpi_processor_get_throttling_control()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (23 preceding siblings ...)
  2016-09-10 10:05 ` [PATCH 23/30] ACPI-processor: Improve a size determination " SF Markus Elfring
@ 2016-09-10 10:06 ` SF Markus Elfring
  2016-09-10 10:07 ` [PATCH 25/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
                   ` (6 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:06 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 21:12:17 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index dcebb4b2..cdcd5d6f 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -442,7 +442,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 	    || (ptc->package.count != 2)) {
 		printk(KERN_ERR PREFIX "Invalid _PTC data\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	/*
@@ -457,7 +457,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 		printk(KERN_ERR PREFIX
 		       "Invalid _PTC data (control_register)\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 	memcpy(&pr->throttling.control_register, obj.buffer.pointer,
 	       sizeof(struct acpi_ptc_register));
@@ -473,7 +473,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 	    || (obj.buffer.pointer == NULL)) {
 		printk(KERN_ERR PREFIX "Invalid _PTC data (status_register)\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	memcpy(&pr->throttling.status_register, obj.buffer.pointer,
@@ -485,17 +485,15 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 		throttling->control_register.bit_offset) > 32) {
 		printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
 		result = -EFAULT;
-		goto end;
+		goto free_buffer;
 	}
 
 	if ((throttling->status_register.bit_width +
 		throttling->status_register.bit_offset) > 32) {
 		printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
 		result = -EFAULT;
-		goto end;
 	}
-
-      end:
+ free_buffer:
 	kfree(buffer.pointer);
 
 	return result;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 25/30] ACPI-processor: Delete two unnecessary initialisations in acpi_processor_get_throttling_control()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (24 preceding siblings ...)
  2016-09-10 10:06 ` [PATCH 24/30] ACPI-processor: Rename jump labels in acpi_processor_get_throttling_control() SF Markus Elfring
@ 2016-09-10 10:07 ` SF Markus Elfring
  2016-09-10 10:08 ` [PATCH 26/30] ACPI-processor: Fix jump targets in acpi_processor_reevaluate_tstate() SF Markus Elfring
                   ` (5 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:07 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 21:17:12 +0200

The local variables "ptc" and "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index cdcd5d6f..0b4e058 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -423,9 +423,9 @@ end:
 static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
 {
 	int result = 0;
-	acpi_status status = 0;
+	acpi_status status;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *ptc = NULL;
+	union acpi_object *ptc;
 	union acpi_object obj = { 0 };
 	struct acpi_processor_throttling *throttling;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 26/30] ACPI-processor: Fix jump targets in acpi_processor_reevaluate_tstate()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (25 preceding siblings ...)
  2016-09-10 10:07 ` [PATCH 25/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
@ 2016-09-10 10:08 ` SF Markus Elfring
  2016-09-10 10:09 ` [PATCH 27/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
                   ` (4 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:08 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 21:40:40 +0200

1. Adjust jump targets according to the current Linux coding
   style convention.

2. Delete a duplicate check then at the end.

3. Do not use curly brackets at two source code places
   where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 0b4e058..994f21c 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -379,23 +379,19 @@ void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
 {
 	int result = 0;
 
-	if (action == CPU_DEAD) {
+	if (action == CPU_DEAD)
 		/* When one CPU is offline, the T-state throttling
 		 * will be invalidated.
 		 */
-		pr->flags.throttling = 0;
-		return;
-	}
+		goto disable_throttling;
 	/* the following is to recheck whether the T-state is valid for
 	 * the online CPU
 	 */
-	if (!pr->throttling.state_count) {
+	if (!pr->throttling.state_count)
 		/* If the number of T-state is invalid, it is
 		 * invalidated.
 		 */
-		pr->flags.throttling = 0;
-		return;
-	}
+		goto disable_throttling;
 	pr->flags.throttling = 1;
 
 	/* Disable throttling (if enabled).  We'll let subsequent
@@ -405,17 +401,16 @@ void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
 
 	result = acpi_processor_get_throttling(pr);
 	if (result)
-		goto end;
+		goto disable_throttling;
 
 	if (pr->throttling.state) {
 		result = acpi_processor_set_throttling(pr, 0, false);
 		if (result)
-			goto end;
+			goto disable_throttling;
 	}
-
-end:
-	if (result)
-		pr->flags.throttling = 0;
+	return;
+ disable_throttling:
+	pr->flags.throttling = 0;
 }
 /*
  * _PTC - Processor Throttling Control (and status) register location
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 27/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_reevaluate_tstate()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (26 preceding siblings ...)
  2016-09-10 10:08 ` [PATCH 26/30] ACPI-processor: Fix jump targets in acpi_processor_reevaluate_tstate() SF Markus Elfring
@ 2016-09-10 10:09 ` SF Markus Elfring
  2016-09-10 10:10 ` [PATCH 28/30] ACPI-processor: Rename a jump label in acpi_processor_get_platform_limit() SF Markus Elfring
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:09 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 21:42:34 +0200

The local variable "result" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 994f21c..d22bcfc 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -377,7 +377,7 @@ int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
 void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
 					unsigned long action)
 {
-	int result = 0;
+	int result;
 
 	if (action == CPU_DEAD)
 		/* When one CPU is offline, the T-state throttling
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 28/30] ACPI-processor: Rename a jump label in acpi_processor_get_platform_limit()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (27 preceding siblings ...)
  2016-09-10 10:09 ` [PATCH 27/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-10 10:10 ` SF Markus Elfring
  2016-09-10 10:11 ` [PATCH 29/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
                   ` (2 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:10 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 21:50:04 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index d22bcfc..7e54a83 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -294,7 +294,7 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
 		return -EINVAL;
 
 	if (ignore_tpc)
-		goto end;
+		goto limit_throttling;
 
 	status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc);
 	if (ACPI_FAILURE(status)) {
@@ -303,8 +303,7 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
 		}
 		return -ENODEV;
 	}
-
-end:
+ limit_throttling:
 	pr->throttling_platform_limit = (int)tpc;
 	return 0;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 29/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (28 preceding siblings ...)
  2016-09-10 10:10 ` [PATCH 28/30] ACPI-processor: Rename a jump label in acpi_processor_get_platform_limit() SF Markus Elfring
@ 2016-09-10 10:11 ` SF Markus Elfring
  2016-09-10 10:12 ` [PATCH 30/30] ACPI-processor: Improve jump targets in acpi_processor_update_tsd_coord() SF Markus Elfring
  2017-08-06 10:05 ` [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:11 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 22:00:07 +0200

The local variable "status" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 7e54a83..79ba9b78 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -287,7 +287,7 @@ static int acpi_processor_throttling_notifier(unsigned long event, void *data)
  */
 static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
 {
-	acpi_status status = 0;
+	acpi_status status;
 	unsigned long long tpc = 0;
 
 	if (!pr)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 30/30] ACPI-processor: Improve jump targets in acpi_processor_update_tsd_coord()
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (29 preceding siblings ...)
  2016-09-10 10:11 ` [PATCH 29/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-10 10:12 ` SF Markus Elfring
  2017-08-06 10:05 ` [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2016-09-10 10:12 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Sep 2016 22:18:30 +0200

* Adjust jump targets according to the current Linux coding
  style convention.

* Delete a duplicate check then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/processor_throttling.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 79ba9b78..b45f6c3 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -97,11 +97,9 @@ static int acpi_processor_update_tsd_coord(void)
 		 */
 		if (!pthrottling->tsd_valid_flag) {
 			retval = -EINVAL;
-			break;
+			goto free_cpumask;
 		}
 	}
-	if (retval)
-		goto err_ret;
 
 	for_each_possible_cpu(i) {
 		pr = per_cpu(processors, i);
@@ -147,12 +145,12 @@ static int acpi_processor_update_tsd_coord(void)
 			 */
 			if (match_pdomain->num_processors != count_target) {
 				retval = -EINVAL;
-				goto err_ret;
+				goto free_cpumask;
 			}
 
 			if (pdomain->coord_type != match_pdomain->coord_type) {
 				retval = -EINVAL;
-				goto err_ret;
+				goto free_cpumask;
 			}
 
 			cpumask_set_cpu(j, covered_cpus);
@@ -180,8 +178,7 @@ static int acpi_processor_update_tsd_coord(void)
 				     pthrottling->shared_cpu_map);
 		}
 	}
-
-err_ret:
+ free_cpumask:
 	free_cpumask_var(covered_cpus);
 
 	for_each_possible_cpu(i) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 2/30] ACPI-processor: Improve two size determinations in acpi_processor_get_performance_states()
  2016-09-10  9:36 ` [PATCH 2/30] ACPI-processor: Improve two size determinations " SF Markus Elfring
@ 2016-09-10 11:47   ` Borislav Petkov
  0 siblings, 0 replies; 34+ messages in thread
From: Borislav Petkov @ 2016-09-10 11:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-acpi, Len Brown, Rafael J. Wysocki, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

On Sat, Sep 10, 2016 at 11:36:41AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 6 Sep 2016 11:11:12 +0200
> 
> Replace the specification of a data structure by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/acpi/processor_perflib.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
> index 78f9025..004e24c 100644
> --- a/drivers/acpi/processor_perflib.c
> +++ b/drivers/acpi/processor_perflib.c
> @@ -358,7 +358,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
>  
>  		struct acpi_processor_px *px = &(pr->performance->states[i]);
>  
> -		state.length = sizeof(struct acpi_processor_px);
> +		state.length = sizeof(*px);

How is this better?

Now the person reading the code has to go and lookup what px is in order
to know what its size is and which goes in there. Sure, it is a couple
of lines up but this is not always the case...

>  		state.pointer = px;
>  
>  		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
> @@ -400,7 +400,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
>  				 * Copy this valid entry over last_invalid entry
>  				 */
>  				memcpy(&(pr->performance->states[last_invalid]),
> -				       px, sizeof(struct acpi_processor_px));
> +				       px,
> +				       sizeof(*px));
>  				++last_invalid;

... like here, for example.

In any case, I won't take this one if I were the maintainer.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations
  2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
                   ` (30 preceding siblings ...)
  2016-09-10 10:12 ` [PATCH 30/30] ACPI-processor: Improve jump targets in acpi_processor_update_tsd_coord() SF Markus Elfring
@ 2017-08-06 10:05 ` SF Markus Elfring
  31 siblings, 0 replies; 34+ messages in thread
From: SF Markus Elfring @ 2017-08-06 10:05 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki; +Cc: LKML, kernel-janitors

> Date: Tue, 9 Sep 2016 20:15:05 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (30):
>   Use kmalloc_array() in acpi_processor_get_performance_states()
>   Improve two size determinations in acpi_processor_get_performance_states()
>   Rename jump labels in acpi_processor_get_performance_states()
>   Delete two unnecessary initialisations in acpi_processor_get_performance_states()
>   Rename jump labels in acpi_processor_preregister_performance()
>   Move a success indication in acpi_processor_preregister_performance()
>   Rename jump labels in acpi_processor_get_psd()
>   Delete two unnecessary initialisations in acpi_processor_get_psd()
>   Improve a size determination in acpi_processor_get_psd()
>   Rename jump labels in acpi_processor_get_performance_control()
>   Delete two unnecessary initialisations in acpi_processor_get_performance_control()
>   Rename jump labels in acpi_processor_ppc_notifier()
>   Delete an unnecessary initialisation in acpi_processor_ppc_notifier()
>   Delete an unnecessary initialisation in acpi_processor_get_performance_info()
>   Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
>   Use kmalloc_array() in acpi_processor_get_throttling_states()
>   Improve another size determination in acpi_processor_get_throttling_states()
>   Rename jump labels in acpi_processor_get_throttling_states()
>   Delete two unnecessary initialisations in acpi_processor_get_throttling_states()
>   Fix jump targets in acpi_processor_get_throttling_info()
>   Rename jump labels in acpi_processor_get_tsd()
>   Delete two unnecessary initialisations in acpi_processor_get_tsd()
>   Improve a size determination in acpi_processor_get_tsd()
>   Rename jump labels in acpi_processor_get_throttling_control()
>   Delete two unnecessary initialisations in acpi_processor_get_throttling_control()
>   Fix jump targets in acpi_processor_reevaluate_tstate()
>   Delete an unnecessary initialisation in acpi_processor_reevaluate_tstate()
>   Rename a jump label in acpi_processor_get_platform_limit()
>   Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
>   Improve jump targets in acpi_processor_update_tsd_coord()
> 
>  drivers/acpi/processor_perflib.c    |  87 +++++++++++++--------------
>  drivers/acpi/processor_throttling.c | 116 ++++++++++++++++--------------------
>  2 files changed, 93 insertions(+), 110 deletions(-)

How do you think about to take another look at change possibilities
for these source files?

Regards,
Markus

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2017-08-06 10:05 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-10  9:30 [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring
2016-09-10  9:35 ` [PATCH 1/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_performance_states() SF Markus Elfring
2016-09-10  9:36 ` [PATCH 2/30] ACPI-processor: Improve two size determinations " SF Markus Elfring
2016-09-10 11:47   ` Borislav Petkov
2016-09-10  9:40 ` [PATCH 03/30] ACPI-processor: Rename jump labels " SF Markus Elfring
2016-09-10  9:41 ` [PATCH 04/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
2016-09-10  9:42 ` [PATCH 05/30] ACPI-processor: Rename jump labels in acpi_processor_preregister_performance() SF Markus Elfring
2016-09-10  9:44 ` [PATCH 06/30] ACPI-processor: Move a success indication " SF Markus Elfring
2016-09-10  9:45 ` [PATCH 07/30] ACPI-processor: Rename jump labels in acpi_processor_get_psd() SF Markus Elfring
2016-09-10  9:48 ` [PATCH 08/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
2016-09-10  9:50 ` [PATCH 09/30] ACPI-processor: Improve a size determination " SF Markus Elfring
2016-09-10  9:51 ` [PATCH 10/30] ACPI-processor: Rename jump labels in acpi_processor_get_performance_control() SF Markus Elfring
2016-09-10  9:52 ` [PATCH 11/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
2016-09-10  9:54 ` [PATCH 12/30] ACPI-processor: Rename jump labels in acpi_processor_ppc_notifier() SF Markus Elfring
2016-09-10  9:55 ` [PATCH 13/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-10  9:55 ` [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations Paolo Bonzini
2016-09-10  9:56 ` [PATCH 14/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_performance_info() SF Markus Elfring
2016-09-10  9:57 ` [PATCH 15/30] ACPI-processor: Delete an unnecessary initialisation in acpi_processor_get_platform_limit() SF Markus Elfring
2016-09-10  9:58 ` [PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states() SF Markus Elfring
2016-09-10  9:59 ` [PATCH 17/30] ACPI-processor: Improve another size determination " SF Markus Elfring
2016-09-10 10:00 ` [PATCH 18/30] ACPI-processor: Rename jump labels " SF Markus Elfring
2016-09-10 10:01 ` [PATCH 19/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
2016-09-10 10:02 ` [PATCH 20/30] ACPI-processor: Fix jump targets in acpi_processor_get_throttling_info() SF Markus Elfring
2016-09-10 10:03 ` [PATCH 21/30] ACPI-processor: Rename jump labels in acpi_processor_get_tsd() SF Markus Elfring
2016-09-10 10:04 ` [PATCH 22/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
2016-09-10 10:05 ` [PATCH 23/30] ACPI-processor: Improve a size determination " SF Markus Elfring
2016-09-10 10:06 ` [PATCH 24/30] ACPI-processor: Rename jump labels in acpi_processor_get_throttling_control() SF Markus Elfring
2016-09-10 10:07 ` [PATCH 25/30] ACPI-processor: Delete two unnecessary initialisations " SF Markus Elfring
2016-09-10 10:08 ` [PATCH 26/30] ACPI-processor: Fix jump targets in acpi_processor_reevaluate_tstate() SF Markus Elfring
2016-09-10 10:09 ` [PATCH 27/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-10 10:10 ` [PATCH 28/30] ACPI-processor: Rename a jump label in acpi_processor_get_platform_limit() SF Markus Elfring
2016-09-10 10:11 ` [PATCH 29/30] ACPI-processor: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-10 10:12 ` [PATCH 30/30] ACPI-processor: Improve jump targets in acpi_processor_update_tsd_coord() SF Markus Elfring
2017-08-06 10:05 ` [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).