From ab32ebc75852a42aed7fc32213486d329eab3b23 Mon Sep 17 00:00:00 2001 From: "7347157+joylvliang@user.noreply.gitee.com" Date: Mon, 19 Jul 2021 19:08:04 +0800 Subject: [PATCH] fix_warning_of_codes --- mindspore/ccsrc/debug/common.cc | 1 - mindspore/ccsrc/debug/data_dump/dump_utils.cc | 1 - mindspore/ccsrc/debug/debugger/debugger.cc | 10 +++++----- .../debug/debugger/offline_debug/dbg_services.cc | 3 --- mindspore/ccsrc/debug/trace.cc | 2 +- mindspore/ccsrc/frontend/operator/composite/map.cc | 6 +++--- mindspore/ccsrc/frontend/optimizer/ad/kprim.cc | 12 ++++++------ .../pipeline/jit/static_analysis/order_enforce.cc | 2 -- mindspore/ccsrc/pybind_api/ir/primitive_py.cc | 12 ++++++------ mindspore/ccsrc/pybind_api/utils/ms_context_py.cc | 2 +- mindspore/ccsrc/utils/context/graph_kernel_flags.cc | 5 +++-- 11 files changed, 25 insertions(+), 31 deletions(-) diff --git a/mindspore/ccsrc/debug/common.cc b/mindspore/ccsrc/debug/common.cc index 817b7ba26db..253495eaa1e 100644 --- a/mindspore/ccsrc/debug/common.cc +++ b/mindspore/ccsrc/debug/common.cc @@ -303,7 +303,6 @@ struct GlogLogDirRegister { std::string log_dir_str = std::string(log_dir); auto real_log_dir_str = Common::GetRealPath(log_dir_str); - // While 'GLOG_logtostderr' = 0, logs output to files. // 'GLOG_log_dir' must be specified as the path of log files. if (logtostderr_str == "0" && real_log_dir_str.has_value()) { diff --git a/mindspore/ccsrc/debug/data_dump/dump_utils.cc b/mindspore/ccsrc/debug/data_dump/dump_utils.cc index 30735eeb890..3a3e285b096 100644 --- a/mindspore/ccsrc/debug/data_dump/dump_utils.cc +++ b/mindspore/ccsrc/debug/data_dump/dump_utils.cc @@ -140,5 +140,4 @@ std::string GetOpNameWithoutScope(const std::string &fullname_with_scope) { } return op_name; } - } // namespace mindspore diff --git a/mindspore/ccsrc/debug/debugger/debugger.cc b/mindspore/ccsrc/debug/debugger/debugger.cc index 0f306a6bf18..2d3e9a73024 100644 --- a/mindspore/ccsrc/debug/debugger/debugger.cc +++ b/mindspore/ccsrc/debug/debugger/debugger.cc @@ -341,7 +341,7 @@ void Debugger::PreExecute(const KernelGraphPtr &graph_ptr) { debug_services_->ResetLoadedTensors(); } // resets for the new graph - suspended_at_last_kernel_ = 0; + suspended_at_last_kernel_ = false; } bool Debugger::DumpDataEnabledIteration() const { auto &dump_json_parser = DumpJsonParser::GetInstance(); @@ -370,7 +370,7 @@ void Debugger::Dump(const KernelGraphPtr &kernel_graph) const { uint32_t rank_id = GetRankID(); if (debugger_->DebuggerBackendEnabled()) { MS_EXCEPTION_IF_NULL(kernel_graph); - E2eDump::DumpParametersAndConstData(kernel_graph.get(), rank_id, debugger_.get()); + (void)E2eDump::DumpParametersAndConstData(kernel_graph.get(), rank_id, debugger_.get()); } else { DumpJsonParser::GetInstance().UpdateDumpIter(); } @@ -379,7 +379,7 @@ void Debugger::Dump(const KernelGraphPtr &kernel_graph) const { void Debugger::DumpSingleNode(const CNodePtr &node, uint32_t graph_id) { if (debugger_->DebuggerBackendEnabled()) { uint32_t rank_id = GetRankID(); - E2eDump::DumpSingleNodeData(node, graph_id, rank_id, debugger_.get()); + (void)E2eDump::DumpSingleNodeData(node, graph_id, rank_id, debugger_.get()); } } @@ -497,7 +497,7 @@ void Debugger::PostExecuteNode(const CNodePtr &kernel, bool last_kernel) { // if kernel is not watchpoint and is next_to or continue_to node, suspend // sets a bool to be checked in preExecute to avoid double stopping at last kernel in the last graph if (last_kernel) { - suspended_at_last_kernel_ = 1; + suspended_at_last_kernel_ = true; } CommandLoop(); } @@ -1147,7 +1147,7 @@ std::vector Debugger::CheckOpOverflow() { if (dir->d_type == DT_REG) { std::string file_path = overflow_bin_path; std::string file_name = dir->d_name; - file_path.append(file_name); + (void)file_path.append(file_name); std::fstream infile; infile.open(file_path.c_str(), std::ios::binary | std::ios::in); if (!infile.is_open()) { diff --git a/mindspore/ccsrc/debug/debugger/offline_debug/dbg_services.cc b/mindspore/ccsrc/debug/debugger/offline_debug/dbg_services.cc index e9941247aae..8c5893de84a 100644 --- a/mindspore/ccsrc/debug/debugger/offline_debug/dbg_services.cc +++ b/mindspore/ccsrc/debug/debugger/offline_debug/dbg_services.cc @@ -173,9 +173,6 @@ std::vector DbgServices::CheckWatchpoints(unsigned int iterati std::vector error_codes; std::vector rank_id; std::vector root_graph_id; - // #ifdef ENABLE_D - // overflow_ops = CheckOpOverflow(); - // #endif std::vector> tensor_list; std::vector file_paths; diff --git a/mindspore/ccsrc/debug/trace.cc b/mindspore/ccsrc/debug/trace.cc index bbafe7e00f2..4cb21a79f03 100644 --- a/mindspore/ccsrc/debug/trace.cc +++ b/mindspore/ccsrc/debug/trace.cc @@ -371,7 +371,7 @@ bool AnalyzeFailExporter::ExportFuncGraph(const std::string &filename, if (printed_func_graphs.find(fg) != printed_func_graphs.end()) { continue; } - printed_func_graphs.emplace(fg); + (void)printed_func_graphs.emplace(fg); current_context_ = node_config->context(); // Set current context. ExportOneFuncGraph(ofs, fg, tagged_func_graphs[fg]); diff --git a/mindspore/ccsrc/frontend/operator/composite/map.cc b/mindspore/ccsrc/frontend/operator/composite/map.cc index ca0766996a9..c550b270ad9 100644 --- a/mindspore/ccsrc/frontend/operator/composite/map.cc +++ b/mindspore/ccsrc/frontend/operator/composite/map.cc @@ -116,7 +116,7 @@ AnfNodePtr Map::FullMakeList(const std::shared_ptr &type, const FuncGraphP auto call_node = func_graph->NewCNodeInOrder(inputs2); if (reverse_) { - inputs.insert(inputs.begin() + 1, call_node); + (void)inputs.insert(inputs.begin() + 1, call_node); } else { inputs.emplace_back(call_node); } @@ -175,7 +175,7 @@ AnfNodePtr Map::FullMakeTuple(const std::shared_ptr &type, const FuncGrap auto call_node = func_graph->NewCNodeInOrder(inputs2); if (reverse_) { - inputs.insert(inputs.begin() + 1, call_node); + (void)inputs.insert(inputs.begin() + 1, call_node); } else { inputs.emplace_back(call_node); } @@ -216,7 +216,7 @@ AnfNodePtr Map::FullMakeClass(const std::shared_ptr &type, const FuncGrap auto call_node = func_graph->NewCNodeInOrder(inputs2); if (reverse_) { - inputs.insert(inputs.begin() + 2, call_node); + (void)inputs.insert(inputs.begin() + 2, call_node); } else { inputs.emplace_back(call_node); } diff --git a/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc b/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc index d9e0f88bb5b..0e16d8b43a9 100644 --- a/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc +++ b/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc @@ -58,8 +58,8 @@ bool IsSerializableBprop(const PrimitivePtr &prim) { [&prim](const PrimitivePtr &serializable_bprop_prim) { auto str1 = prim->name(); auto str2 = serializable_bprop_prim->name(); - transform(str1.begin(), str1.end(), str1.begin(), ::tolower); - transform(str2.begin(), str2.end(), str2.begin(), ::tolower); + (void)transform(str1.begin(), str1.end(), str1.begin(), ::tolower); + (void)transform(str2.begin(), str2.end(), str2.begin(), ::tolower); return str1 == str2; }); } @@ -175,7 +175,7 @@ FuncGraphPtr KPrim::GetBprop(const PrimitivePtr &prim, const pipeline::ResourceB func_graph->set_flag(mindspore::kFuncGraphFlagReAutoMonad, true); } pipeline::ResourceBasePtr res = (resources != nullptr) ? resources : std::make_shared(); - parse::ResolveFuncGraph(func_graph, res); + (void)parse::ResolveFuncGraph(func_graph, res); #ifndef _WIN32 // Check whether the bprop needs to be exported. if (serializable) { @@ -312,7 +312,7 @@ FuncGraphPtr KPrim::KPrimitive(const CNodePtr &cnode, const ValueNodePtr &value_ if (resources != nullptr) { auto manager = resources->manager(); auto &users = manager->node_users()[value_node]; - for (auto user_iter = users.begin(); user_iter != users.end(); user_iter++) { + for (auto user_iter = users.begin(); user_iter != users.end(); ++user_iter) { primal_debug_infos.push_back(user_iter->first->debug_info()); } } @@ -493,8 +493,8 @@ void KPrim::CheckBprop(const FuncGraphPtr &bprop_fg, const string &prim_to_check inputs.emplace_back(NewValueNode(prim::kPrimMakeTuple)); constexpr int primitive_size = 1; constexpr int brprop_offset_size = 2; - inputs.insert(inputs.begin() + primitive_size, bprop_fg->parameters().begin(), - bprop_fg->parameters().end() - brprop_offset_size); + (void)inputs.insert(inputs.begin() + primitive_size, bprop_fg->parameters().begin(), + bprop_fg->parameters().end() - brprop_offset_size); AnfNodePtr params = bprop_fg->NewCNode(inputs); inputs.clear(); diff --git a/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc b/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc index b1dbda43de6..e2ed12d890d 100644 --- a/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc +++ b/mindspore/ccsrc/pipeline/jit/static_analysis/order_enforce.cc @@ -234,9 +234,7 @@ class OrderEnforcer { } // namespace -// // Enforce order of execution for Load users node. -// void OrderEnforce(const FuncGraphPtr &func_graph) { OrderEnforcer enforcer(func_graph); enforcer.Run(); diff --git a/mindspore/ccsrc/pybind_api/ir/primitive_py.cc b/mindspore/ccsrc/pybind_api/ir/primitive_py.cc index 81f3beff2fd..24226244d13 100644 --- a/mindspore/ccsrc/pybind_api/ir/primitive_py.cc +++ b/mindspore/ccsrc/pybind_api/ir/primitive_py.cc @@ -64,7 +64,7 @@ PrimitivePy::PrimitivePy(const py::object &python_obj, const PrimitivePyAdapterP : Primitive(adapter->name_, false), python_obj_(python_obj), adapter_(adapter) { MS_LOG(DEBUG) << "New primitive:" << adapter->name_; set_signatures(adapter->signatures_); - Primitive::SetAttrs(adapter->attrs_); + (void)Primitive::SetAttrs(adapter->attrs_); Primitive::set_prim_type(adapter->prim_type_); Primitive::set_const_prim(adapter->is_const_prim_); Primitive::set_const_input_indexes(adapter->const_input_indexes_); @@ -305,7 +305,7 @@ void PrimitivePy::CopyHookFunction(const PrimitivePtr &primitive) { MS_EXCEPTION_IF_NULL(primitive_py); this->set_hook(primitive_py->hook()); if (primitive_py->HasAttr(kBpropAttrName)) { - this->AddAttr(kBpropAttrName, primitive_py->GetAttr(kBpropAttrName)); + (void)this->AddAttr(kBpropAttrName, primitive_py->GetAttr(kBpropAttrName)); } } @@ -392,11 +392,11 @@ void PrimitivePyAdapter::AddPyAttr(const py::str &name, const py::object &obj) { if (kOpAttrNameReplaceMap.find(attr_name) != kOpAttrNameReplaceMap.end()) { attr_name = kOpAttrNameReplaceMap[attr_name]; } - CheckAndConvertUtils::ConvertAttrValueToInt(name_, name, &converted_ret); + (void)CheckAndConvertUtils::ConvertAttrValueToInt(name_, name, &converted_ret); attrs_[attr_name] = converted_ret; auto prim = attached_primitive_.lock(); if (prim != nullptr) { - prim->AddAttr(attr_name, converted_ret); + (void)prim->AddAttr(attr_name, converted_ret); } if (attr_name == "primitive_target") { @@ -415,10 +415,10 @@ void PrimitivePyAdapter::AddPyAttr(const py::str &name, const py::object &obj) { } void PrimitivePyAdapter::DelPyAttr(const py::str &name) { - attrs_.erase(name); + (void)attrs_.erase(name); auto prim = attached_primitive_.lock(); if (prim != nullptr) { - prim->DelAttr(name); + (void)prim->DelAttr(name); } } diff --git a/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc b/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc index e52da9f6574..c431349ed8f 100644 --- a/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc +++ b/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc @@ -22,7 +22,7 @@ namespace mindspore { namespace { -void MsCtxSetParameter(std::shared_ptr ctx, MsCtxParam param, const py::object &value) { +void MsCtxSetParameter(const std::shared_ptr &ctx, MsCtxParam param, const py::object &value) { MS_LOG(DEBUG) << "set param(" << param << ") with value '" << py::str(value).cast() << "' of type '" << py::str(value.get_type()).cast() << "'."; if (param >= MS_CTX_TYPE_BOOL_BEGIN && param < MS_CTX_TYPE_BOOL_END && py::isinstance(value)) { diff --git a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc index 97cdf4aab29..2c495845759 100644 --- a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc +++ b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc @@ -46,10 +46,11 @@ std::vector GetTokens(const std::string &str, const std::string &de std::pair ParseFlag(const std::string &flag) { auto i = flag.find("--"); // check the string starts with "--". - if (i != 0 || flag.size() == 2) { + constexpr size_t expected_size = 2; + if (i != 0 || flag.size() == expected_size) { return std::pair(); } - i += 2; + i += expected_size; auto j = flag.find('=', i + 1); // the key should not be empty, "--=" is invalid if (j == std::string::npos) {