All of lore.kernel.org
 help / color / mirror / Atom feed
From: Victor Erminpour <victor.erminpour@oracle.com>
To: lorenzo.pieralisi@arm.com
Cc: guohanjun@huawei.com, sudeep.holla@arm.com, rafael@kernel.org,
	lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, trivial@kernel.org,
	victor.erminpour@oracle.com
Subject: [PATCH] ACPI/IORT: Fix GCC 12 warning
Date: Wed,  9 Feb 2022 16:32:21 -0800	[thread overview]
Message-ID: <1644453141-1181-1-git-send-email-victor.erminpour@oracle.com> (raw)

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
  1670 |                         struct acpi_iort_named_component *ncomp;
       |                                                           ^~~~~

Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
---
 drivers/acpi/arm64/iort.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 3b23fb775ac4..5c5d2e56d756 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
  */
 phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 {
-	phys_addr_t limit = PHYS_ADDR_MAX;
+	phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
 	struct acpi_iort_node *node, *end;
 	struct acpi_table_iort *iort;
 	acpi_status status;
@@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 			break;
 
 		switch (node->type) {
-			struct acpi_iort_named_component *ncomp;
-			struct acpi_iort_root_complex *rc;
-			phys_addr_t local_limit;
-
 		case ACPI_IORT_NODE_NAMED_COMPONENT:
+			struct acpi_iort_named_component *ncomp;
 			ncomp = (struct acpi_iort_named_component *)node->node_data;
 			local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
 			limit = min_not_zero(limit, local_limit);
 			break;
 
 		case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+			struct acpi_iort_root_complex *rc;
 			if (node->revision < 1)
 				break;
 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Victor Erminpour <victor.erminpour@oracle.com>
To: lorenzo.pieralisi@arm.com
Cc: guohanjun@huawei.com, sudeep.holla@arm.com, rafael@kernel.org,
	lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, trivial@kernel.org,
	victor.erminpour@oracle.com
Subject: [PATCH] ACPI/IORT: Fix GCC 12 warning
Date: Wed,  9 Feb 2022 16:32:21 -0800	[thread overview]
Message-ID: <1644453141-1181-1-git-send-email-victor.erminpour@oracle.com> (raw)

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
  1670 |                         struct acpi_iort_named_component *ncomp;
       |                                                           ^~~~~

Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
---
 drivers/acpi/arm64/iort.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 3b23fb775ac4..5c5d2e56d756 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
  */
 phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 {
-	phys_addr_t limit = PHYS_ADDR_MAX;
+	phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
 	struct acpi_iort_node *node, *end;
 	struct acpi_table_iort *iort;
 	acpi_status status;
@@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 			break;
 
 		switch (node->type) {
-			struct acpi_iort_named_component *ncomp;
-			struct acpi_iort_root_complex *rc;
-			phys_addr_t local_limit;
-
 		case ACPI_IORT_NODE_NAMED_COMPONENT:
+			struct acpi_iort_named_component *ncomp;
 			ncomp = (struct acpi_iort_named_component *)node->node_data;
 			local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
 			limit = min_not_zero(limit, local_limit);
 			break;
 
 		case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+			struct acpi_iort_root_complex *rc;
 			if (node->revision < 1)
 				break;
 

             reply	other threads:[~2022-02-10  0:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10  0:32 Victor Erminpour [this message]
2022-02-10  0:32 ` [PATCH] ACPI/IORT: Fix GCC 12 warning Victor Erminpour
2022-02-10  9:11 ` Ard Biesheuvel
2022-02-10  9:11   ` Ard Biesheuvel
2022-02-10 17:36   ` Victor Erminpour
2022-02-10 17:36     ` Victor Erminpour
2022-02-10 19:29     ` Ard Biesheuvel
2022-02-10 19:29       ` Ard Biesheuvel
2022-02-10 19:39       ` Ard Biesheuvel
2022-02-10 19:39         ` Ard Biesheuvel
2022-02-10 18:06 ` Robin Murphy
2022-02-10 18:06   ` Robin Murphy
2022-02-10 18:27   ` Victor Erminpour
2022-02-10 18:27     ` Victor Erminpour
2022-02-10 18:35     ` Robin Murphy
2022-02-10 18:35       ` Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1644453141-1181-1-git-send-email-victor.erminpour@oracle.com \
    --to=victor.erminpour@oracle.com \
    --cc=guohanjun@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rafael@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.