Skip to contentSkip to conversation

sfc: It's a small cleanup to use ERR_CAST() here.

PATCH In review Rohit Chavan 2 participants 2 messages Sep 6, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sfc: It's a small cleanup to use ERR_CAST() here.

Using ERR_CAST() is more reasonable and safer, When it is necessary to convert the type of an error pointer and return it.

---
 drivers/net/ethernet/sfc/tc_counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sfc/tc_counters.c +1 -1
index c44088424323..76d32641202b 100644
@@ -249,7 +249,7 @@ struct efx_tc_counter_index *efx_tc_flower_get_counter_index(
 					       &ctr->linkage,
 					       efx_tc_counter_id_ht_params);
 			kfree(ctr);
-			return (void *)cnt; /* it's an ERR_PTR */
+			return ERR_CAST(cnt); /* it's an ERR_PTR */
 		}
 		ctr->cnt = cnt;
 		refcount_set(&ctr->ref, 1);
Signature · 1 line
2.34.1
#1 lore raw

This was already done as
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=74ce94ac38a6

Thanks,
Martin

Quoted 24 lines · Rohit Chavan

Using ERR_CAST() is more reasonable and safer, When it is necessary to convert the type of an error pointer and return it.

---
 drivers/net/ethernet/sfc/tc_counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sfc/tc_counters.c +1 -1
index c44088424323..76d32641202b 100644
@@ -249,7 +249,7 @@ struct efx_tc_counter_index *efx_tc_flower_get_counter_index(
 					       &ctr->linkage,
 					       efx_tc_counter_id_ht_params);
 			kfree(ctr);
-			return (void *)cnt; /* it's an ERR_PTR */
+			return ERR_CAST(cnt); /* it's an ERR_PTR */
 		}
 		ctr->cnt = cnt;
 		refcount_set(&ctr->ref, 1);
Signature · 1 line
2.34.1