已合并
【质量加固】补充 const 修饰、参数 const 修饰与 lambda 显式捕获 #4572
味蕾木柚创建于 28 天前
【质量加固】补充 const 修饰、参数 const 修饰与 lambda 显式捕获 #4572
已合并
味蕾木柚创建于 28 天前
11 个文件变更+17-17
@@ -285,7 +285,7 @@ void FindParserSo(const std::string &path, std::vector<std::string> &file_list,
285 return;285 return;
286}286}
287 287 
288-bool CheckDigitStr(std::string &str) {288+bool CheckDigitStr(const std::string &str) {
289 for (char c : str) {289 for (char c : str) {
290 if (!isdigit(c)) {290 if (!isdigit(c)) {
291 GELOGE(FAILED, "[Check][Param]value[%s] is not positive integer", str.c_str());291 GELOGE(FAILED, "[Check][Param]value[%s] is not positive integer", str.c_str());
@@ -295,7 +295,7 @@ bool CheckDigitStr(std::string &str) {
295 return true;295 return true;
296}296}
297 297 
298-domi::Status StringToInt(std::string &str, int32_t &value) {298+domi::Status StringToInt(const std::string &str, int32_t &value) {
夏国正26 天前

该修改导致最新 CI 的 UT_Test_ge_common 在链接阶段失败。实现已从 StringToInt(std::string &, int32_t &) 改为 StringToInt(const std::string &, int32_t &)实现),但测试文件仍保留旧的前置声明(测试声明)。因此 ut_libge_multiparts_utest 仍引用旧符号,线上报错:undefined reference to ge::StringToInt(std::string&, int&)(测试调用位于该文件第 1171、1177 行)。请同步更新测试前置声明为 const std::string &,否则 UT_Test_ge_common 无法完成链接。

likedislike
299 try {299 try {
300 if (!CheckDigitStr(str)) {300 if (!CheckDigitStr(str)) {
301 GELOGE(PARAM_INVALID, "[Check][Param]Invalid of digit std::string: %s ", str.c_str());301 GELOGE(PARAM_INVALID, "[Check][Param]Invalid of digit std::string: %s ", str.c_str());
@@ -16,7 +16,7 @@ KernelBuilderPtr AicpuKernelBuilder::instance_ = nullptr;
16 16 
17inline KernelBuilderPtr AicpuKernelBuilder::Instance() {17inline KernelBuilderPtr AicpuKernelBuilder::Instance() {
18 static std::once_flag flag;18 static std::once_flag flag;
19- std::call_once(flag, [&]() { instance_.reset(new (std::nothrow) AicpuKernelBuilder); });19+ std::call_once(flag, []() { instance_.reset(new (std::nothrow) AicpuKernelBuilder); });
20 return instance_;20 return instance_;
21}21}
22 22 
@@ -23,7 +23,7 @@ KernelInfoPtr AicpuKernelInfo::instance_ = nullptr;
23 23 
24inline KernelInfoPtr AicpuKernelInfo::Instance() {24inline KernelInfoPtr AicpuKernelInfo::Instance() {
25 static once_flag flag;25 static once_flag flag;
26- call_once(flag, [&]() { instance_.reset(new (nothrow) AicpuKernelInfo); });26+ call_once(flag, []() { instance_.reset(new (nothrow) AicpuKernelInfo); });
27 return instance_;27 return instance_;
28}28}
29 29 
@@ -18,7 +18,7 @@ OptimizerPtr AicpuOptimizer::instance_ = nullptr;
18 18 
19OptimizerPtr AicpuOptimizer::Instance() {19OptimizerPtr AicpuOptimizer::Instance() {
20 static std::once_flag flag;20 static std::once_flag flag;
21- std::call_once(flag, [&]() { instance_.reset(new (std::nothrow) AicpuOptimizer); });21+ std::call_once(flag, []() { instance_.reset(new (std::nothrow) AicpuOptimizer); });
22 return instance_;22 return instance_;
23}23}
24 24 
@@ -152,7 +152,7 @@ class BaseCluster : public std::enable_shared_from_this<BaseCluster> {
152 type_index_ = type_index;152 type_index_ = type_index;
153 }153 }
154 void SetMergeInputs(bool merge_inputs);154 void SetMergeInputs(bool merge_inputs);
155- std::string GetPartitionedCallName() {155+ std::string GetPartitionedCallName() const {
156 if (partition_node_ != nullptr) {156 if (partition_node_ != nullptr) {
157 return partition_node_->GetName();157 return partition_node_->GetName();
158 }158 }
@@ -52,27 +52,27 @@ class BaseNodePass {
52 52 
53 virtual ~BaseNodePass() = default;53 virtual ~BaseNodePass() = default;
54 54 
55- const std::vector<NodePtr> &GetNodesNeedRePass() {55+ const std::vector<NodePtr> &GetNodesNeedRePass() const {
56 return nodes_need_re_pass_;56 return nodes_need_re_pass_;
57 }57 }
58 58 
59- const OrderedNodeSet &GetNodesNeedRePassImmediately() {59+ const OrderedNodeSet &GetNodesNeedRePassImmediately() const {
60 return nodes_need_re_pass_immediately_;60 return nodes_need_re_pass_immediately_;
61 }61 }
62 62 
63- const OrderedNodeSet &GetGlobalNodesNeedRePassImmediately() {63+ const OrderedNodeSet &GetGlobalNodesNeedRePassImmediately() const {
64 return global_nodes_need_repass_immediately_;64 return global_nodes_need_repass_immediately_;
65 }65 }
66 66 
67- const std::unordered_set<NodePtr> &GetNodesDeleted() {67+ const std::unordered_set<NodePtr> &GetNodesDeleted() const {
68 return nodes_deleted_;68 return nodes_deleted_;
69 }69 }
70 70 
71- const std::unordered_set<NodePtr> &GetNodesSuspend() {71+ const std::unordered_set<NodePtr> &GetNodesSuspend() const {
72 return nodes_suspend_;72 return nodes_suspend_;
73 }73 }
74 74 
75- const OrderedNodeSet &GetNodesResume() {75+ const OrderedNodeSet &GetNodesResume() const {
76 return nodes_resume_;76 return nodes_resume_;
77 }77 }
78 78 
@@ -353,7 +353,7 @@ void TeFileUtils::DeleteFile(const std::string &path) {
353 }353 }
354}354}
355 355 
356-bool TeFileUtils::IsFileUsed(std::string &filePath) {356+bool TeFileUtils::IsFileUsed(const std::string &filePath) {
357 // if locked by other process, don't delete the file357 // if locked by other process, don't delete the file
358 FILE *fp = fopen(filePath.c_str(), "r");358 FILE *fp = fopen(filePath.c_str(), "r");
359 if (fp == nullptr) {359 if (fp == nullptr) {
@@ -36,7 +36,7 @@ class TeFileUtils {
36 static bool GetBufferFromBinFile(const std::string &binFilePath, std::vector<char> &buffer);36 static bool GetBufferFromBinFile(const std::string &binFilePath, std::vector<char> &buffer);
37 37 
38 private:38 private:
39- static bool IsFileUsed(std::string &filePath);39+ static bool IsFileUsed(const std::string &filePath);
40 static bool IsFileFcntlLock(int fd);40 static bool IsFileFcntlLock(int fd);
41 static bool JudgeEmptyAndCreateDir(char tmpDirPath[], const std::string &directoryPath);41 static bool JudgeEmptyAndCreateDir(char tmpDirPath[], const std::string &directoryPath);
42 static bool CopyFileToNewPath(const std::string &filePath, const std::string &dstPath);42 static bool CopyFileToNewPath(const std::string &filePath, const std::string &dstPath);
@@ -40,7 +40,7 @@ class Pass {
40 name_ = name;40 name_ = name;
41 }41 }
42 42 
43- std::string GetName() {43+ std::string GetName() const {
44 return name_;44 return name_;
45 }45 }
46 46 
@@ -20,7 +20,7 @@ bool TaskThread::Start(Runnable runnable) {
20 return false;20 return false;
21 }21 }
22 22 
23- thread_.reset(new (std::nothrow) std::thread([=]() {23+ thread_.reset(new (std::nothrow) std::thread([runnable]() {
24 SET_THREAD_NAME(pthread_self(), "ge_exe_tasktd");24 SET_THREAD_NAME(pthread_self(), "ge_exe_tasktd");
25 runnable();25 runnable();
26 }));26 }));
@@ -40,7 +40,7 @@
40using namespace std;40using namespace std;
41 41 
42namespace ge {42namespace ge {
43-domi::Status StringToInt(std::string &str, int32_t &value);43+domi::Status StringToInt(const std::string &str, int32_t &value);
44domi::Status ParseOutNodes(const std::string &out_nodes);44domi::Status ParseOutNodes(const std::string &out_nodes);
45domi::Status CheckOutPutDataTypeSupport(const std::string &output_type);45domi::Status CheckOutPutDataTypeSupport(const std::string &output_type);
46domi::Status ParseOutputType(const std::string &output_type,46domi::Status ParseOutputType(const std::string &output_type,