[PATCH] uefirtvariable: fix the wrong operator used, coverity scan error (LP: #1362893)

Ivan Hu ivan.hu at canonical.com
Fri Aug 29 02:47:04 UTC 2014


CID 1232806, CID1232805: Wrong operator used (CONSTANT_EXPRESSION_RESULT)
always true regardless of the values of its operand.

Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
 src/uefi/uefirtvariable/uefirtvariable.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
index 46c7f0e..f0fd0ce 100644
--- a/src/uefi/uefirtvariable/uefirtvariable.c
+++ b/src/uefi/uefirtvariable/uefirtvariable.c
@@ -781,9 +781,9 @@ static int setvariable_insertvariable(
 
 	if (ioret == -1) {
 		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))) {
+			((attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
+			(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) ||
+			(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) {
 			fwts_uefi_print_status_info(fw, status);
 			fwts_skipped(fw,
 				"EFI_INVALID_PARAMETER shall be returned, "
@@ -941,8 +941,8 @@ static int setvariable_invalidattr(
 	ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
 
 	if ((status == EFI_SUCCESS) && (ioret != -1)) {
-		if ((attributes | FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) &&
-			(attributes | FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) &&
+		if ((attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) &&
+			(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) &&
 			(status != EFI_INVALID_PARAMETER)) {
 			fwts_warning(fw,
 				"Both the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS attribute and the "
-- 
1.7.9.5




More information about the fwts-devel mailing list