diff mbox

[20/46] cpu: microcode: reduce scope of variables

Message ID 1421175905-17035-21-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/microcode/microcode.c:203]:
	(style) The scope of the variable 'path' can be reduced.
[src/cpu/microcode/microcode.c:204]:
	(style) The scope of the variable 'data' can be reduced.

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

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/microcode/microcode.c:203]:
> 	(style) The scope of the variable 'path' can be reduced.
> [src/cpu/microcode/microcode.c:204]:
> 	(style) The scope of the variable 'data' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/microcode/microcode.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
> index d493168..b541b87 100644
> --- a/src/cpu/microcode/microcode.c
> +++ b/src/cpu/microcode/microcode.c
> @@ -200,13 +200,13 @@ static int microcode_test1(fwts_framework *fw)
>
>   	/* Scan and check */
>   	while ((entry = readdir(dir)) != NULL) {
> -		char path[PATH_MAX];
> -		char *data;
> -
>   	        if (entry &&
>   		    (strlen(entry->d_name) > 3) &&
>   		    (strncmp(entry->d_name,"cpu", 3) == 0) &&
>   		    (isdigit(entry->d_name[3]))) {
> +			char path[PATH_MAX];
> +			char *data;
> +
>   	        	snprintf(path, sizeof(path),
>   				SYS_CPU_PATH "/%s/microcode/version",
>   				entry->d_name);
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin Jan. 20, 2015, 6:55 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/microcode/microcode.c:203]:
>         (style) The scope of the variable 'path' can be reduced.
> [src/cpu/microcode/microcode.c:204]:
>         (style) The scope of the variable 'data' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/microcode/microcode.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
> index d493168..b541b87 100644
> --- a/src/cpu/microcode/microcode.c
> +++ b/src/cpu/microcode/microcode.c
> @@ -200,13 +200,13 @@ static int microcode_test1(fwts_framework *fw)
>
>         /* Scan and check */
>         while ((entry = readdir(dir)) != NULL) {
> -               char path[PATH_MAX];
> -               char *data;
> -
>                 if (entry &&
>                     (strlen(entry->d_name) > 3) &&
>                     (strncmp(entry->d_name,"cpu", 3) == 0) &&
>                     (isdigit(entry->d_name[3]))) {
> +                       char path[PATH_MAX];
> +                       char *data;
> +
>                         snprintf(path, sizeof(path),
>                                 SYS_CPU_PATH "/%s/microcode/version",
>                                 entry->d_name);
> --
> 2.1.4
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
index d493168..b541b87 100644
--- a/src/cpu/microcode/microcode.c
+++ b/src/cpu/microcode/microcode.c
@@ -200,13 +200,13 @@  static int microcode_test1(fwts_framework *fw)
 
 	/* Scan and check */
 	while ((entry = readdir(dir)) != NULL) {
-		char path[PATH_MAX];
-		char *data;
-
 	        if (entry &&
 		    (strlen(entry->d_name) > 3) &&
 		    (strncmp(entry->d_name,"cpu", 3) == 0) &&
 		    (isdigit(entry->d_name[3]))) {
+			char path[PATH_MAX];
+			char *data;
+
 	        	snprintf(path, sizeof(path),
 				SYS_CPU_PATH "/%s/microcode/version",
 				entry->d_name);