Merge blocked
变更摘要
本 PR 针对中英文 debug 调试文档中打印 ACL 错误消息的示例代码进行安全性修正。原示例直接以 printf(aclGetRecentErrMsg()) 调用,将 API 返回的错误消息文本当作格式字符串使用,既会在 -Werror=format-security 下编译失败,也会把消息中出现的百分号格式指令误当成参数解析,且未对空指针返回做保护。修复方式是将返回值先保存到指针变量,在非空时以固定的 "%s" 格式打印,并把对应代码块语言标记改为 cpp,中英文文档同步处理。
主要改动
- 避免返回值直接作为格式字符串: 不再直接
printf(aclGetRecentErrMsg()),而是先保存返回指针再以固定"%s"格式输出,消除-Werror=format-security编译失败与百分号被解析为格式指令的问题。 - 增加空指针保护: 仅在返回指针非空时执行打印,跳过空指针场景。
- 统一代码块语言标记: 将相关示例代码块的语言标记改为
cpp。 - 中英文文档同步修复: 同一修复同时应用于
docs/zh/debug/op_debug_prof.md与docs/en/debug/op_debug_prof.md。


🤖 本次改动均为数据 / 生成 / 二进制文件(如测试用例、锁文件、媒体资源),没有可审查的代码逻辑,已跳过 AI 代码审查。


Hi @Ethan_Zou, welcome to submitting your first PR to ops-ras!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-ras | ❌ (0/2)(You can also ask: 徐鲁威, 王林木, 唐燕峰, 周奇龙, 陈兴宇) | ❌ (0/1)(You can also ask: 徐鲁威, 柳宗谷, 唐燕峰, 於欣洁, 王林木) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Ethan_Zou, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [539c3bcc16a94d3e993fa51f202d1639][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-10-02 13:32:50] CI执行结束


流水线任务触发成功
任务链接 [634dc03fdc184692a8137f34a105034f][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> |
[2026-10-02 13:35:02] CI执行结束


流水线任务触发成功
任务链接 [1ef54d0c1c50486ab2f87d5ae85f82b1][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-10-10 00:11:24] CI执行结束


流水线任务触发成功
任务链接 [d19a532fe7964610be12090fd6bc5179][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> |
[2026-10-10 00:13:40] CI执行结束


流水线任务触发成功
任务链接 [cb00087818ee41e19f0df5b92d03b6ae][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> |
[2026-11-08 00:12:00] CI执行结束


流水线任务触发成功
任务链接 [d7434ec693eb4a7d95d4f5792e621168][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-11-08 00:10:45] CI执行结束


描述
中英文 docs/*/debug/op_debug_prof.md 均直接 printf(aclGetRecentErrMsg())。该 API 返回错误消息文本,作为格式字符串会导致 -Werror=format-security 编译失败,并将消息中的百分号格式指令当成参数访问;空指针返回也没有保护。
中英文合并为一个修复:保存返回指针,非空时使用固定 "%s" 格式打印,并将该代码块语言标记为 cpp。
关联的Issue
Fixes #61
测试
Host clang++ 包含 cann/runtime 真实公开 acl/acl.h,使用错误消息返回值替身复现真实文档语句。原例开启 -Wformat -Werror=format-security 后编译失败;修复后编译通过,含 %s 与 100% 的文本逐字打印,空指针跳过。没有设备运行或真实 ACL 初始化。git diff --check 通过。 仓库适用 pre-commit hooks 与 diff --check 通过。
本地无 NPU,未执行设备测试;提交后评论
/compile。文档更新
docs/zh/debug/op_debug_prof.mddocs/en/debug/op_debug_prof.md类型标签