Merged
fix(machine): Split runtime headers and use secure bundle functions #6422
W4termyAdd on Sep 17
fix(machine): Split runtime headers and use secure bundle functions #6422
Merged
Merged fromW4termy/pypto_2747fix/9.2.0_cleancodeintocann/pypto9.2.0
W4termyCollaborators
Sep 17
Sep 17


Pull Request has been successfully merged by CANN-robot.
(Thank you for W4termy's contribution.)Sep 17 Associated issue: [Task|任务跟踪]: Machine Cleancode告警清理
atomgit-bot
Sep 17 Comments:
Sep 17 Comments:
变更摘要
本 PR 主要对 machine 模块进行两方面的重构:一是拆分运行时头文件,将原本内联在 wrap_manager.h 与 dev_encode_function.h 中的枚举、位图操作等内联函数抽取到独立的新头文件 wrap_task_utils.h 与 dev_encode_function_bitmap.h 中,原文件改为通过 #include 引入并仅保留声明;二是将 bundle 相关代码中的 std::memcpy、std::snprintf 等替换为安全版本 MemcpyS、snprintf_s,并补充断言与失败日志,提升内存拷贝与格式化操作的安全性。
主要改动
- 抽取 wrap 任务工具函数到新头文件:在新增的
wrap_task_utils.h中定义MixResourceType、DieId枚举及WrapInfoQueueLock、WrapInfoQueueUnLock、GetTaskNumByMixResType、IsWrapTaskReady等内联函数,wrap_manager.h删除原内联定义并改为包含该头文件。 - 拆分
DevAscendFunction位图操作:将IsDeadEndHub、IsTailTask、ClearTailTask、ClearDeadEndHub、PropagateDeadHubClear、GetBitmapByteSize、BackupBitmapTo、RestoreBitmapFrom等内联位图函数从dev_encode_function.h移入新增的dev_encode_function_bitmap.h,原头文件保留声明并在末尾包含新头文件。 - bundle 加载/打包改用安全内存拷贝:
kernel_bundle_loader.cpp与kernel_bundle_packer.cpp将std::memcpy替换为MemcpyS,并新增对machine/runtime/runner/runtime_utils.h的引用。 - AICPU 操作名格式化改用安全函数:
kernel_bundle_launch.cpp将std::snprintf替换为snprintf_s,并通过MACHINE_ASSERT对格式化返回值进行校验,失败时输出[kernel-bundle]相关错误日志。


Incorrect?
atomgit-bot
Sep 17 Comments:
Sep 17 Comments:
Sep 17 Added label: cann-cla/yes
W4termy
Sep 17 Comments:
Sep 17 Comments:
compile


CANN-robot
Sep 17 Comments:
Sep 17 Comments:
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
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| framework/src/machine | ✅ gaoxingwang, jason_yuan_ye (2/2) | ✅ jason_yuan_ye (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
W4termy, thanks for your pull request. All authors of the commits have signed the CLA. 👍


CANN-robot
Sep 17 Comments:
Sep 17 Comments:
Sep 17 Pre merge succeeded (commit_id: 0fc4902ffba86989abc0da86d3d49691fc68958c)
Sep 17 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
Sep 17 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
Sep 17 Set jason_yuan_ye,yinjie27_,tsungl4,gaoxingwang,linjiashu as approver
Sep 17 Modify description of pull request
CANN-robot
Sep 17 Comments:
Sep 17 Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Sep 17 Added label: ci-pipeline-running
7 event messages are collapsed here。 See more
Sep 17 Added label: cann-cla/yes
W4termy
Sep 17 Comments:
Sep 17 Comments:
compile


Sep 17 Pre merge succeeded (commit_id: a6a783b704449e8e7b7223cdd6eec4be4350cf3b)
CANN-robot
Sep 17 Comments:
Sep 17 Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Sep 17 Removed label: ci-pipeline-failed
Sep 17 Added label: ci-pipeline-running
Sep 17 Removed label: ci-pipeline-running
Sep 17 Added label: ci-pipeline-passed
Sep 17 Change title to "fix(machine): Split runtime headers and use secure bundle functions", originally titled "refactor(machine): split runtime headers and use secure bundle functions".
Sep 17 Change title to "fix(machine): Split runtime headers and use secure bundle functions", originally titled "refactor(machine): split runtime headers and use secure bundle functions".
gaoxingwang
Sep 17 Comments:
Sep 17 Comments:
/lgtm


袁野
Sep 17 Comments:
Sep 17 Comments:
/approve


Sep 17 Added label: lgtmapproved
Sep 17 Merged pull request