[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230815-void-drivers-net-ethernet-ni-nixge-v1-1-f096a6e43038@google.com>
Date: Tue, 15 Aug 2023 20:50:13 +0000
From: Justin Stitt <justinstitt@...gle.com>
To: "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: nixge: fix -Wvoid-pointer-to-enum-cast warning
When building with clang 18 I see the following warning:
| drivers/net/ethernet/ni/nixge.c:1273:12: warning: cast to smaller integer
| type 'enum nixge_version' from 'const void *' [-Wvoid-pointer-to-enum-cast]
| 1273 | version = (enum nixge_version)of_id->data;
This is due to the fact that `of_id->data` is a void* while `enum nixge_version`
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: There is likely no data loss occurring here since `enum nixge_version`
has only a few fields which aren't nearly large enough to cause data
loss. However, this patch still works towards the goal of enabling this
warning for more builds by reducing noise.
---
drivers/net/ethernet/ni/nixge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 0fd156286d4d..105977804e6a 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -1270,7 +1270,7 @@ static int nixge_of_get_resources(struct platform_device *pdev)
if (!of_id)
return -ENODEV;
- version = (enum nixge_version)of_id->data;
+ version = (uintptr_t)of_id->data;
if (version <= NIXGE_V2)
priv->dma_regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
else
---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230815-void-drivers-net-ethernet-ni-nixge-37b465831af0
Best regards,
--
Justin Stitt <justinstitt@...gle.com>
Powered by blists - more mailing lists