diff mbox series

lib: fwts_acpi_tables: fix the passed reserved value

Message ID 20221230053853.6348-1-ivan.hu@canonical.com
State Accepted
Headers show
Series lib: fwts_acpi_tables: fix the passed reserved value | expand

Commit Message

ivanhu Dec. 30, 2022, 5:38 a.m. UTC
BugLink: https://bugs.launchpad.net/fwts/+bug/2000752

The function fwts_acpi_reserved_type verify the type to see if in reserved,
which compares with the value with >=
if (value < min || value >= reserved) {

So it shouldn't pass the reserved value with RESERVED - 1.
Also modify the print out maximum value for reserved.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/hmat/hmat.c           | 2 +-
 src/acpi/nfit/nfit.c           | 2 +-
 src/acpi/phat/phat.c           | 2 +-
 src/acpi/pptt/pptt.c           | 2 +-
 src/lib/src/fwts_acpi_tables.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
index a3a3e005..f433a2d9 100644
--- a/src/acpi/hmat/hmat.c
+++ b/src/acpi/hmat/hmat.c
@@ -187,7 +187,7 @@  static int hmat_test1(fwts_framework *fw)
 			type_length = sizeof(fwts_acpi_table_hmat_cache) +
 			              ((fwts_acpi_table_hmat_cache *) entry)->num_smbios * 2;
 		} else {
-			fwts_acpi_reserved_type(fw, "HMAT", entry->type, 0, FWTS_HMAT_TYPE_RESERVED - 1, &passed);
+			fwts_acpi_reserved_type(fw, "HMAT", entry->type, 0, FWTS_HMAT_TYPE_RESERVED, &passed);
 			break;
 		}
 
diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c
index 1564b392..3d5166c1 100644
--- a/src/acpi/nfit/nfit.c
+++ b/src/acpi/nfit/nfit.c
@@ -503,7 +503,7 @@  static int nfit_test1(fwts_framework *fw)
 				reserved_passed = nfit_struct->reserved2;
 
 		} else {
-			fwts_acpi_reserved_type(fw, "NFIT", entry->type, 0, FWTS_NFIT_TYPE_RESERVED - 1, &passed);
+			fwts_acpi_reserved_type(fw, "NFIT", entry->type, 0, FWTS_NFIT_TYPE_RESERVED, &passed);
 			break;
 		}
 
diff --git a/src/acpi/phat/phat.c b/src/acpi/phat/phat.c
index c41dca3c..17832591 100644
--- a/src/acpi/phat/phat.c
+++ b/src/acpi/phat/phat.c
@@ -145,7 +145,7 @@  static int phat_test1(fwts_framework *fw)
 		} else if (entry->type == FWTS_PHAT_HEALTH) {
 			phat_health_test(fw, (fwts_acpi_table_phat_health *) entry, offset, &passed);
 		} else {
-			fwts_acpi_reserved_type(fw, "PHAT", entry->type, 0, FWTS_PHAT_RESERVED - 1, &passed);
+			fwts_acpi_reserved_type(fw, "PHAT", entry->type, 0, FWTS_PHAT_RESERVED, &passed);
 			break;
 		}
 
diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
index 61a71639..8fd605c0 100644
--- a/src/acpi/pptt/pptt.c
+++ b/src/acpi/pptt/pptt.c
@@ -153,7 +153,7 @@  static int pptt_test1(fwts_framework *fw)
 			pptt_id_test(fw, (fwts_acpi_table_pptt_id *) entry, &passed);
 			type_length = sizeof(fwts_acpi_table_pptt_id);
 		} else {
-			fwts_acpi_reserved_type(fw, "PPTT", entry->type, 0, FWTS_PPTT_RESERVED - 1, &passed);
+			fwts_acpi_reserved_type(fw, "PPTT", entry->type, 0, FWTS_PPTT_RESERVED, &passed);
 			break;
 		}
 
diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index 4521dd66..d39571a3 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -1601,7 +1601,7 @@  void fwts_acpi_reserved_type(
 		fwts_failed(fw, LOG_LEVEL_HIGH, label,
 			"%4.4s must have subtable with Type %" PRId8
 			"..%" PRId8 ", got %" PRId8 " instead",
-			table, min, reserved, value);
+			table, min, reserved - 1, value);
 
 		*passed = false;
 	}