diff mbox

[17/46] bios: multiproc: reduce scope of variables

Message ID 1421175905-17035-18-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/bios/multiproc/mpdump.c:300]:
	(style) The scope of the variable 'buffer' can be reduced.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/bios/multiproc/mpdump.c | 4 ++--
 1 file changed, 2 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/bios/multiproc/mpdump.c:300]:
> 	(style) The scope of the variable 'buffer' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/bios/multiproc/mpdump.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/bios/multiproc/mpdump.c b/src/bios/multiproc/mpdump.c
> index 2a57b20..0b22ba9 100644
> --- a/src/bios/multiproc/mpdump.c
> +++ b/src/bios/multiproc/mpdump.c
> @@ -297,11 +297,11 @@ static char *mpdump_find_bus_name(uint8_t bus_id)
>
>   static char *mpdump_dst_io_apic(uint8_t apic)
>   {
> -	static char buffer[4];
> -
>   	if (apic == 255)
>   		return "all";
>   	else {
> +		static char buffer[4];
> +
>   		snprintf(buffer, sizeof(buffer), "%d", apic);
>   		return buffer;
>   	}
>

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/bios/multiproc/mpdump.c:300]:
>         (style) The scope of the variable 'buffer' can be reduced.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/bios/multiproc/mpdump.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/bios/multiproc/mpdump.c b/src/bios/multiproc/mpdump.c
> index 2a57b20..0b22ba9 100644
> --- a/src/bios/multiproc/mpdump.c
> +++ b/src/bios/multiproc/mpdump.c
> @@ -297,11 +297,11 @@ static char *mpdump_find_bus_name(uint8_t bus_id)
>
>  static char *mpdump_dst_io_apic(uint8_t apic)
>  {
> -       static char buffer[4];
> -
>         if (apic == 255)
>                 return "all";
>         else {
> +               static char buffer[4];
> +
>                 snprintf(buffer, sizeof(buffer), "%d", apic);
>                 return buffer;
>         }
> --
> 2.1.4
>
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/bios/multiproc/mpdump.c b/src/bios/multiproc/mpdump.c
index 2a57b20..0b22ba9 100644
--- a/src/bios/multiproc/mpdump.c
+++ b/src/bios/multiproc/mpdump.c
@@ -297,11 +297,11 @@  static char *mpdump_find_bus_name(uint8_t bus_id)
 
 static char *mpdump_dst_io_apic(uint8_t apic)
 {
-	static char buffer[4];
-
 	if (apic == 255)
 		return "all";
 	else {
+		static char buffer[4];
+
 		snprintf(buffer, sizeof(buffer), "%d", apic);
 		return buffer;
 	}