]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mtd: maps: fix -Wvoid-pointer-to-enum-cast warning
authorJustin Stitt <justinstitt@google.com>
Wed, 16 Aug 2023 18:26:44 +0000 (18:26 +0000)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 18 Aug 2023 14:38:54 +0000 (16:38 +0200)
When building with clang 18 I see the following warning:
|       drivers/mtd/maps/physmap-versatile.c:209:25: warning: cast to smaller
|               integer type 'enum versatile_flashprot' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|         209 |                 versatile_flashprot = (enum versatile_flashprot)devid->data;

This is due to the fact that `devid->data` is a void* while `enum versatile_flashprot`
has the size of an int.

Cast `devid->data` to a uintptr_t to silence the above warning for clang
builds using W=1.

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: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230816-void-drivers-mtd-maps-physmap-versatile-v2-1-433a25272bfa@google.com
drivers/mtd/maps/physmap-versatile.c

index 8e15d514c82daf84e066e37feb5534f2357aa829..2e779111bf7949574f37694ecaf8d14059cd3e7e 100644 (file)
@@ -206,7 +206,7 @@ int of_flash_probe_versatile(struct platform_device *pdev,
                if (!sysnp)
                        return -ENODEV;
 
-               versatile_flashprot = (enum versatile_flashprot)devid->data;
+               versatile_flashprot = (uintptr_t)devid->data;
                rmap = syscon_node_to_regmap(sysnp);
                of_node_put(sysnp);
                if (IS_ERR(rmap))