[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230815-void-drivers-net-mdio-mdio-xgene-v1-1-5304342e0659@google.com>
Date: Tue, 15 Aug 2023 20:35:59 +0000
From: Justin Stitt <justinstitt@...gle.com>
To: Iyappan Subramanian <iyappan@...amperecomputing.com>,
Keyur Chudgar <keyur@...amperecomputing.com>, Quan Nguyen <quan@...amperecomputing.com>,
Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Nathan Chancellor <nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>, Tom Rix <trix@...hat.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
Justin Stitt <justinstitt@...gle.com>
Subject: [PATCH] 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/1910
Reported-by: Nathan Chancellor <nathan@...nel.org>
Signed-off-by: Justin Stitt <justinstitt@...gle.com>
---
Note: `xgene_mdio_id` has only two fields enumerated from 1 which means
this is no data loss happening here. Either way, this patch helps the
goal of eventually enabling this warning for more builds by reducing
noise.
---
drivers/net/mdio/mdio-xgene.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mdio/mdio-xgene.c b/drivers/net/mdio/mdio-xgene.c
index 7aafc221b5cf..7119eb11c00d 100644
--- a/drivers/net/mdio/mdio-xgene.c
+++ b/drivers/net/mdio/mdio-xgene.c
@@ -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;
---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230815-void-drivers-net-mdio-mdio-xgene-e5b3b4a3343b
Best regards,
--
Justin Stitt <justinstitt@...gle.com>
Powered by blists - more mailing lists