[PATCH 1/6] acpi: refactor zero length by fwts_acpi_structure_length_zero_check
Alex Hung
alex.hung at canonical.com
Fri May 14 19:21:50 UTC 2021
Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
src/acpi/hmat/hmat.c | 5 +----
src/acpi/nfit/nfit.c | 5 +----
src/acpi/pmtt/pmtt.c | 17 +++++------------
src/acpi/pptt/pptt.c | 5 +----
src/acpi/sdev/sdev.c | 5 +----
5 files changed, 9 insertions(+), 28 deletions(-)
diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
index e1105481..8a06f8b1 100644
--- a/src/acpi/hmat/hmat.c
+++ b/src/acpi/hmat/hmat.c
@@ -159,11 +159,8 @@ static int hmat_test1(fwts_framework *fw)
while (offset < table->length) {
uint32_t type_length;
- if (entry->length == 0) {
+ if (fwts_acpi_structure_length_zero_check(fw, "HMAT", entry->length, offset)) {
passed = false;
- fwts_failed(fw, LOG_LEVEL_HIGH, "HMATStructLengthZero",
- "HMAT structure (offset 0x%4.4" PRIx32 ") "
- "length cannot be 0", offset);
break;
}
diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c
index 6eba2058..d7436166 100644
--- a/src/acpi/nfit/nfit.c
+++ b/src/acpi/nfit/nfit.c
@@ -138,11 +138,8 @@ static int nfit_test1(fwts_framework *fw)
fwts_log_info_simp_int(fw, " Type: ", entry->type);
fwts_log_info_simp_int(fw, " Length: ", entry->length);
- if (entry->length == 0) {
+ if (fwts_acpi_structure_length_zero_check(fw, "NFIT", entry->length, offset)) {
passed = false;
- fwts_failed(fw, LOG_LEVEL_HIGH, "NFITLengthZero",
- "NFIT Subtable (offset 0x%4.4" PRIx32 ") "
- "length cannot be 0", offset);
break;
}
diff --git a/src/acpi/pmtt/pmtt.c b/src/acpi/pmtt/pmtt.c
index 74e49717..f0ad0df1 100644
--- a/src/acpi/pmtt/pmtt.c
+++ b/src/acpi/pmtt/pmtt.c
@@ -94,10 +94,8 @@ static void pmtt_controller_test(
break;
}
- if (header->length == 0) {
- fwts_failed(fw, LOG_LEVEL_CRITICAL,
- "PMTTBadSubtableLength",
- "PMTT Controller has a subtable with zero length");
+ if (fwts_acpi_structure_length_zero_check(fw, "PMTT", header->length, offset)) {
+ *passed = false;
break;
}
@@ -132,10 +130,8 @@ static void pmtt_socket_test(
break;
}
- if (header->length == 0) {
- fwts_failed(fw, LOG_LEVEL_CRITICAL,
- "PMTTBadSubtableLength",
- "PMTT Socket has a subtable with zero length");
+ if (fwts_acpi_structure_length_zero_check(fw, "PMTT", header->length, offset)) {
+ *passed = false;
break;
}
@@ -195,11 +191,8 @@ static int pmtt_test1(fwts_framework *fw)
offset = sizeof(fwts_acpi_table_pmtt);
while (offset < table->length) {
- if (entry->length == 0) {
+ if (fwts_acpi_structure_length_zero_check(fw, "PHAT", entry->length, offset)) {
passed = false;
- fwts_failed(fw, LOG_LEVEL_HIGH, "PMTTLengthZero",
- "PMTT Subtable (offset 0x%4.4" PRIx32 ") "
- "length cannot be 0", offset);
break;
}
diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
index 54eef4a2..c436ab82 100644
--- a/src/acpi/pptt/pptt.c
+++ b/src/acpi/pptt/pptt.c
@@ -123,11 +123,8 @@ static int pptt_test1(fwts_framework *fw)
while (offset < table->length) {
uint32_t type_length;
- if (entry->length == 0) {
+ if (fwts_acpi_structure_length_zero_check(fw, "PPTT", entry->length, offset)) {
passed = false;
- fwts_failed(fw, LOG_LEVEL_HIGH, "PPTTStructLengthZero",
- "PPTT structure (offset 0x%4.4" PRIx32 ") "
- "length cannot be 0", offset);
break;
}
diff --git a/src/acpi/sdev/sdev.c b/src/acpi/sdev/sdev.c
index 8946c5e9..ef868df6 100644
--- a/src/acpi/sdev/sdev.c
+++ b/src/acpi/sdev/sdev.c
@@ -76,11 +76,8 @@ static int sdev_test1(fwts_framework *fw)
while (offset < table->length) {
uint32_t type_length;
- if (entry->length == 0) {
+ if (fwts_acpi_structure_length_zero_check(fw, "SDEV", entry->length, offset)) {
passed = false;
- fwts_failed(fw, LOG_LEVEL_HIGH, "SDEVStructLengthZero",
- "SDEV structure (offset 0x%4.4" PRIx32 ") "
- "length cannot be 0", offset);
break;
}
--
2.31.1
More information about the fwts-devel
mailing list