Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

【Hackathon 6th Fundable Projects 2 No.1】Fix cppcoreguidelines-no-malloc

Open walkalone20 opened this issue 1 year ago • 4 comments

PR Category

Others

PR Types

Bug fixes

Description

修复了 C 风格的 malloc、free 的共计 23 个错误。该问题共 27 处,还有 4 处涉及到函数参数是指针,在函数内或跨函数释放的情况:

/paddle/Paddle/paddle/phi/api/profiler/device_tracer.cc:179:46: error: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc,-warnings-as-errors]
  uint8_t *buf = reinterpret_cast<uint8_t *>(malloc(kBufSize + kAlignSize));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/paddle/Paddle/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.cc:49:3: error: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc,-warnings-as-errors]
  free(mem_ptr);
  ^~~~~~~~~~~~~
/paddle/Paddle/paddle/pir/src/core/utils.cc:51:3: error: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc,-warnings-as-errors]
  free(mem_ptr);
  ^~~~~~~~~~~~~
/paddle/Paddle/paddle/phi/api/profiler/device_tracer.cc:309:3: error: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc,-warnings-as-errors]
  free(buffer);
  ^~~~~~~~~~~~

walkalone20 avatar Apr 22 '24 12:04 walkalone20

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 22 '24 12:04 CLAassistant

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 22 '24 12:04 CLAassistant

你的PR提交成功,感谢你对开源项目的贡献! 请关注后续CI自动化测试结果,详情请参考Paddle-CI手册。 Your PR has been submitted. Thanks for your contribution! Please wait for the result of CI firstly. See Paddle CI Manual for details.

paddle-bot[bot] avatar Apr 22 '24 12:04 paddle-bot[bot]

Sorry to inform you that 9844a3b's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

paddle-ci-bot[bot] avatar May 01 '24 03:05 paddle-ci-bot[bot]

Sorry to inform you that ae6e00e's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

paddle-ci-bot[bot] avatar May 09 '24 03:05 paddle-ci-bot[bot]