Merged
fix(codecheck): resolve codecheck findings in profiler and block ops #6742
fix(codecheck): resolve codecheck findings in profiler and block ops #6742
Merged
h9718wAdd on Sep 28
h9718w
h9718w
Sep 28

修复 codecheck 告警:pypto_profiler.h 将原始 unsigned char* 缓冲改为 uint8_t*、两处 std::memcpy 改为 memcpy_s(引入 securec.h);删除 memory.cpp 中调用与返回值判断之间的多余空行;并在 profiler 单测中补 memcpy_s 桩。另新增 UT,验证通过

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for h9718w's contribution.)
h9718wh9718w
Sep 28 Created pull request, commit f0b2b655
atomgit-bot
atomgit-bot
Sep 28 Comments:

变更摘要

本 PR 针对 codecheck 检查发现的告警进行清理,主要涉及 profiler 与 block 算子相关代码。核心改动集中在 python/pypto_pro/include/pypto_profiler.h:将 CacheCaptureTensorInfo 中的不安全检查 std::memcpy 替换为带目标缓冲区容量校验的 memcpy_s,并引入 securec.h、cstdint 头文件及 uint8_t 类型;同时在对应单元测试中补充了 memcpy_s 的桩实现。memory.cpp 仅做了一处空行清理。

主要改动

  • 引入安全拷贝接口: pypto_profiler.h 中新增 #include "securec.h" 与 #include <cstdint>,为使用安全内存操作函数做准备。
  • 缓冲区类型统一: CacheCaptureTensorInfo 中声明的 buffer 由 unsigned char* 改为 uint8_t*。
  • 替换 memcpy 为 memcpy_s: 将两次 std::memcpy 调用改为 (void)memcpy_s(...),并为其传入目标缓冲区剩余大小(size 与 size - offset),以满足安全拷贝的容量校验要求。
  • 补充测试桩实现: test_native_prof_tensor_info.py 中新增 extern "C" errno_t memcpy_s(...),通过断言 count <= destMax 并转调 std::memcpy 模拟该接口。
  • 格式清理: framework/src/interface/ir/op/block_ops/memory.cpp 的 DeduceSubViewType 中删除一行空行,属无业务影响的格式调整。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 28 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 28 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 28 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
9.2.0 ✅ gcw_kUomxQ2l, gaoxiang618 (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:

CLA Signature Pass

h9718w, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Set xinweiliu,cam_bxh,dai-zhentao,TianXL,lululu40888,shi-dingkun,gguuaanngg,codehjp423,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,gcw_kUomxQ2l,Andy-lb,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 28 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
h9718w
h9718w
Sep 28 Comments:

/compile

likedislike
h9718wh9718w
Sep 28 Pre merge succeeded (commit_id: a50baadff1c8750d30073c5fa7d34415d4c9689a)
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: ci-pipeline-running
h9718wh9718w
Sep 28 Associated issue: [Bug-Report|缺陷反馈]: cleancode清理
h9718wh9718w
Sep 28 Modify description of pull request
gaoxiang618
gaoxiang618Collaborators
Sep 28 Comments:

/approve
/lgtm

likedislike
liulun0308
liulun0308Collaborators
Sep 28 Comments:

/approve

likedislike
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: gaoxiang618

likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: lgtmapproved
h9718w
h9718w
Sep 29 Comments:

/compile

likedislike
h9718wh9718w
Sep 29 Pre merge succeeded (commit_id: c8f2d5e341136edcdc5a20354d5453a343d95402)
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 29 Added label: ci-pipeline-failed
h9718w
h9718w
Sep 29 Comments:

/compile

likedislike
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Removed label: ci-pipeline-failed
7 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 29 Merged pull request