* [PATCH] ASoC: rt5677: fix -Wvoid-pointer-to-enum-cast warning
@ 2023-08-14 21:58 Justin Stitt
2023-08-15 12:54 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Justin Stitt @ 2023-08-14 21:58 UTC (permalink / raw)
To: Oder Chiou, Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: alsa-devel, linux-kernel, Nathan Chancellor, Justin Stitt
`match_id->data` is a void* and as such is being truncated when cast to
`enum rt5677_type` which is only int-width.
There is likely no data loss occurring, though, as `enum rt5677_type`
consists of only two fields from 0 to 1 wherein obviously no data loss
happens from pointer-width -> int-width.
Link: https://github.com/ClangBuiltLinux/linux/issues/1910
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
Note: I'm not sure if `uintptr_t` is the correct solution here as I've
also seen a cast to `unsigned long` suffice. Any thoughts on the
semantically correct option?
---
sound/soc/codecs/rt5677.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index ad14d18860fc..278cb0b265e5 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -5578,7 +5578,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c)
match_id = of_match_device(rt5677_of_match, &i2c->dev);
if (match_id)
- rt5677->type = (enum rt5677_type)match_id->data;
+ rt5677->type = (uintptr_t)match_id->data;
} else if (ACPI_HANDLE(&i2c->dev)) {
const struct acpi_device_id *acpi_id;
---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230814-void-sound-soc-codecs-rt5677-dfc041c1a734
Best regards,
--
Justin Stitt <justinstitt@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: rt5677: fix -Wvoid-pointer-to-enum-cast warning
2023-08-14 21:58 [PATCH] ASoC: rt5677: fix -Wvoid-pointer-to-enum-cast warning Justin Stitt
@ 2023-08-15 12:54 ` Mark Brown
2023-08-15 14:15 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2023-08-15 12:54 UTC (permalink / raw)
To: Justin Stitt
Cc: Oder Chiou, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
alsa-devel, linux-kernel, Nathan Chancellor
[-- Attachment #1: Type: text/plain, Size: 249 bytes --]
On Mon, Aug 14, 2023 at 09:58:56PM +0000, Justin Stitt wrote:
> `match_id->data` is a void* and as such is being truncated when cast to
> `enum rt5677_type` which is only int-width.
This doesn't apply against current code, please check and resend.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: rt5677: fix -Wvoid-pointer-to-enum-cast warning
2023-08-15 12:54 ` Mark Brown
@ 2023-08-15 14:15 ` Nathan Chancellor
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-08-15 14:15 UTC (permalink / raw)
To: Mark Brown
Cc: Justin Stitt, Oder Chiou, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-kernel
On Tue, Aug 15, 2023 at 01:54:40PM +0100, Mark Brown wrote:
> On Mon, Aug 14, 2023 at 09:58:56PM +0000, Justin Stitt wrote:
> > `match_id->data` is a void* and as such is being truncated when cast to
> > `enum rt5677_type` which is only int-width.
>
> This doesn't apply against current code, please check and resend.
It looks like Andy fixed this warning as part of the refactoring to
device_get_match_data():
https://git.kernel.org/broonie/sound/c/043bb9c012ee7d092a477159cc66dbdf62fd2666
Cheers,
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-15 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 21:58 [PATCH] ASoC: rt5677: fix -Wvoid-pointer-to-enum-cast warning Justin Stitt
2023-08-15 12:54 ` Mark Brown
2023-08-15 14:15 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®