diff mbox

[18/46] cpu: cpufreq: reduce scope of variables

Message ID 1421175905-17035-19-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Jan. 13, 2015, 7:04 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

cppcheck is picking up some minor style issues which can
be easily fixed:

[src/cpu/cpufreq/cpufreq.c:447]:
	(style) The scope of the variable 'Hz' can be reduced.
[src/cpu/cpufreq/cpufreq.c:476]:
	(style) The scope of the variable 'Hz' can be reduced.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/cpu/cpufreq/cpufreq.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Ivan Hu Jan. 15, 2015, 7:32 a.m. UTC | #1
On 01/14/2015 03:04 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/cpu/cpufreq/cpufreq.c:447]:
> 	(style) The scope of the variable 'Hz' can be reduced.
> [src/cpu/cpufreq/cpufreq.c:476]:
> 	(style) The scope of the variable 'Hz' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 0fcab88..d3e19ef 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -444,7 +444,7 @@ static void lowest_speed(fwts_framework *fw, const int cpu)
>   	char path[PATH_MAX];
>   	char *line;
>   	char *c, *c2;
> -	uint64_t Hz, lowspeed = 0;
> +	uint64_t lowspeed = 0;
>
>   	cpu_mkpath(path, sizeof(path), cpu, "scaling_available_frequencies");
>   	if ((line = fwts_get(path)) == NULL)
> @@ -452,6 +452,8 @@ static void lowest_speed(fwts_framework *fw, const int cpu)
>
>   	c = line;
>   	while (c && strlen(c) > 1) {
> +		uint64_t Hz;
> +
>   		c2 = strchr(c, ' ');
>   		if (c2) {
>   			*c2 = 0;
> @@ -473,7 +475,6 @@ static void highest_speed(fwts_framework *fw, const int cpu)
>   {
>   	char path[PATH_MAX];
>   	char *line;
> -	uint64_t Hz;
>   	char *c, *c2;
>   	unsigned long highspeed=0;
>
> @@ -483,6 +484,8 @@ static void highest_speed(fwts_framework *fw, const int cpu)
>
>   	c = line;
>   	while (c && strlen(c) > 1) {
> +		uint64_t Hz;
> +
>   		c2 = strchr(c, ' ');
>   		if (c2) {
>   			*c2=0;
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin Jan. 20, 2015, 6:54 a.m. UTC | #2
On Wed, Jan 14, 2015 at 3:04 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/cpu/cpufreq/cpufreq.c:447]:
>         (style) The scope of the variable 'Hz' can be reduced.
> [src/cpu/cpufreq/cpufreq.c:476]:
>         (style) The scope of the variable 'Hz' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/cpufreq/cpufreq.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 0fcab88..d3e19ef 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -444,7 +444,7 @@ static void lowest_speed(fwts_framework *fw, const int cpu)
>         char path[PATH_MAX];
>         char *line;
>         char *c, *c2;
> -       uint64_t Hz, lowspeed = 0;
> +       uint64_t lowspeed = 0;
>
>         cpu_mkpath(path, sizeof(path), cpu, "scaling_available_frequencies");
>         if ((line = fwts_get(path)) == NULL)
> @@ -452,6 +452,8 @@ static void lowest_speed(fwts_framework *fw, const int cpu)
>
>         c = line;
>         while (c && strlen(c) > 1) {
> +               uint64_t Hz;
> +
>                 c2 = strchr(c, ' ');
>                 if (c2) {
>                         *c2 = 0;
> @@ -473,7 +475,6 @@ static void highest_speed(fwts_framework *fw, const int cpu)
>  {
>         char path[PATH_MAX];
>         char *line;
> -       uint64_t Hz;
>         char *c, *c2;
>         unsigned long highspeed=0;
>
> @@ -483,6 +484,8 @@ static void highest_speed(fwts_framework *fw, const int cpu)
>
>         c = line;
>         while (c && strlen(c) > 1) {
> +               uint64_t Hz;
> +
>                 c2 = strchr(c, ' ');
>                 if (c2) {
>                         *c2=0;
> --
> 2.1.4
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 0fcab88..d3e19ef 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -444,7 +444,7 @@  static void lowest_speed(fwts_framework *fw, const int cpu)
 	char path[PATH_MAX];
 	char *line;
 	char *c, *c2;
-	uint64_t Hz, lowspeed = 0;
+	uint64_t lowspeed = 0;
 
 	cpu_mkpath(path, sizeof(path), cpu, "scaling_available_frequencies");
 	if ((line = fwts_get(path)) == NULL)
@@ -452,6 +452,8 @@  static void lowest_speed(fwts_framework *fw, const int cpu)
 
 	c = line;
 	while (c && strlen(c) > 1) {
+		uint64_t Hz;
+
 		c2 = strchr(c, ' ');
 		if (c2) {
 			*c2 = 0;
@@ -473,7 +475,6 @@  static void highest_speed(fwts_framework *fw, const int cpu)
 {
 	char path[PATH_MAX];
 	char *line;
-	uint64_t Hz;
 	char *c, *c2;
 	unsigned long highspeed=0;
 
@@ -483,6 +484,8 @@  static void highest_speed(fwts_framework *fw, const int cpu)
 
 	c = line;
 	while (c && strlen(c) > 1) {
+		uint64_t Hz;
+
 		c2 = strchr(c, ' ');
 		if (c2) {
 			*c2=0;