[v5,04/52] eventdev: replace strerror with reentrant version

Message ID 20241104111037.3632161-5-huangdengdui@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series replace strerror |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

huangdengdui Nov. 4, 2024, 11:09 a.m. UTC
The function strerror() is insecure in a multi-thread environment.
This patch uses strerror_r() to replace it.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
---
 lib/eventdev/rte_event_eth_rx_adapter.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 3ee20d95f3..01fa862334 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1082,6 +1082,7 @@  rxa_intr_ring_enqueue(struct event_eth_rx_adapter *rx_adapter, void *data)
 	union queue_data qd;
 	struct eth_device_info *dev_info;
 	struct eth_rx_queue_info *queue_info;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int *intr_enabled;
 
 	qd.ptr = data;
@@ -1104,9 +1105,12 @@  rxa_intr_ring_enqueue(struct event_eth_rx_adapter *rx_adapter, void *data)
 		 * vectors supported (an interrupt vector is shared in
 		 * case of shared interrupts)
 		 */
-		if (err)
+		if (err) {
+			if (strerror_r(-err, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -err);
 			RTE_EDEV_LOG_ERR("Failed to enqueue interrupt"
-				" to ring: %s", strerror(-err));
+				" to ring: %s", errmsg);
+		}
 		else
 			rte_eth_dev_rx_intr_disable(port_id, queue);
 	}