Skip to content

Commit

Permalink
mtd: maps: fix -Wvoid-pointer-to-enum-cast warning
Browse files Browse the repository at this point in the history
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: ClangBuiltLinux#1910
Reported-by: Nathan Chancellor <[email protected]>
Signed-off-by: Justin Stitt <[email protected]>
Signed-off-by: Miquel Raynal <[email protected]>
Link: https://lore.kernel.org/linux-mtd/20230816-void-drivers-mtd-maps-physmap-versatile-v2-1-433a25272bfa@google.com
  • Loading branch information
JustinStitt authored and miquelraynal committed Aug 18, 2023
1 parent 264725e commit a417ab3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/maps/physmap-versatile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit a417ab3

Please sign in to comment.