Skip to contentSkip to conversation

can-next: fix clang warnings

PATCH In review Marc Kleine-Budde 2 participants 5 messages May 4, 2021 – May 5, 2021 CAN network drivers

lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#0 lore raw

Hello,

This series fixes two warnings found by clang, the first one was reported by intel's kernel test robot.

Marc

author maintainer
#1 lore raw

PATCH 1/2 can: mcp251x: mcp251x_can_probe(): silence clang warning

This patch silences the following clang warning:

| drivers/net/can/spi/mcp251x.c:1333:17: warning: cast to smaller integer type
| 'enum mcp251x_model' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|                 priv->model = (enum mcp251x_model)match;
|                               ^~~~~~~~~~~~~~~~~~~~~~~~~
Fixes 8de29a5c34a5 ("can: mcp251x: Make use of device property API")
Cc Andy Shevchenko <[email protected]>
---
 drivers/net/can/spi/mcp251x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251x.c +1 -1
index 492f1bcb0516..275b2ddab143 100644
@@ -1343,7 +1343,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
 	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
 		CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
 	if (match)
-		priv->model = (enum mcp251x_model)match;
+		priv->model = (enum mcp251x_model)(kernel_ulong_t)match;
 	else
 		priv->model = spi_get_device_id(spi)->driver_data;
 	priv->net = net;

base-commit: 9d31d2338950293ec19d9b095fbaa9030899dcb4
prerequisite-patch-id: 2d99a92f9c04a76341ba84b5f4924c2ba03bdd88
prerequisite-patch-id: 6dbb40c8b889604bf57aa2374f34290b247b7d28
prerequisite-patch-id: 24ff9c746552e4a8e100200f13bb1732990392a3

Signature · 1 line
2.30.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [can-nextc 1/2] can: mcp251x: mcp251x_can_probe(): silence clang warning

Quoted 20 lines · Marc Kleine-Budde

This patch silences the following clang warning:

| drivers/net/can/spi/mcp251x.c:1333:17: warning: cast to smaller integer type
| 'enum mcp251x_model' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|                 priv->model = (enum mcp251x_model)match;
|                               ^~~~~~~~~~~~~~~~~~~~~~~~~
Fixes 8de29a5c34a5 ("can: mcp251x: Make use of device property API")
Cc Andy Shevchenko <[email protected]>
---
 drivers/net/can/spi/mcp251x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251x.c +0 -0
index 492f1bcb0516..275b2ddab143 100644

drivers/net/can/spi/mcp251x.c static int mcp251x_can_probe(struct spi_device *spi) · line 1346

Quoted 5 lines
drivers/net/can/spi/mcp251x.c +1 -1
@@ -1343,7 +1343,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
 	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
 		CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
 	if (match)
-		priv->model = (enum mcp251x_model)match;
+		priv->model = (enum mcp251x_model)(kernel_ulong_t)match;

Usually we use uintptr_t, but either way

Thanks!

Quoted 12 lines
drivers/net/can/spi/mcp251x.c +0 -0
 	else
 		priv->model = spi_get_device_id(spi)->driver_data;
 	priv->net = net;

base-commit: 9d31d2338950293ec19d9b095fbaa9030899dcb4
prerequisite-patch-id: 2d99a92f9c04a76341ba84b5f4924c2ba03bdd88
prerequisite-patch-id: 6dbb40c8b889604bf57aa2374f34290b247b7d28
prerequisite-patch-id: 24ff9c746552e4a8e100200f13bb1732990392a3

Signature · 1 line
2.30.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw

Re: [can-nextc 1/2] can: mcp251x: mcp251x_can_probe(): silence clang warning

Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Marc Kleine-Budde

This patch silences the following clang warning:

| drivers/net/can/spi/mcp251x.c:1333:17: warning: cast to smaller integer type
| 'enum mcp251x_model' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|                 priv->model = (enum mcp251x_model)match;
|                               ^~~~~~~~~~~~~~~~~~~~~~~~~
Fixes 8de29a5c34a5 ("can: mcp251x: Make use of device property API")
Cc Andy Shevchenko <[email protected]>
---
 drivers/net/can/spi/mcp251x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/net/can/spi/mcp251x.c static int mcp251x_can_probe(struct spi_device *spi) · line 1346

Quoted 10 lines
drivers/net/can/spi/mcp251x.c +1 -1
index 492f1bcb0516..275b2ddab143 100644
@@ -1343,7 +1343,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
 	priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
 		CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
 	if (match)
-		priv->model = (enum mcp251x_model)match;
+		priv->model = (enum mcp251x_model)(kernel_ulong_t)match;

Usually we use uintptr_t, but either way

I've updated the patch to uintptr_t.

Quoted 1 line

Thanks,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
author maintainer
#4 lore raw

PATCH 2/2 can: hi311x: hi3110_can_probe(): silence clang warning

In reply to Marc Kleine-Budde

This patch silences the following clang warning:

| drivers/net/can/spi/hi311x.c:874:17: warning: cast to smaller integer type
| 'enum hi3110_model' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|                 priv->model = (enum hi3110_model)of_id->data;
|                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes 57e83fb9b746 ("can: hi311x: Add Holt HI-311x CAN driver")
---
 drivers/net/can/spi/hi311x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/hi311x.c +1 -1
index 6f5d6d04a8b9..9ab480a1875f 100644
@@ -871,7 +871,7 @@ static int hi3110_can_probe(struct spi_device *spi)
 		CAN_CTRLMODE_BERR_REPORTING;
 
 	if (of_id)
-		priv->model = (enum hi3110_model)of_id->data;
+		priv->model = (enum hi3110_model)(kernel_ulong_t)of_id->data;
 	else
 		priv->model = spi_get_device_id(spi)->driver_data;
 	priv->net = net;
Signature · 1 line
2.30.2