drm/repaper: fix -Wvoid-pointer-to-enum-cast warning
authorJustin Stitt <justinstitt@google.com>
Wed, 16 Aug 2023 19:55:29 +0000 (19:55 +0000)
committerNoralf Trønnes <noralf@tronnes.org>
Fri, 25 Aug 2023 11:13:20 +0000 (13:13 +0200)
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;

Link: https://github.com/ClangBuiltLinux/linux/issues/1910
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230816-void-drivers-gpu-drm-tiny-repaper-v1-1-9d8d10f0d52f@google.com
drivers/gpu/drm/tiny/repaper.c

index 13ae148f59b9b5079ab6a91162a48684593bb1ee..73dd4f4289c20c8e7d2007af2ca8a247cdc381ab 100644 (file)
@@ -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;