diff mbox

[21/46] cpu: msr: reduce scope of variables

Message ID 1421175905-17035-22-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/msr/msr.c:123]:
	(style) The scope of the variable 'cpu' can be reduced.

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

Comments

Ivan Hu Jan. 15, 2015, 7:33 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/msr/msr.c:123]:
> 	(style) The scope of the variable 'cpu' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/msr/msr.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/cpu/msr/msr.c b/src/cpu/msr/msr.c
> index 0d04007..e2acce3 100644
> --- a/src/cpu/msr/msr.c
> +++ b/src/cpu/msr/msr.c
> @@ -120,7 +120,6 @@ static int msr_consistent_check(fwts_framework *fw,
>   	uint64_t *vals;
>   	bool *inconsistent;
>   	int inconsistent_count;
> -	int cpu;
>
>   	if ((vals = calloc(ncpus, sizeof(uint64_t))) == NULL) {
>   		fwts_log_error(fw, "Out of memory allocating msr value buffers.");
> @@ -138,6 +137,8 @@ static int msr_consistent_check(fwts_framework *fw,
>   		return FWTS_ERROR;
>   	}
>   	if (inconsistent_count > 0) {
> +		int cpu;
> +
>   		fwts_failed(fw, level, "MSRCPUsInconsistent",
>   			"MSR 0x%8.8" PRIx32 " %s has %d inconsistent values across "
>   			"%d CPUs (shift: %d mask: 0x%" PRIx64 ").",
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin Jan. 20, 2015, 6:56 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/msr/msr.c:123]:
>         (style) The scope of the variable 'cpu' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/msr/msr.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/cpu/msr/msr.c b/src/cpu/msr/msr.c
> index 0d04007..e2acce3 100644
> --- a/src/cpu/msr/msr.c
> +++ b/src/cpu/msr/msr.c
> @@ -120,7 +120,6 @@ static int msr_consistent_check(fwts_framework *fw,
>         uint64_t *vals;
>         bool *inconsistent;
>         int inconsistent_count;
> -       int cpu;
>
>         if ((vals = calloc(ncpus, sizeof(uint64_t))) == NULL) {
>                 fwts_log_error(fw, "Out of memory allocating msr value buffers.");
> @@ -138,6 +137,8 @@ static int msr_consistent_check(fwts_framework *fw,
>                 return FWTS_ERROR;
>         }
>         if (inconsistent_count > 0) {
> +               int cpu;
> +
>                 fwts_failed(fw, level, "MSRCPUsInconsistent",
>                         "MSR 0x%8.8" PRIx32 " %s has %d inconsistent values across "
>                         "%d CPUs (shift: %d mask: 0x%" PRIx64 ").",
> --
> 2.1.4
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/cpu/msr/msr.c b/src/cpu/msr/msr.c
index 0d04007..e2acce3 100644
--- a/src/cpu/msr/msr.c
+++ b/src/cpu/msr/msr.c
@@ -120,7 +120,6 @@  static int msr_consistent_check(fwts_framework *fw,
 	uint64_t *vals;
 	bool *inconsistent;
 	int inconsistent_count;
-	int cpu;
 
 	if ((vals = calloc(ncpus, sizeof(uint64_t))) == NULL) {
 		fwts_log_error(fw, "Out of memory allocating msr value buffers.");
@@ -138,6 +137,8 @@  static int msr_consistent_check(fwts_framework *fw,
 		return FWTS_ERROR;
 	}
 	if (inconsistent_count > 0) {
+		int cpu;
+
 		fwts_failed(fw, level, "MSRCPUsInconsistent",
 			"MSR 0x%8.8" PRIx32 " %s has %d inconsistent values across "
 			"%d CPUs (shift: %d mask: 0x%" PRIx64 ").",