diff mbox series

[2/6] acpi: refactor length check by fwts_acpi_structure_length_check

Message ID 20210514192155.593354-2-alex.hung@canonical.com
State Accepted
Headers show
Series [1/6] acpi: refactor zero length by fwts_acpi_structure_length_zero_check | expand

Commit Message

Alex Hung May 14, 2021, 7:21 p.m. UTC
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/acpi/hmat/hmat.c | 7 +------
 src/acpi/pptt/pptt.c | 7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)

Comments

Ivan Hu May 17, 2021, 6:22 a.m. UTC | #1
On 5/15/21 3:21 AM, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/hmat/hmat.c | 7 +------
>  src/acpi/pptt/pptt.c | 7 +------
>  2 files changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
> index 8a06f8b1..01b76100 100644
> --- a/src/acpi/hmat/hmat.c
> +++ b/src/acpi/hmat/hmat.c
> @@ -182,13 +182,8 @@ static int hmat_test1(fwts_framework *fw)
>  			break;
>  		}
>  
> -		if (entry->length != type_length) {
> +		if (!fwts_acpi_structure_length_check(fw, "HMAT", entry->type, entry->length, type_length)) {
>  			passed = false;
> -			fwts_failed(fw, LOG_LEVEL_CRITICAL,
> -				"HMATBadSubtableLength",
> -				"HMAT subtable Type 0x%2.2" PRIx8 " should have "
> -				"length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8,
> -				entry->type, entry->length, type_length);
>  			break;
>  		}
>  
> diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
> index c436ab82..8656e979 100644
> --- a/src/acpi/pptt/pptt.c
> +++ b/src/acpi/pptt/pptt.c
> @@ -146,13 +146,8 @@ static int pptt_test1(fwts_framework *fw)
>  			break;
>  		}
>  
> -		if (entry->length != type_length) {
> +		if (!fwts_acpi_structure_length_check(fw, "PPTT", entry->type, entry->length, type_length)) {
>  			passed = false;
> -			fwts_failed(fw, LOG_LEVEL_CRITICAL,
> -				"PPTTBadSubtableLength",
> -				"PPTT subtable Type 0x%2.2" PRIx8 " should have "
> -				"length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8,
> -				entry->type, type_length, entry->length);
>  			break;
>  		}
>  
> 

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Colin Ian King May 20, 2021, 7:42 a.m. UTC | #2
On 14/05/2021 20:21, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/acpi/hmat/hmat.c | 7 +------
>  src/acpi/pptt/pptt.c | 7 +------
>  2 files changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
> index 8a06f8b1..01b76100 100644
> --- a/src/acpi/hmat/hmat.c
> +++ b/src/acpi/hmat/hmat.c
> @@ -182,13 +182,8 @@ static int hmat_test1(fwts_framework *fw)
>  			break;
>  		}
>  
> -		if (entry->length != type_length) {
> +		if (!fwts_acpi_structure_length_check(fw, "HMAT", entry->type, entry->length, type_length)) {
>  			passed = false;
> -			fwts_failed(fw, LOG_LEVEL_CRITICAL,
> -				"HMATBadSubtableLength",
> -				"HMAT subtable Type 0x%2.2" PRIx8 " should have "
> -				"length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8,
> -				entry->type, entry->length, type_length);
>  			break;
>  		}
>  
> diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
> index c436ab82..8656e979 100644
> --- a/src/acpi/pptt/pptt.c
> +++ b/src/acpi/pptt/pptt.c
> @@ -146,13 +146,8 @@ static int pptt_test1(fwts_framework *fw)
>  			break;
>  		}
>  
> -		if (entry->length != type_length) {
> +		if (!fwts_acpi_structure_length_check(fw, "PPTT", entry->type, entry->length, type_length)) {
>  			passed = false;
> -			fwts_failed(fw, LOG_LEVEL_CRITICAL,
> -				"PPTTBadSubtableLength",
> -				"PPTT subtable Type 0x%2.2" PRIx8 " should have "
> -				"length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8,
> -				entry->type, type_length, entry->length);
>  			break;
>  		}
>  
> 


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

Patch

diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
index 8a06f8b1..01b76100 100644
--- a/src/acpi/hmat/hmat.c
+++ b/src/acpi/hmat/hmat.c
@@ -182,13 +182,8 @@  static int hmat_test1(fwts_framework *fw)
 			break;
 		}
 
-		if (entry->length != type_length) {
+		if (!fwts_acpi_structure_length_check(fw, "HMAT", entry->type, entry->length, type_length)) {
 			passed = false;
-			fwts_failed(fw, LOG_LEVEL_CRITICAL,
-				"HMATBadSubtableLength",
-				"HMAT subtable Type 0x%2.2" PRIx8 " should have "
-				"length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8,
-				entry->type, entry->length, type_length);
 			break;
 		}
 
diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
index c436ab82..8656e979 100644
--- a/src/acpi/pptt/pptt.c
+++ b/src/acpi/pptt/pptt.c
@@ -146,13 +146,8 @@  static int pptt_test1(fwts_framework *fw)
 			break;
 		}
 
-		if (entry->length != type_length) {
+		if (!fwts_acpi_structure_length_check(fw, "PPTT", entry->type, entry->length, type_length)) {
 			passed = false;
-			fwts_failed(fw, LOG_LEVEL_CRITICAL,
-				"PPTTBadSubtableLength",
-				"PPTT subtable Type 0x%2.2" PRIx8 " should have "
-				"length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8,
-				entry->type, type_length, entry->length);
 			break;
 		}