forked from ClangBuiltLinux/tc-build
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: Add patch for __counted_by error
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
- Loading branch information
1 parent
fcd5e76
commit 8e0451d
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
From 0f2fd37c141110e2763742376c9f6c9dd21b7416 Mon Sep 17 00:00:00 2001 | ||
From: Bill Wendling <morbo@google.com> | ||
Date: Wed, 29 May 2024 14:54:44 -0700 | ||
Subject: [PATCH] drm/radeon: Remove __counted_by from StateArray.states[] | ||
|
||
Work for __counted_by on generic pointers in structures (not just | ||
flexible array members) has started landing in Clang 19 (current tip of | ||
tree). During the development of this feature, a restriction was added | ||
to __counted_by to prevent the flexible array member's element type from | ||
including a flexible array member itself such as: | ||
|
||
struct foo { | ||
int count; | ||
char buf[]; | ||
}; | ||
|
||
struct bar { | ||
int count; | ||
struct foo data[] __counted_by(count); | ||
}; | ||
|
||
because the size of data cannot be calculated with the standard array | ||
size formula: | ||
|
||
sizeof(struct foo) * count | ||
|
||
This restriction was downgraded to a warning but due to CONFIG_WERROR, | ||
it can still break the build. The application of __counted_by on the | ||
states member of 'struct _StateArray' triggers this restriction, | ||
resulting in: | ||
|
||
drivers/gpu/drm/radeon/pptable.h:442:5: error: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size] | ||
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries); | ||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
1 error generated. | ||
|
||
Remove this use of __counted_by to fix the warning/error. However, | ||
rather than remove it altogether, leave it commented, as it may be | ||
possible to support this in future compiler releases. | ||
|
||
Cc: stable@vger.kernel.org | ||
Closes: https://github.com/ClangBuiltLinux/linux/issues/2028 | ||
Fixes: efade6fe50e7 ("drm/radeon: silence UBSAN warning (v3)") | ||
Signed-off-by: Bill Wendling <morbo@google.com> | ||
Co-developed-by: Nathan Chancellor <nathan@kernel.org> | ||
Signed-off-by: Nathan Chancellor <nathan@kernel.org> | ||
Signed-off-by: Alex Deucher <alexander.deucher@amd.com> | ||
--- | ||
Link: https://gitlab.freedesktop.org/agd5f/linux/-/commit/0f2fd37c141110e2763742376c9f6c9dd21b7416 | ||
--- | ||
drivers/gpu/drm/radeon/pptable.h | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/drivers/gpu/drm/radeon/pptable.h b/drivers/gpu/drm/radeon/pptable.h | ||
index b7f22597ee95e..969a8fb0ee9e0 100644 | ||
--- a/drivers/gpu/drm/radeon/pptable.h | ||
+++ b/drivers/gpu/drm/radeon/pptable.h | ||
@@ -439,7 +439,7 @@ typedef struct _StateArray{ | ||
//how many states we have | ||
UCHAR ucNumEntries; | ||
|
||
- ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries); | ||
+ ATOM_PPLIB_STATE_V2 states[] /* __counted_by(ucNumEntries) */; | ||
}StateArray; | ||
|
||
|
||
-- | ||
GitLab | ||
|