* [PATCH] drm/sched: Fix clang build warning in kunit tests
@ 2026-05-22 9:01 Tvrtko Ursulin
2026-05-25 9:09 ` Claude review: " Claude Code Review Bot
2026-05-25 9:09 ` Claude Code Review Bot
0 siblings, 2 replies; 3+ messages in thread
From: Tvrtko Ursulin @ 2026-05-22 9:01 UTC (permalink / raw)
To: dri-devel; +Cc: kernel-dev, Tvrtko Ursulin, kernel test robot, Philipp Stanner
Initializing compile time constant struct or arrays from another such
variable is a gcc extension, while clang strictly requires a compile time
constant literal.
As reported by LKP:
>> drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error: initializer element is not a compile-time constant
drm_sched_scheduler_two_clients_attr),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/kunit/test.h:224:13: note: expanded from macro 'KUNIT_CASE_PARAM_ATTR'
.attr = attributes, .module_name = KBUILD_MODNAME}
^~~~~~~~~~
1 error generated.
vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c
671
672 static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
673 KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
674 drm_sched_scheduler_two_clients_gen_params,
> 675 drm_sched_scheduler_two_clients_attr),
676 {}
677 };
678
Fix it by using a compound literal as other tests do.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605220312.Pu7UO05u-lkp@intel.com/
Fixes: 97ef806a5314 ("drm/sched: Add some scheduling quality unit tests")
Cc: Philipp Stanner <phasta@kernel.org>
---
drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/tests/tests_scheduler.c b/drivers/gpu/drm/scheduler/tests/tests_scheduler.c
index 8b2e4ef9915f..90d31888cf92 100644
--- a/drivers/gpu/drm/scheduler/tests/tests_scheduler.c
+++ b/drivers/gpu/drm/scheduler/tests/tests_scheduler.c
@@ -666,14 +666,10 @@ static void drm_sched_scheduler_two_clients_test(struct kunit *test)
}
}
-static const struct kunit_attributes drm_sched_scheduler_two_clients_attr = {
- .speed = KUNIT_SPEED_SLOW,
-};
-
static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
drm_sched_scheduler_two_clients_gen_params,
- drm_sched_scheduler_two_clients_attr),
+ { .speed = KUNIT_SPEED_SLOW }),
{}
};
@@ -858,14 +854,10 @@ static void drm_sched_scheduler_many_clients_test(struct kunit *test)
drm_mock_sched_entity_free(client[i].entity);
}
-static const struct kunit_attributes drm_sched_scheduler_many_clients_attr = {
- .speed = KUNIT_SPEED_SLOW,
-};
-
static struct kunit_case drm_sched_scheduler_many_clients_tests[] = {
KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test,
drm_sched_scheduler_many_clients_gen_params,
- drm_sched_scheduler_many_clients_attr),
+ { .speed = KUNIT_SPEED_SLOW }),
{}
};
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Claude review: drm/sched: Fix clang build warning in kunit tests
2026-05-22 9:01 [PATCH] drm/sched: Fix clang build warning in kunit tests Tvrtko Ursulin
@ 2026-05-25 9:09 ` Claude Code Review Bot
2026-05-25 9:09 ` Claude Code Review Bot
1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-25 9:09 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: drm/sched: Fix clang build warning in kunit tests
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Patches: 1
Reviewed: 2026-05-25T19:09:07.112976
---
This is a single, straightforward build fix patch. The clang compiler strictly requires compile-time constant literals in initializer elements, whereas GCC accepts `const` variables as an extension. The fix replaces two `static const struct kunit_attributes` variables with inline compound literals, which is the correct and idiomatic approach — consistent with how every other `KUNIT_CASE_PARAM_ATTR` caller in the kernel tree already does it (xe_bo.c, ext4/mballoc-test.c, etc.).
The patch is correct, minimal, and well-motivated. No concerns.
**Recommendation: Accept as-is.**
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Claude review: drm/sched: Fix clang build warning in kunit tests
2026-05-22 9:01 [PATCH] drm/sched: Fix clang build warning in kunit tests Tvrtko Ursulin
2026-05-25 9:09 ` Claude review: " Claude Code Review Bot
@ 2026-05-25 9:09 ` Claude Code Review Bot
1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-25 9:09 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Correctness: Good.** The macro `KUNIT_CASE_PARAM_ATTR` expands `.attr = attributes` directly into a struct initializer (line 224 of `include/kunit/test.h`). When `attributes` is a named `const` variable, GCC accepts it but clang rejects it because it's not a compile-time constant expression per the C standard. Replacing with a compound literal `{ .speed = KUNIT_SPEED_SLOW }` is the standard-conforming fix.
**Consistency: Good.** The existing callers in the tree already use this pattern:
- `drivers/gpu/drm/xe/tests/xe_bo.c:622`: `{.speed = KUNIT_SPEED_SLOW}`
- `fs/ext4/mballoc-test.c:990`: `{ .speed = KUNIT_SPEED_SLOW }`
The patch matches the style with designated initializer and spaces inside braces, consistent with the ext4 usage.
**Completeness: Good.** Both instances in the file (`drm_sched_scheduler_two_clients_tests` and `drm_sched_scheduler_many_clients_tests`) are fixed, and the now-unused `static const` variables are removed.
**Commit message: Good.** Clearly explains the problem with the LKP bot error output, references the fix approach ("compound literal as other tests do"), and has appropriate tags (Reported-by, Closes, Fixes, Cc).
**Minor note:** The `cs35l56-shared-test.c:857` caller uses `{ KUNIT_SPEED_SLOW }` (positional initializer) rather than `{ .speed = KUNIT_SPEED_SLOW }` (designated initializer). The designated initializer form used in this patch is preferable as it's more explicit and resilient to struct layout changes.
**No issues found.** Clean, minimal fix.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-25 9:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22 9:01 [PATCH] drm/sched: Fix clang build warning in kunit tests Tvrtko Ursulin
2026-05-25 9:09 ` Claude review: " Claude Code Review Bot
2026-05-25 9:09 ` 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