drm/repaper: fix -Wvoid-pointer-to-enum-cast warning
PATCH 1/1 drm/repaper: fix -Wvoid-pointer-to-enum-cast warning
When building with clang 18 I see the following warning:
| drivers/gpu/drm/tiny/repaper.c:952:11: warning: cast to smaller integer | type 'enum repaper_model' from 'const void *' [-Wvoid-pointer-to-enum-cast] | 952 | model = (enum repaper_model)match; |
This is due to the fact that match is a void* while enum repaper_model has the size of an int.
Add uintptr_t cast to silence clang warning while also keeping enum cast for readability and consistency with other model assignment just a few lines below:
| model = (enum repaper_model)spi_id->driver_data;
--- drivers/gpu/drm/tiny/repaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tiny/repaper.c +1 -1
@@ -949,7 +949,7 @@ static int repaper_probe(struct spi_device *spi) match =device_get_match_data (dev);if (match) { - model = (enum repaper_model )match; + model = (enum repaper_model )(uintptr_t )match; }else { spi_id =spi_get_device_id (spi); model = (enum repaper_model )spi_id->driver_data;
---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230816-void-drivers-gpu-drm-tiny-repaper-a08321cd99d7
Best regards,
--
Justin Stitt <[email protected]>
Noralf Trønnes
AppliedQuoted 14 lines · Justin Stitt
When building with clang 18 I see the following warning:
| drivers/gpu/drm/tiny/repaper.c:952:11: warning: cast to smaller integer | type 'enum repaper_model' from 'const void *' [-Wvoid-pointer-to-enum-cast] | 952 | model = (enum repaper_model)match; |This is due to the fact that
matchis a void* whileenum repaper_modelhas the size of an int.Add
uintptr_tcast to silence clang warning while also keeping enum cast for readability and consistency with othermodelassignment just a few lines below:
| model = (enum repaper_model)spi_id->driver_data;
Quoted 4 lines
Reported-by Nathan Chancellor <[email protected]>Signed-off-by Justin Stitt <[email protected]>---
Thanks, applied to drm-misc-next.
Noralf.
Quoted 25 lines
drivers/gpu/drm/tiny/repaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/tiny/repaper.c +1
-2@@ -949,7 +949,7 @@ static int repaper_probe(struct spi_device *spi) match =device_get_match_data (dev);if (match) { - model = (enum repaper_model )match; + model = (enum repaper_model )(uintptr_t )match; }else { spi_id =spi_get_device_id (spi); model = (enum repaper_model )spi_id->driver_data; ---base-commit:
2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230816-void-drivers-gpu-drm-tiny-repaper-a08321cd99d7Best regards,
--
Justin Stitt <[email protected]>