summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYanteng Si <siyanteng@loongson.cn>2022-12-10 11:26:34 +0800
committerJonathan Corbet <corbet@lwn.net>2023-01-02 16:14:10 -0700
commite07e9f22259ede8258c00cf3358a44eefa1ad7ff (patch)
treec5faecfbf5160cae604f1f6f76b1e49668a955e9
parent1003f3420663f7959327650d0185546574a34728 (diff)
docs/zh_CN: Update the translation of testing-overview to 6.1-rc8
Update to commit a32d5c0fc12b ("Documentation: dev-tools: Enhance static analysis section with discussion") Signed-off-by: Yanteng Si <siyanteng@loongson.cn> Reviewed-by: Wu XiangCheng <bobwxc@email.cn> Link: https://lore.kernel.org/r/f3ae5e63502fed7e904f5a801168d2324c71f014.1670642548.git.siyanteng@loongson.cn Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rw-r--r--Documentation/translations/zh_CN/dev-tools/testing-overview.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/Documentation/translations/zh_CN/dev-tools/testing-overview.rst b/Documentation/translations/zh_CN/dev-tools/testing-overview.rst
index d6f2c65ed511..af65e7e93c02 100644
--- a/Documentation/translations/zh_CN/dev-tools/testing-overview.rst
+++ b/Documentation/translations/zh_CN/dev-tools/testing-overview.rst
@@ -132,3 +132,30 @@ Documentation/dev-tools/kcov.rst 是能够构建在内核之中,用于在每
不过要注意的是,静态分析工具存在**假阳性**的问题。在试图修复错误和警
告之前,需要仔细评估它们。
+
+何时使用Sparse和Smatch
+----------------------
+
+Sparse做类型检查,例如验证注释的变量不会导致无符号的错误,检测
+``__user`` 指针使用不当的地方,以及分析符号初始化器的兼容性。
+
+Smatch进行流程分析,如果允许建立函数数据库,它还会进行跨函数分析。
+Smatch试图回答一些问题,比如这个缓冲区是在哪里分配的?它有多大?这
+个索引可以由用户控制吗?这个变量比那个变量大吗?
+
+一般来说,在Smatch中写检查比在Sparse中写检查要容易。尽管如此,
+Sparse和Smatch的检查还是有一些重叠的地方。
+
+Smatch和Coccinelle的强项
+------------------------
+
+Coccinelle可能是最容易写检查的。它在预处理器之前工作,所以用Coccinelle
+检查宏中的错误更容易。Coccinelle还能为你创建补丁,这是其他工具无法做到的。
+
+例如,用Coccinelle你可以从 ``kmalloc_array(x, size, GFP_KERNEL)``
+到 ``kmalloc_array(x, size, GFP_KERNEL)`` 进行大规模转换,这真的很
+有用。如果你只是创建一个Smatch警告,并试图把转换的工作推给维护者,他们会很
+恼火。你将不得不为每个警告争论是否真的可以溢出。
+
+Coccinelle不对变量值进行分析,而这正是Smatch的强项。另一方面,Coccinelle
+允许你用简单的方法做简单的事情。