diff mbox

lib: fwts_cpu: fix missing { } on an if statement

Message ID 1471428005-103177-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Aug. 17, 2016, 10 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

We're missing { } around two statements following an if statement which
is clearly a bug. Fix this.

Found with static analysis by cppcheck:

[src/lib/src/fwts_cpu.c:256]: (style) Statements following return, break,
continue, goto or throw will never be executed.

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

Comments

Alex Hung Aug. 17, 2016, 10:06 a.m. UTC | #1
On 2016-08-17 06:00 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> We're missing { } around two statements following an if statement which
> is clearly a bug. Fix this.
>
> Found with static analysis by cppcheck:
>
> [src/lib/src/fwts_cpu.c:256]: (style) Statements following return, break,
> continue, goto or throw will never be executed.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_cpu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
> index c0b1ec2..b28fb59 100644
> --- a/src/lib/src/fwts_cpu.c
> +++ b/src/lib/src/fwts_cpu.c
> @@ -250,9 +250,10 @@ fwts_bool fwts_cpu_has_c1e(void)
>  			}
>
>                          if (val >= 2) {
> -                                if (fwts_cpu_readmsr(0, MSR_AMD64_OSVW_STATUS, &val) != FWTS_OK)
> +				if (fwts_cpu_readmsr(0, MSR_AMD64_OSVW_STATUS, &val) != FWTS_OK) {
>  					rc = FWTS_BOOL_ERROR;
>  					goto free_info;
> +				}
>                                  if (!(val & 2)) {
>  					rc = FWTS_FALSE;
>  					goto free_info;
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Aug. 18, 2016, 2:20 a.m. UTC | #2
On 2016年08月17日 18:00, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> We're missing { } around two statements following an if statement which
> is clearly a bug. Fix this.
>
> Found with static analysis by cppcheck:
>
> [src/lib/src/fwts_cpu.c:256]: (style) Statements following return, break,
> continue, goto or throw will never be executed.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_cpu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
> index c0b1ec2..b28fb59 100644
> --- a/src/lib/src/fwts_cpu.c
> +++ b/src/lib/src/fwts_cpu.c
> @@ -250,9 +250,10 @@ fwts_bool fwts_cpu_has_c1e(void)
>  			}
>
>                          if (val >= 2) {
> -                                if (fwts_cpu_readmsr(0, MSR_AMD64_OSVW_STATUS, &val) != FWTS_OK)
> +				if (fwts_cpu_readmsr(0, MSR_AMD64_OSVW_STATUS, &val) != FWTS_OK) {
>  					rc = FWTS_BOOL_ERROR;
>  					goto free_info;
> +				}
>                                  if (!(val & 2)) {
>  					rc = FWTS_FALSE;
>  					goto free_info;
>

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

Patch

diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
index c0b1ec2..b28fb59 100644
--- a/src/lib/src/fwts_cpu.c
+++ b/src/lib/src/fwts_cpu.c
@@ -250,9 +250,10 @@  fwts_bool fwts_cpu_has_c1e(void)
 			}
 
                         if (val >= 2) {
-                                if (fwts_cpu_readmsr(0, MSR_AMD64_OSVW_STATUS, &val) != FWTS_OK)
+				if (fwts_cpu_readmsr(0, MSR_AMD64_OSVW_STATUS, &val) != FWTS_OK) {
 					rc = FWTS_BOOL_ERROR;
 					goto free_info;
+				}
                                 if (!(val & 2)) {
 					rc = FWTS_FALSE;
 					goto free_info;