diff mbox series

lib: fwts_acpi_table.c: fix build fail

Message ID 20201125042606.28537-1-ivan.hu@canonical.com
State Accepted
Headers show
Series lib: fwts_acpi_table.c: fix build fail | expand

Commit Message

Ivan Hu Nov. 25, 2020, 4:26 a.m. UTC
fwts_acpi_tables.c: In function ‘fwts_acpi_is_reduced_hardware’:
fwts_acpi_tables.c:293:10: error: implicit conversion from ‘enum <anonymous>’ to ‘fwts_bool’ [-Werror=enum-conversion]
  293 |   return FWTS_ERROR;
      |          ^~~~~~~~~~
fwts_acpi_tables.c:297:10: error: implicit conversion from ‘enum <anonymous>’ to ‘fwts_bool’ [-Werror=enum-conversion]
  297 |   return FWTS_ERROR;
      |          ^~~~~~~~~~

Also modify some codes for affecting the patch,
lib: refactor fwts_acpi_is_reduced_hardware

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/src/fwts_acpi_tables.c | 6 +++---
 src/sbbr/fadt/fadt.c           | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

Comments

Alex Hung Nov. 25, 2020, 4:52 a.m. UTC | #1
On 2020-11-24 9:26 p.m., Ivan Hu wrote:
> fwts_acpi_tables.c: In function ‘fwts_acpi_is_reduced_hardware’:
> fwts_acpi_tables.c:293:10: error: implicit conversion from ‘enum <anonymous>’ to ‘fwts_bool’ [-Werror=enum-conversion]
>   293 |   return FWTS_ERROR;
>       |          ^~~~~~~~~~
> fwts_acpi_tables.c:297:10: error: implicit conversion from ‘enum <anonymous>’ to ‘fwts_bool’ [-Werror=enum-conversion]
>   297 |   return FWTS_ERROR;
>       |          ^~~~~~~~~~
> 
> Also modify some codes for affecting the patch,
> lib: refactor fwts_acpi_is_reduced_hardware
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/src/fwts_acpi_tables.c | 6 +++---
>  src/sbbr/fadt/fadt.c           | 7 ++++---
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index f0a809eb..248f8ae1 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -290,11 +290,11 @@ fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw)
>  
>  	if (fwts_acpi_find_table(fw, "FACP", 0, &table) != FWTS_OK) {
>  		fwts_log_error(fw, "Cannot read ACPI table FACP.");
> -		return FWTS_ERROR;
> +		return FWTS_BOOL_ERROR;
>  	}
>  	if (table == NULL) {
>  		fwts_log_error(fw, "ACPI table FACP does not exist!");
> -		return FWTS_ERROR;
> +		return FWTS_BOOL_ERROR;
>  	}
>  	fadt = (const fwts_acpi_table_fadt *) table->data;
>  
> @@ -415,7 +415,7 @@ PRAGMA_PACK_WARN_OFF
>  PRAGMA_POP
>  	if (result != FWTS_OK) {
>  		if ((result == FWTS_NULL_POINTER) &&
> -				fwts_acpi_is_reduced_hardware(fw)) {
> +				(fwts_acpi_is_reduced_hardware(fw) == FWTS_TRUE)) {
>  			fwts_log_info(fw, "Ignore the missing FACS. "
>  					"It is optional in hardware-reduced mode");
>  		} else {
> diff --git a/src/sbbr/fadt/fadt.c b/src/sbbr/fadt/fadt.c
> index c02c84e9..35ba5d15 100644
> --- a/src/sbbr/fadt/fadt.c
> +++ b/src/sbbr/fadt/fadt.c
> @@ -93,11 +93,12 @@ static int fadt_sbbr_reduced_hw_test2(fwts_framework *fw)
>  	uint32_t flag_mask;
>  
>  	rhw = fwts_acpi_is_reduced_hardware(fw);
> -	if (rhw == 0)
> +	if (rhw == FWTS_FALSE)
>  		fwts_failed(fw, LOG_LEVEL_CRITICAL, "fadt_reduced_hw:", "FADT indicates ACPI is not in reduced hardware mode.");
> -	else
> +	else if(rhw == FWTS_TRUE)
>  		fwts_passed(fw, "FADT indicates ACPI is in reduced hardware mode.");
> -
> +	else
> +		fwts_failed(fw, LOG_LEVEL_HIGH, "fadt_reduced_hw:", "ACPI table reads error.");
>  
>  	if (!rhw)
>  		return FWTS_OK;
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Colin Ian King Nov. 25, 2020, 9:13 a.m. UTC | #2
On 25/11/2020 04:26, Ivan Hu wrote:
> fwts_acpi_tables.c: In function ‘fwts_acpi_is_reduced_hardware’:
> fwts_acpi_tables.c:293:10: error: implicit conversion from ‘enum <anonymous>’ to ‘fwts_bool’ [-Werror=enum-conversion]
>   293 |   return FWTS_ERROR;
>       |          ^~~~~~~~~~
> fwts_acpi_tables.c:297:10: error: implicit conversion from ‘enum <anonymous>’ to ‘fwts_bool’ [-Werror=enum-conversion]
>   297 |   return FWTS_ERROR;
>       |          ^~~~~~~~~~
> 
> Also modify some codes for affecting the patch,
> lib: refactor fwts_acpi_is_reduced_hardware
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/src/fwts_acpi_tables.c | 6 +++---
>  src/sbbr/fadt/fadt.c           | 7 ++++---
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index f0a809eb..248f8ae1 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -290,11 +290,11 @@ fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw)
>  
>  	if (fwts_acpi_find_table(fw, "FACP", 0, &table) != FWTS_OK) {
>  		fwts_log_error(fw, "Cannot read ACPI table FACP.");
> -		return FWTS_ERROR;
> +		return FWTS_BOOL_ERROR;
>  	}
>  	if (table == NULL) {
>  		fwts_log_error(fw, "ACPI table FACP does not exist!");
> -		return FWTS_ERROR;
> +		return FWTS_BOOL_ERROR;
>  	}
>  	fadt = (const fwts_acpi_table_fadt *) table->data;
>  
> @@ -415,7 +415,7 @@ PRAGMA_PACK_WARN_OFF
>  PRAGMA_POP
>  	if (result != FWTS_OK) {
>  		if ((result == FWTS_NULL_POINTER) &&
> -				fwts_acpi_is_reduced_hardware(fw)) {
> +				(fwts_acpi_is_reduced_hardware(fw) == FWTS_TRUE)) {
>  			fwts_log_info(fw, "Ignore the missing FACS. "
>  					"It is optional in hardware-reduced mode");
>  		} else {
> diff --git a/src/sbbr/fadt/fadt.c b/src/sbbr/fadt/fadt.c
> index c02c84e9..35ba5d15 100644
> --- a/src/sbbr/fadt/fadt.c
> +++ b/src/sbbr/fadt/fadt.c
> @@ -93,11 +93,12 @@ static int fadt_sbbr_reduced_hw_test2(fwts_framework *fw)
>  	uint32_t flag_mask;
>  
>  	rhw = fwts_acpi_is_reduced_hardware(fw);
> -	if (rhw == 0)
> +	if (rhw == FWTS_FALSE)
>  		fwts_failed(fw, LOG_LEVEL_CRITICAL, "fadt_reduced_hw:", "FADT indicates ACPI is not in reduced hardware mode.");
> -	else
> +	else if(rhw == FWTS_TRUE)
>  		fwts_passed(fw, "FADT indicates ACPI is in reduced hardware mode.");
> -
> +	else
> +		fwts_failed(fw, LOG_LEVEL_HIGH, "fadt_reduced_hw:", "ACPI table reads error.");
>  
>  	if (!rhw)
>  		return FWTS_OK;
> 

Thanks Ivan.

Acked-by: Colin Ian King <colin.king@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index f0a809eb..248f8ae1 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -290,11 +290,11 @@  fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw)
 
 	if (fwts_acpi_find_table(fw, "FACP", 0, &table) != FWTS_OK) {
 		fwts_log_error(fw, "Cannot read ACPI table FACP.");
-		return FWTS_ERROR;
+		return FWTS_BOOL_ERROR;
 	}
 	if (table == NULL) {
 		fwts_log_error(fw, "ACPI table FACP does not exist!");
-		return FWTS_ERROR;
+		return FWTS_BOOL_ERROR;
 	}
 	fadt = (const fwts_acpi_table_fadt *) table->data;
 
@@ -415,7 +415,7 @@  PRAGMA_PACK_WARN_OFF
 PRAGMA_POP
 	if (result != FWTS_OK) {
 		if ((result == FWTS_NULL_POINTER) &&
-				fwts_acpi_is_reduced_hardware(fw)) {
+				(fwts_acpi_is_reduced_hardware(fw) == FWTS_TRUE)) {
 			fwts_log_info(fw, "Ignore the missing FACS. "
 					"It is optional in hardware-reduced mode");
 		} else {
diff --git a/src/sbbr/fadt/fadt.c b/src/sbbr/fadt/fadt.c
index c02c84e9..35ba5d15 100644
--- a/src/sbbr/fadt/fadt.c
+++ b/src/sbbr/fadt/fadt.c
@@ -93,11 +93,12 @@  static int fadt_sbbr_reduced_hw_test2(fwts_framework *fw)
 	uint32_t flag_mask;
 
 	rhw = fwts_acpi_is_reduced_hardware(fw);
-	if (rhw == 0)
+	if (rhw == FWTS_FALSE)
 		fwts_failed(fw, LOG_LEVEL_CRITICAL, "fadt_reduced_hw:", "FADT indicates ACPI is not in reduced hardware mode.");
-	else
+	else if(rhw == FWTS_TRUE)
 		fwts_passed(fw, "FADT indicates ACPI is in reduced hardware mode.");
-
+	else
+		fwts_failed(fw, LOG_LEVEL_HIGH, "fadt_reduced_hw:", "ACPI table reads error.");
 
 	if (!rhw)
 		return FWTS_OK;