Commit f3add6de authored by Justin Stitt's avatar Justin Stitt Committed by Jakub Kicinski

net: mdio: fix -Wvoid-pointer-to-enum-cast warning

When building with clang 18 I see the following warning:
|       drivers/net/mdio/mdio-xgene.c:338:13: warning: cast to smaller integer
|               type 'enum xgene_mdio_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|         338 |                 mdio_id = (enum xgene_mdio_id)of_id->data;

This is due to the fact that `of_id->data` is a void* while `enum
xgene_mdio_id` has the size of an int. This leads to truncation and
possible data loss.

Link: https://github.com/ClangBuiltLinux/linux/issues/1910Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarJustin Stitt <justinstitt@google.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20230815-void-drivers-net-mdio-mdio-xgene-v1-1-5304342e0659@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0c2d8227
......@@ -335,7 +335,7 @@ static int xgene_mdio_probe(struct platform_device *pdev)
of_id = of_match_device(xgene_mdio_of_match, &pdev->dev);
if (of_id) {
mdio_id = (enum xgene_mdio_id)of_id->data;
mdio_id = (uintptr_t)of_id->data;
} else {
#ifdef CONFIG_ACPI
const struct acpi_device_id *acpi_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment