diff mbox series

acpi: viot: fix build fail on bionic and focal

Message ID 20240116065238.231596-1-ivan.hu@canonical.com
State Accepted
Headers show
Series acpi: viot: fix build fail on bionic and focal | expand

Commit Message

ivanhu Jan. 16, 2024, 6:52 a.m. UTC
BugLing: https://bugs.launchpad.net/fwts/+bug/2049459

Got build fail below,
acpi/viot/viot.c:76:5: error: a label can only be part of a statement and a declaration is not a statement
   76 | fwts_acpi_viot_pci_rng_node *pci_rng = (fwts_acpi_viot_pci_rng_node *)(table->data + offset);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
acpi/viot/viot.c:93:5: error: a label can only be part of a statement and a declaration is not a statement
   93 | fwts_acpi_viot_mmio_ep_node *mmio_ep = (fwts_acpi_viot_mmio_ep_node *)(table->data + offset);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
acpi/viot/viot.c:107:5: error: a label can only be part of a statement and a declaration is not a statement
  107 | fwts_acpi_viot_pci_iommu_node *pci_iommu = (fwts_acpi_viot_pci_iommu_node *)(table->data + offset);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acpi/viot/viot.c:120:5: error: a label can only be part of a statement and a declaration is not a statement
  120 | fwts_acpi_viot_mmio_iommu_node *mmio_iommu = (fwts_acpi_viot_mmio_iommu_node *)(table->data + offset);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[4]: *** [Makefile:4244: acpi/viot/fwts-viot.o] Error 1

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/viot/viot.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/acpi/viot/viot.c b/src/acpi/viot/viot.c
index 74394fec..b6c3cb50 100644
--- a/src/acpi/viot/viot.c
+++ b/src/acpi/viot/viot.c
@@ -71,9 +71,14 @@  static int viot_test1(fwts_framework *fw)
 			return FWTS_OK;
 		}
 
+		fwts_acpi_viot_pci_rng_node *pci_rng = NULL;
+		fwts_acpi_viot_mmio_ep_node *mmio_ep = NULL;
+		fwts_acpi_viot_pci_iommu_node *pci_iommu = NULL;
+		fwts_acpi_viot_mmio_iommu_node *mmio_iommu = NULL;
+
 		switch(node_hdr->type) {
 			case 1:
-				fwts_acpi_viot_pci_rng_node *pci_rng = (fwts_acpi_viot_pci_rng_node *)(table->data + offset);
+				pci_rng = (fwts_acpi_viot_pci_rng_node *)(table->data + offset);
 				fwts_log_info_verbatim(fw, "  PCI Range Node Structure:");
 				fwts_log_info_simp_int(fw, "    Type:               ", pci_rng->hdr.type);
 				fwts_log_info_simp_int(fw, "    Reserved:           ", pci_rng->hdr.reserved);
@@ -90,7 +95,7 @@  static int viot_test1(fwts_framework *fw)
 				offset += sizeof(fwts_acpi_viot_pci_rng_node);
 				break;
 			case 2:
-				fwts_acpi_viot_mmio_ep_node *mmio_ep = (fwts_acpi_viot_mmio_ep_node *)(table->data + offset);
+				mmio_ep = (fwts_acpi_viot_mmio_ep_node *)(table->data + offset);
 				fwts_log_info_verbatim(fw, "  Single MMIO Endpoint Node Structure:");
 				fwts_log_info_simp_int(fw, "    Type:               ", mmio_ep->hdr.type);
 				fwts_log_info_simp_int(fw, "    Reserved:           ", mmio_ep->hdr.reserved);
@@ -104,7 +109,7 @@  static int viot_test1(fwts_framework *fw)
 				offset += sizeof(fwts_acpi_viot_mmio_ep_node);
 				break;
 			case 3:
-				fwts_acpi_viot_pci_iommu_node *pci_iommu = (fwts_acpi_viot_pci_iommu_node *)(table->data + offset);
+				pci_iommu = (fwts_acpi_viot_pci_iommu_node *)(table->data + offset);
 				fwts_log_info_verbatim(fw, "  Virtio-iommu based on virtio-pci Node Structure:");
 				fwts_log_info_simp_int(fw, "    Type:               ", pci_iommu->hdr.type);
 				fwts_log_info_simp_int(fw, "    Reserved:           ", pci_iommu->hdr.reserved);
@@ -117,7 +122,7 @@  static int viot_test1(fwts_framework *fw)
 				offset += sizeof(fwts_acpi_viot_pci_iommu_node);
 				break;
 			case 4:
-				fwts_acpi_viot_mmio_iommu_node *mmio_iommu = (fwts_acpi_viot_mmio_iommu_node *)(table->data + offset);
+				mmio_iommu = (fwts_acpi_viot_mmio_iommu_node *)(table->data + offset);
 				fwts_log_info_verbatim(fw, "  Virtio-iommu based on virtio-pci Node Structure:");
 				fwts_log_info_simp_int(fw, "    Type:               ", mmio_iommu->hdr.type);
 				fwts_log_info_simp_int(fw, "    Reserved:           ", mmio_iommu->hdr.reserved);