[v4,01/42] devtools: forbid use of strerror

Message ID 20241023082852.2780488-2-huangdengdui@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series replace strerror |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

huangdengdui Oct. 23, 2024, 8:28 a.m. UTC
The function strerror() is insecure in a multi-thread environment.
rte_strerror() has been provided in DPDK 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>
---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index d860f19045..078d5714da 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -209,6 +209,14 @@  check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# refrain from using strerror() for drivers and libs
+	awk -v FOLDERS="lib drivers" \
+		-v EXPRESSIONS="\\\sstrerror\\\(" \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using strerror, prefer rte_strerror' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# refrain from using RTE_LOG_REGISTER for drivers and libs
 	awk -v FOLDERS='lib drivers' \
 		-v EXPRESSIONS='\\<RTE_LOG_REGISTER\\>' \