public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check()
@ 2026-03-12 21:46 Nathan Chancellor
  2026-03-13  3:44 ` Claude review: " Claude Code Review Bot
  2026-03-13  3:44 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-03-12 21:46 UTC (permalink / raw)
  To: Alex Deucher, Christian König
  Cc: Likun Gao, Hawking Zhang, amd-gfx, dri-devel, llvm, patches,
	Nathan Chancellor

When building with a version of clang that supports the narrower
'-fms-anonymous-structs' (as opposed to the wider '-fms-extensions')
along with the associated kernel support (such as in next-20260312 [1]),
there are warnings (or errors with CONFIG_WERROR=y / W=e) from the
switch statement added by commit 47ab777c16c7 ("drm/amdgpu/discovery:
use common function to check discovery table").

  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:560:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
    560 |                 struct ip_discovery_header *ihdr =
        |                 ^
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:568:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
    568 |                 struct gpu_info_header *ghdr =
        |                 ^
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:576:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
    576 |                 struct harvest_info_header *hhdr =
        |                 ^
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:584:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
    584 |                 struct vcn_info_header *vhdr =
        |                 ^
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:592:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
    592 |                 struct mall_info_header *mhdr =
        |                 ^

If '-fms-extensions' were not present, this would be a hard error in
older clang versions.

Add braces to the case statements that declare variables to clear up the
warnings.

Fixes: 47ab777c16c7 ("drm/amdgpu/discovery: use common function to check discovery table")
Link: https://git.kernel.org/next/linux-next/c/0d3fccf68d9873a3c824fb70be0dbb2c4642aa90 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index f9f785c5d8ac..4209945af66f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -556,7 +556,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
 	checksum = le16_to_cpu(info->checksum);
 
 	switch (table_id) {
-	case IP_DISCOVERY:
+	case IP_DISCOVERY: {
 		struct ip_discovery_header *ihdr =
 			(struct ip_discovery_header *)(discovery_bin + offset);
 		act_val = le32_to_cpu(ihdr->signature);
@@ -564,7 +564,8 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
 		table_size = le16_to_cpu(ihdr->size);
 		table_name = "data table";
 		break;
-	case GC:
+	}
+	case GC: {
 		struct gpu_info_header *ghdr =
 			(struct gpu_info_header *)(discovery_bin + offset);
 		act_val = le32_to_cpu(ghdr->table_id);
@@ -572,7 +573,8 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
 		table_size = le16_to_cpu(ghdr->size);
 		table_name = "gc table";
 		break;
-	case HARVEST_INFO:
+	}
+	case HARVEST_INFO: {
 		struct harvest_info_header *hhdr =
 			(struct harvest_info_header *)(discovery_bin + offset);
 		act_val = le32_to_cpu(hhdr->signature);
@@ -580,7 +582,8 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
 		table_size = sizeof(struct harvest_table);
 		table_name = "harvest table";
 		break;
-	case VCN_INFO:
+	}
+	case VCN_INFO: {
 		struct vcn_info_header *vhdr =
 			(struct vcn_info_header *)(discovery_bin + offset);
 		act_val = le32_to_cpu(vhdr->table_id);
@@ -588,7 +591,8 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
 		table_size = le32_to_cpu(vhdr->size_bytes);
 		table_name = "vcn table";
 		break;
-	case MALL_INFO:
+	}
+	case MALL_INFO: {
 		struct mall_info_header *mhdr =
 			(struct mall_info_header *)(discovery_bin + offset);
 		act_val = le32_to_cpu(mhdr->table_id);
@@ -597,6 +601,7 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
 		table_name = "mall table";
 		check_table = false;
 		break;
+	}
 	default:
 		dev_err(adev->dev, "invalid ip discovery table id %d specified\n", table_id);
 		check_table = false;

---
base-commit: 7a9419ab42699fd3d4c857ef81ae097d8d8d5899
change-id: 20260312-amdgpu-fix-clang-c23-extensions-1fb28eee64c2

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Claude review: drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check()
  2026-03-12 21:46 [PATCH] drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check() Nathan Chancellor
  2026-03-13  3:44 ` Claude review: " Claude Code Review Bot
@ 2026-03-13  3:44 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-13  3:44 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check()
Author: Nathan Chancellor <nathan@kernel.org>
Patches: 1
Reviewed: 2026-03-13T13:44:39.541822

---

This is a single-patch fix from Nathan Chancellor addressing a clang C23 compatibility warning/error in `amdgpu_discovery.c`. The issue is well-known: in C11/C17, a `case` label cannot be directly followed by a declaration — only by a statement. Clang flags this as `-Wc23-extensions` since C23 relaxes this restriction, but the kernel currently targets C11. The fix is the standard, idiomatic solution: wrap each case body in braces to create a compound statement, which allows declarations at the top.

**Verdict: The patch is correct and ready to merge.**

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Claude review: drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check()
  2026-03-12 21:46 [PATCH] drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check() Nathan Chancellor
@ 2026-03-13  3:44 ` Claude Code Review Bot
  2026-03-13  3:44 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-13  3:44 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness:** The fix is textbook correct. Each of the five `case` labels (`IP_DISCOVERY`, `GC`, `HARVEST_INFO`, `VCN_INFO`, `MALL_INFO`) that declares a local variable immediately after the label is wrapped with `{ ... }` braces. The opening brace is placed after the colon on the `case` line, and the closing brace is placed before the next `case` (or `default`). Each case already ends with `break;`, so the braces don't change control flow.

**Commit message:** Excellent. Clearly explains the problem (clang with `-fms-anonymous-structs` instead of `-fms-extensions`), references the triggering commit (`47ab777c16c7`), provides the exact compiler error messages, links to the relevant linux-next commit enabling the new flag, and has a proper `Fixes:` tag.

**Style:** The brace placement follows kernel coding style. The diff is minimal — only 10 insertions and 5 deletions, all purely mechanical.

**No issues found.** This is a clean, minimal compiler-compatibility fix with no functional change.

Reviewed-by: AI Reviewer (automated)

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-13  3:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 21:46 [PATCH] drm/amdgpu/discovery: Add braces to case statements in amdgpu_discovery_table_check() Nathan Chancellor
2026-03-13  3:44 ` Claude review: " Claude Code Review Bot
2026-03-13  3:44 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox