lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230816-void-drivers-gpu-drm-pl111-pl111_versatile-v1-1-92125dd9e6d4@google.com>
Date:   Wed, 16 Aug 2023 20:05:37 +0000
From:   Justin Stitt <justinstitt@...gle.com>
To:     Emma Anholt <emma@...olt.net>, David Airlie <airlied@...il.com>,
        Daniel Vetter <daniel@...ll.ch>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Tom Rix <trix@...hat.com>
Cc:     dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
        llvm@...ts.linux.dev, Justin Stitt <justinstitt@...gle.com>
Subject: [PATCH] drm: pl111: fix clang -Wvoid-pointer-to-enum-cast warning

When building with clang 18 I see the following warnings:
|1.     drivers/gpu/drm/pl111/pl111_versatile.c:487:24: warning: cast to smaller
|       integer type 'enum versatile_clcd' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|         487 |         versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
-
|2.     drivers/gpu/drm/pl111/pl111_versatile.c:507:26: warning: cast to smaller
|       integer type 'enum versatile_clcd' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|         507 |                         versatile_clcd_type = (enum versatile_clcd)clcd_id->data;

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

Cast `clcd_id->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@...nel.org>
Signed-off-by: Justin Stitt <justinstitt@...gle.com>
---
 drivers/gpu/drm/pl111/pl111_versatile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/pl111/pl111_versatile.c b/drivers/gpu/drm/pl111/pl111_versatile.c
index 00c3ebd32359..d6fd9e51377e 100644
--- a/drivers/gpu/drm/pl111/pl111_versatile.c
+++ b/drivers/gpu/drm/pl111/pl111_versatile.c
@@ -484,7 +484,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
 		return 0;
 	}
 
-	versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
+	versatile_clcd_type = (enum versatile_clcd)(uintptr_t)clcd_id->data;
 
 	/* Versatile Express special handling */
 	if (versatile_clcd_type == VEXPRESS_CLCD_V2M) {
@@ -504,7 +504,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
 		np = of_find_matching_node_and_match(NULL, impd1_clcd_of_match,
 						     &clcd_id);
 		if (np)
-			versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
+			versatile_clcd_type = (enum versatile_clcd)(uintptr_t)clcd_id->data;
 	}
 
 	map = syscon_node_to_regmap(np);

---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230816-void-drivers-gpu-drm-pl111-pl111_versatile-43b109cfa7ad

Best regards,
--
Justin Stitt <justinstitt@...gle.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ