已合并
fix:修复静态检查告警 #3936
Chang-an-HW创建于 7月9日
fix:修复静态检查告警 #3936
已合并
共 6 个文件变更+23-23
| @@ -67,8 +67,8 @@ Status LoadRawCreators(const PullCreatorSymbols &symbols, std::vector<CustomOpTy | |||
| 67 | 67 | ||
| 68 | const size_t creator_num = symbols.get_creator_num(); | 68 | const size_t creator_num = symbols.get_creator_num(); |
| 69 | raw_creators.resize(creator_num); | 69 | raw_creators.resize(creator_num); |
| 70 | - const auto ret = symbols.get_creators(raw_creators.empty() ? nullptr : raw_creators.data(), raw_creators.size(), | 70 | + auto creator = raw_creators.empty() ? nullptr : raw_creators.data(); |
| 71 | - sizeof(CustomOpTypeToCreator)); | 71 | + const auto ret = symbols.get_creators(creator, raw_creators.size(), sizeof(CustomOpTypeToCreator)); |
| 72 | if (ret != 0) { | 72 | if (ret != 0) { |
| 73 | GELOGE(FAILED, "[CUSTOM OP] get registered custom op creators failed, ret:%d.", ret); | 73 | GELOGE(FAILED, "[CUSTOM OP] get registered custom op creators failed, ret:%d.", ret); |
| 74 | return FAILED; | 74 | return FAILED; |
| @@ -98,7 +98,7 @@ class PendingSoResource { | |||
| 98 | std::string CalculateBinHash(const uint8_t *data, const size_t data_len) { | 98 | std::string CalculateBinHash(const uint8_t *data, const size_t data_len) { |
| 99 | const size_t hash_val = std::hash<std::string>{}(std::string(reinterpret_cast<const char *>(data), data_len)); | 99 | const size_t hash_val = std::hash<std::string>{}(std::string(reinterpret_cast<const char *>(data), data_len)); |
| 100 | std::ostringstream oss; | 100 | std::ostringstream oss; |
| 101 | - oss << std::hex << std::setfill('0') << std::setw(sizeof(size_t) * 2) << hash_val; | 101 | + oss << std::hex << std::setfill('0') << std::setw(sizeof(size_t) * 2U) << hash_val; |
| 102 | return oss.str(); | 102 | return oss.str(); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| @@ -263,7 +263,7 @@ Status CustomOpSoLoader::LoadCustomOpSoBins(const std::vector<OpSoBinPtr> &custo | |||
| 263 | for (const auto &so_bin : custom_so_bins) { | 263 | for (const auto &so_bin : custom_so_bins) { |
| 264 | GE_ASSERT_SUCCESS(LoadSingleCustomOpSoBin(so_bin, current_loaded_handles)); | 264 | GE_ASSERT_SUCCESS(LoadSingleCustomOpSoBin(so_bin, current_loaded_handles)); |
| 265 | } | 265 | } |
| 266 | - loaded_handles.insert(loaded_handles.end(), current_loaded_handles.begin(), current_loaded_handles.end()); | 266 | + (void)loaded_handles.insert(loaded_handles.end(), current_loaded_handles.begin(), current_loaded_handles.end()); |
| 267 | return SUCCESS; | 267 | return SUCCESS; |
| 268 | } | 268 | } |
| 269 | 269 | ||
| @@ -290,7 +290,7 @@ Status CustomOpSoLoader::LoadSingleCustomOpSoBin(const OpSoBinPtr &so_bin, | |||
| 290 | if (loaded_handle != nullptr) { | 290 | if (loaded_handle != nullptr) { |
| 291 | GELOGI("[CustomOpSoLoader] custom op so[%s] fingerprint[%s] was published after local load failure, reuse lease.", | 291 | GELOGI("[CustomOpSoLoader] custom op so[%s] fingerprint[%s] was published after local load failure, reuse lease.", |
| 292 | so_bin->GetSoName().c_str(), fingerprint_key.c_str()); | 292 | so_bin->GetSoName().c_str(), fingerprint_key.c_str()); |
| 293 | - loaded_handles.emplace_back(loaded_handle); | 293 | + (void)loaded_handles.emplace_back(loaded_handle); |
| 294 | return SUCCESS; | 294 | return SUCCESS; |
| 295 | } | 295 | } |
| 296 | return load_status; | 296 | return load_status; |
| @@ -77,7 +77,7 @@ Status CollectCustomOpTypesFromGraph(const ComputeGraphPtr &graph, const CustomO | |||
| 77 | for (const auto &node : graph->GetAllNodes()) { | 77 | for (const auto &node : graph->GetAllNodes()) { |
| 78 | const std::string op_type = node->GetType(); | 78 | const std::string op_type = node->GetType(); |
| 79 | if (registry->HasCreator(AscendString(op_type.c_str()))) { | 79 | if (registry->HasCreator(AscendString(op_type.c_str()))) { |
| 80 | - used_custom_op_types.insert(op_type); | 80 | + (void)used_custom_op_types.insert(op_type); |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | return SUCCESS; | 83 | return SUCCESS; |
| @@ -145,9 +145,9 @@ Status ModelHelper::SerializeCustomOpKernel(PortableOp *serializable_op, const s | |||
| 145 | header.bin_len = static_cast<uint32_t>(buffer.size()); | 145 | header.bin_len = static_cast<uint32_t>(buffer.size()); |
| 146 | 146 | ||
| 147 | const auto *header_ptr = reinterpret_cast<const uint8_t *>(&header); | 147 | const auto *header_ptr = reinterpret_cast<const uint8_t *>(&header); |
| 148 | - merged_buffers.insert(merged_buffers.end(), header_ptr, header_ptr + sizeof(header)); | 148 | + (void)merged_buffers.insert(merged_buffers.end(), header_ptr, header_ptr + sizeof(header)); |
| 149 | - merged_buffers.insert(merged_buffers.end(), op_type_str.begin(), op_type_str.end()); | 149 | + (void)merged_buffers.insert(merged_buffers.end(), op_type_str.begin(), op_type_str.end()); |
| 150 | - merged_buffers.insert(merged_buffers.end(), buffer.begin(), buffer.end()); | 150 | + (void)merged_buffers.insert(merged_buffers.end(), buffer.begin(), buffer.end()); |
| 151 | GELOGD("[CUSTOM OP] Serialized custom op '%s', bin size:%zu", op_type_str.c_str(), buffer.size()); | 151 | GELOGD("[CUSTOM OP] Serialized custom op '%s', bin size:%zu", op_type_str.c_str(), buffer.size()); |
| 152 | return SUCCESS; | 152 | return SUCCESS; |
| 153 | } | 153 | } |
| @@ -184,7 +184,7 @@ Status ModelHelper::SaveCustomOpsPartition(std::shared_ptr<OmFileSaveHelper> &om | |||
| 184 | has_non_serializable_custom_op = true; | 184 | has_non_serializable_custom_op = true; |
| 185 | } else { | 185 | } else { |
| 186 | has_serializable_custom_op = true; | 186 | has_serializable_custom_op = true; |
| 187 | - serializable_ops.emplace_back(op_type_str, serializable_op); | 187 | + (void)serializable_ops.emplace_back(op_type_str, serializable_op); |
| 188 | } | 188 | } |
| 189 | if (has_serializable_custom_op && has_non_serializable_custom_op) { | 189 | if (has_serializable_custom_op && has_non_serializable_custom_op) { |
| 190 | GELOGE(FAILED, "[CUSTOM OP] graph contains both serializable and non-serializable custom ops."); | 190 | GELOGE(FAILED, "[CUSTOM OP] graph contains both serializable and non-serializable custom ops."); |
| @@ -295,11 +295,11 @@ Status ModelHelper::LoadOpSoBin(const OmFileLoadHelper &om_load_helper, const Ge | |||
| 295 | GELOGD("Added autofuse so_path:%s", so_path.c_str()); | 295 | GELOGD("Added autofuse so_path:%s", so_path.c_str()); |
| 296 | } | 296 | } |
| 297 | } else if (op_so_bin_ptr->GetSoBinType() == SoBinType::kCustomOp) { | 297 | } else if (op_so_bin_ptr->GetSoBinType() == SoBinType::kCustomOp) { |
| 298 | - custom_op_so_bins.emplace_back(op_so_bin_ptr); | 298 | + (void)custom_op_so_bins.emplace_back(op_so_bin_ptr); |
| 299 | } | 299 | } |
| 300 | } | 300 | } |
| 301 | if (!bin_file_buffer.empty()) { | 301 | if (!bin_file_buffer.empty()) { |
| 302 | - root_graph->SetExtAttr<std::map<std::string, ge::OpSoBinPtr>>("bin_file_buffer", bin_file_buffer); | 302 | + (void)root_graph->SetExtAttr<std::map<std::string, ge::OpSoBinPtr>>("bin_file_buffer", bin_file_buffer); |
| 303 | } | 303 | } |
| 304 | GE_ASSERT_SUCCESS(LoadCustomOpSoBins(custom_op_so_bins, loaded_handles)); | 304 | GE_ASSERT_SUCCESS(LoadCustomOpSoBins(custom_op_so_bins, loaded_handles)); |
| 305 | SaveOpSoInfo(ge_root_model); | 305 | SaveOpSoInfo(ge_root_model); |
| @@ -34,11 +34,11 @@ | |||
| 34 | 34 | ||
| 35 | namespace ge { | 35 | namespace ge { |
| 36 | namespace { | 36 | namespace { |
| 37 | -constexpr uint8_t kElfMachineOffset = 18U; | 37 | +constexpr std::streamoff kElfMachineOffset = 18; |
| 38 | 38 | ||
| 39 | std::string ToLowerCopy(std::string value) { | 39 | std::string ToLowerCopy(std::string value) { |
| 40 | - std::transform(value.begin(), value.end(), value.begin(), | 40 | + (void)std::transform(value.begin(), value.end(), value.begin(), |
| 41 | - [](const unsigned char ch) { return static_cast<char>(std::tolower(ch)); }); | 41 | + [](const uint8_t ch) { return static_cast<char>(std::tolower(ch)); }); |
| 42 | return value; | 42 | return value; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -81,11 +81,11 @@ bool ReadElfMachine(const std::string &so_path, uint16_t &machine, bool &is_elf) | |||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | std::array<char, EI_NIDENT> ident{}; | 83 | std::array<char, EI_NIDENT> ident{}; |
| 84 | - file.read(ident.data(), static_cast<std::streamsize>(ident.size())); | 84 | + (void)file.read(ident.data(), static_cast<std::streamsize>(ident.size())); |
| 85 | if (file.gcount() != static_cast<std::streamsize>(ident.size())) { | 85 | if (file.gcount() != static_cast<std::streamsize>(ident.size())) { |
| 86 | return false; | 86 | return false; |
| 87 | } | 87 | } |
| 88 | - const auto to_u8 = [](const char ch) { return static_cast<uint8_t>(static_cast<unsigned char>(ch)); }; | 88 | + const auto to_u8 = [](const char ch) { return static_cast<uint8_t>(ch); }; |
| 89 | if ((to_u8(ident[EI_MAG0]) != ELFMAG0) || (to_u8(ident[EI_MAG1]) != ELFMAG1) || (to_u8(ident[EI_MAG2]) != ELFMAG2) || | 89 | if ((to_u8(ident[EI_MAG0]) != ELFMAG0) || (to_u8(ident[EI_MAG1]) != ELFMAG1) || (to_u8(ident[EI_MAG2]) != ELFMAG2) || |
| 90 | (to_u8(ident[EI_MAG3]) != ELFMAG3)) { | 90 | (to_u8(ident[EI_MAG3]) != ELFMAG3)) { |
| 91 | is_elf = false; | 91 | is_elf = false; |
| @@ -97,11 +97,11 @@ bool ReadElfMachine(const std::string &so_path, uint16_t &machine, bool &is_elf) | |||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | std::array<char, sizeof(uint16_t)> machine_bytes{}; | 99 | std::array<char, sizeof(uint16_t)> machine_bytes{}; |
| 100 | - file.seekg(kElfMachineOffset, std::ios::beg); | 100 | + (void)file.seekg(kElfMachineOffset, std::ios::beg); |
| 101 | if (!file.good()) { | 101 | if (!file.good()) { |
| 102 | return false; | 102 | return false; |
| 103 | } | 103 | } |
| 104 | - file.read(machine_bytes.data(), static_cast<std::streamsize>(machine_bytes.size())); | 104 | + (void)file.read(machine_bytes.data(), static_cast<std::streamsize>(machine_bytes.size())); |
| 105 | if (file.gcount() != static_cast<std::streamsize>(machine_bytes.size())) { | 105 | if (file.gcount() != static_cast<std::streamsize>(machine_bytes.size())) { |
| 106 | return false; | 106 | return false; |
| 107 | } | 107 | } |
| @@ -498,8 +498,9 @@ Status GeRootModel::CheckAndSetAutofuseSo() { | |||
| 498 | const std::string *guard_so_data = AttrUtils::GetStr(root_graph_, "_guard_check_so_data"); | 498 | const std::string *guard_so_data = AttrUtils::GetStr(root_graph_, "_guard_check_so_data"); |
| 499 | if (!autofuse_so_set_.empty() || ((guard_so_data != nullptr) && !guard_so_data->empty())) { | 499 | if (!autofuse_so_set_.empty() || ((guard_so_data != nullptr) && !guard_so_data->empty())) { |
| 500 | OpSoStoreUtils::SetSoBinType(SoBinType::kAutofuse, so_in_om_); | 500 | OpSoStoreUtils::SetSoBinType(SoBinType::kAutofuse, so_in_om_); |
| 501 | + const auto guard_so_size = (guard_so_data != nullptr) ? guard_so_data->size() : 0UL; | ||
| 501 | GELOGD("Set kAutofuse so_in_om_ bit, autofuse_so_count=%zu, guard_so_size=%zu.", autofuse_so_set_.size(), | 502 | GELOGD("Set kAutofuse so_in_om_ bit, autofuse_so_count=%zu, guard_so_size=%zu.", autofuse_so_set_.size(), |
| 502 | - (guard_so_data != nullptr) ? guard_so_data->size() : 0UL); | 503 | + guard_so_size); |
| 503 | } | 504 | } |
| 504 | GELOGI("[AutofuseSo]The num of so is %zu.", autofuse_so_set_.size()); | 505 | GELOGI("[AutofuseSo]The num of so is %zu.", autofuse_so_set_.size()); |
| 505 | return SUCCESS; | 506 | return SUCCESS; |
| @@ -36,7 +36,7 @@ std::vector<ge::NodePtr> GetAllPartitioncallNodes(const ge::ComputeGraphPtr &roo | |||
| 36 | std::vector<ge::NodePtr> partiticall_nodes; | 36 | std::vector<ge::NodePtr> partiticall_nodes; |
| 37 | for (const auto &node : root_graph->GetDirectNode()) { | 37 | for (const auto &node : root_graph->GetDirectNode()) { |
| 38 | if (node->GetType() == ge::PARTITIONEDCALL) { | 38 | if (node->GetType() == ge::PARTITIONEDCALL) { |
| 39 | - partiticall_nodes.emplace_back(node); | 39 | + (void)partiticall_nodes.emplace_back(node); |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | return partiticall_nodes; | 42 | return partiticall_nodes; |
| @@ -252,7 +252,7 @@ ge::Status GraphUnfolder::UnfoldAllPartitioncallInPlace(const ge::ComputeGraphPt | |||
| 252 | GELOGD("Start unfloder partitioncall node, graph[%s]", root_graph->GetName().c_str()); | 252 | GELOGD("Start unfloder partitioncall node, graph[%s]", root_graph->GetName().c_str()); |
| 253 | uint32_t depth = 0U; | 253 | uint32_t depth = 0U; |
| 254 | GE_ASSERT_SUCCESS(UnfoldPartitioncallInPlace(root_graph, root_graph, depth)); | 254 | GE_ASSERT_SUCCESS(UnfoldPartitioncallInPlace(root_graph, root_graph, depth)); |
| 255 | - root_graph->TopologicalSorting(); | 255 | + (void)root_graph->TopologicalSorting(); |
| 256 | return ge::SUCCESS; | 256 | return ge::SUCCESS; |
| 257 | } | 257 | } |
| 258 | 258 | ||