diff mbox series

[6/7] uefi: uefirtauthvar: don't logically or a constant operand.

Message ID 20180730183059.28039-7-colin.king@canonical.com
State Accepted
Headers show
Series abstract _Pragmas and minor changes to build with gcc and clang | expand

Commit Message

Colin Ian King July 30, 2018, 6:30 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Cast constant operands to bool type so that the logical or does not
result in a clang warning.

Fixes clang build warning:

uefi/uefirtauthvar/uefirtauthvar.c:148:65: error: use of logical '||' with
constant operand [-Werror,-Wconstant-logical-operand]

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

Comments

Alex Hung July 31, 2018, 12:13 a.m. UTC | #1
On 2018-07-30 11:30 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Cast constant operands to bool type so that the logical or does not
> result in a clang warning.
> 
> Fixes clang build warning:
> 
> uefi/uefirtauthvar/uefirtauthvar.c:148:65: error: use of logical '||' with
> constant operand [-Werror,-Wconstant-logical-operand]
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefirtauthvar/uefirtauthvar.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index c2031741..7384ae3d 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -145,9 +145,9 @@ static int uefirtauthvar_deinit(fwts_framework *fw)
>   static int check_fw_support(fwts_framework *fw, uint64_t status)
>   {
>   	if ((status == EFI_INVALID_PARAMETER) &&
> -		((attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
> -		(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
> -		(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
> +		((bool)(attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
> +		 (bool)(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
> +		 (bool)(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
>   		fwts_uefi_print_status_info(fw, status);
>   		fwts_skipped(fw,
>   			"EFI_INVALID_PARAMETER shall be returned, "
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu July 31, 2018, 7:50 a.m. UTC | #2
On 07/31/2018 02:30 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Cast constant operands to bool type so that the logical or does not
> result in a clang warning.
>
> Fixes clang build warning:
>
> uefi/uefirtauthvar/uefirtauthvar.c:148:65: error: use of logical '||' with
> constant operand [-Werror,-Wconstant-logical-operand]
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/uefi/uefirtauthvar/uefirtauthvar.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index c2031741..7384ae3d 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -145,9 +145,9 @@ static int uefirtauthvar_deinit(fwts_framework *fw)
>  static int check_fw_support(fwts_framework *fw, uint64_t status)
>  {
>  	if ((status == EFI_INVALID_PARAMETER) &&
> -		((attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
> -		(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
> -		(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
> +		((bool)(attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
> +		 (bool)(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
> +		 (bool)(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
>  		fwts_uefi_print_status_info(fw, status);
>  		fwts_skipped(fw,
>  			"EFI_INVALID_PARAMETER shall be returned, "
Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
index c2031741..7384ae3d 100644
--- a/src/uefi/uefirtauthvar/uefirtauthvar.c
+++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
@@ -145,9 +145,9 @@  static int uefirtauthvar_deinit(fwts_framework *fw)
 static int check_fw_support(fwts_framework *fw, uint64_t status)
 {
 	if ((status == EFI_INVALID_PARAMETER) &&
-		((attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
-		(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
-		(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
+		((bool)(attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
+		 (bool)(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
+		 (bool)(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
 		fwts_uefi_print_status_info(fw, status);
 		fwts_skipped(fw,
 			"EFI_INVALID_PARAMETER shall be returned, "