Patchwork lib: fwts_cpu: initialize variable, stop coverity warning

login
register
mail settings
Submitter Colin King
Date May 6, 2013, 11:11 p.m.
Message ID <1367881860-21357-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/241825/
State Accepted
Headers show

Comments

Colin King - May 6, 2013, 11:11 p.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997324, Uninitialized scalar variable (UNINIT)

We really don't care about initializing the loop counter as
we are just burning up CPU cycles. But to keep coverity happy
we may as well initialize it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - May 9, 2013, 6:16 a.m.
On 05/07/2013 07:11 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997324, Uninitialized scalar variable (UNINIT)
>
> We really don't care about initializing the loop counter as
> we are just burning up CPU cycles. But to keep coverity happy
> we may as well initialize it.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_cpu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
> index 282bc42..44711fd 100644
> --- a/src/lib/src/fwts_cpu.c
> +++ b/src/lib/src/fwts_cpu.c
> @@ -385,7 +385,7 @@ int fwts_cpu_performance(
>   static void fwts_cpu_consume_cycles(void)
>   {
>   	signal(SIGUSR1, fwts_cpu_consume_sighandler);
> -	uint64_t i;
> +	uint64_t i = 0;
>
>   	for (;;) {
>   		fwts_cpu_burn_cycles();
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - May 16, 2013, 3:18 a.m.
On 05/07/2013 07:11 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997324, Uninitialized scalar variable (UNINIT)
>
> We really don't care about initializing the loop counter as
> we are just burning up CPU cycles. But to keep coverity happy
> we may as well initialize it.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_cpu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
> index 282bc42..44711fd 100644
> --- a/src/lib/src/fwts_cpu.c
> +++ b/src/lib/src/fwts_cpu.c
> @@ -385,7 +385,7 @@ int fwts_cpu_performance(
>   static void fwts_cpu_consume_cycles(void)
>   {
>   	signal(SIGUSR1, fwts_cpu_consume_sighandler);
> -	uint64_t i;
> +	uint64_t i = 0;
>
>   	for (;;) {
>   		fwts_cpu_burn_cycles();
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
index 282bc42..44711fd 100644
--- a/src/lib/src/fwts_cpu.c
+++ b/src/lib/src/fwts_cpu.c
@@ -385,7 +385,7 @@  int fwts_cpu_performance(
 static void fwts_cpu_consume_cycles(void)
 {
 	signal(SIGUSR1, fwts_cpu_consume_sighandler);
-	uint64_t i;
+	uint64_t i = 0;
 
 	for (;;) {
 		fwts_cpu_burn_cycles();