From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2000945C49; Fri, 1 Nov 2024 10:16:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2667340298; Fri, 1 Nov 2024 10:16:34 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 3E3E640264 for ; Fri, 1 Nov 2024 10:16:30 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XfwCQ1PqCzdZLc; Fri, 1 Nov 2024 17:13:54 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id B28961800A5; Fri, 1 Nov 2024 17:16:28 +0800 (CST) Received: from [10.67.121.193] (10.67.121.193) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 1 Nov 2024 17:16:28 +0800 Message-ID: <4677c933-b60b-462d-b7bc-2e9ca345edfe@huawei.com> Date: Fri, 1 Nov 2024 17:16:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 00/42] replace strerror Content-Language: en-US To: Thomas Monjalon CC: Stephen Hemminger , , , , , , , , , References: <20231114082539.1858594-44-huangdengdui@huawei.com> <20241023084237.4da0ae1b@hermes.local> <56ac151b-79e9-461e-9ace-83af7b602eff@huawei.com> <4609477.bm5RmrZB5H@thomas> From: huangdengdui In-Reply-To: <4609477.bm5RmrZB5H@thomas> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.193] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500011.china.huawei.com (7.185.36.84) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2024/10/26 5:56, Thomas Monjalon wrote: > 24/10/2024 08:47, huangdengdui: >> On 2024/10/23 23:42, Stephen Hemminger wrote: >>> On Wed, 23 Oct 2024 16:28:10 +0800 >>> Dengdui Huang wrote: >>> >>>> The function strerror() is insecure in a multi-thread environment. >>>> It is better to use rte_strerror() instead of strerror(). >>>> In this patchset, only the libs and drivers are modified. >>> >>> Even rte_strerror is not completely safe. It depends on the calling >>> thread being a registered lcore. >> >> As discussed earlier, it is still safe if used from non-DPDK registered threads[1]: >> >> #define RTE_DEFINE_PER_LCORE(type, name) \ >> __thread __typeof__(type) per_lcore_##name >> >> [1]: https://elixir.bootlin.com/dpdk/v23.11-rc3/source/lib/eal/include/rte_per_lcore.h#L37 >> >>> >>> It would be better to use a coccinelle script to do direct replacement >>> with strerror_r(). >>> >>> Also, rte_strerror is not signal safe. >> >> Can we use strerror_r() in the signal processing context and replace it with rte_strerror() everywhere else? > > It does not make sense to use rte_strerror after libc functions. > Please restrict the use of rte_strerror for error numbers from DPDK functions. > > The Windows platform does not support strerror_r(). Using strerror_r() instead of strerror() is not a good idea, Platform differences have been handled in rte_strerror()[1]. The rte_strerror() can also handle errno from libc functions[2][3]. So is it better to use rte_strerror() instead of strerror()? [1]https://elixir.bootlin.com/dpdk/v23.11-rc3/source/lib/eal/common/eal_common_errno.c#L15 [2]https://elixir.bootlin.com/dpdk/v23.11-rc3/source/lib/eal/common/eal_common_errno.c#L49 [3]https://elixir.bootlin.com/dpdk/v23.11-rc3/source/lib/eal/include/rte_errno.h#L32