diff --git a/mindspore/ccsrc/debug/data_dump/e2e_dump.cc b/mindspore/ccsrc/debug/data_dump/e2e_dump.cc index 013c486b0e3..43f3ecb715b 100644 --- a/mindspore/ccsrc/debug/data_dump/e2e_dump.cc +++ b/mindspore/ccsrc/debug/data_dump/e2e_dump.cc @@ -425,9 +425,11 @@ bool E2eDump::isDatasetGraph(const session::KernelGraph *graph) { } bool E2eDump::DumpDirExists(const std::string &dump_path) { DIR *dir = opendir(dump_path.c_str()); - if (dir) { + if (dir != nullptr) { MS_LOG(INFO) << "Dump dir " << dump_path << " exists"; - closedir(dir); + if (closedir(dir) == -1) { + MS_LOG(WARNING) << "Dump dir " << dump_path << " close failed."; + } return true; } return false; @@ -446,12 +448,16 @@ bool E2eDump::MoveDumpFiles(const std::string &first_dir, const std::string &sec std::string old_file_path = first_dir + "/" + file_name; std::string new_file_path = second_dir + "/" + file_name; if (rename(old_file_path.c_str(), new_file_path.c_str()) != 0) { - closedir(d_handle); + if (closedir(d_handle) == -1) { + MS_LOG(WARNING) << "Dump dir " << first_dir << " close failed."; + } return false; } } - closedir(d_handle); + if (closedir(d_handle) == -1) { + MS_LOG(WARNING) << "Dump dir " << first_dir << " close failed."; + } return true; } @@ -469,11 +475,15 @@ bool E2eDump::DeleteDirContents(const std::string &dir_path) { int res = remove(file_path.c_str()); if (res != 0) { // Could not remove the file - closedir(d_handle); + if (closedir(d_handle) == -1) { + MS_LOG(WARNING) << "Dump dir " << dir_path << " close failed."; + } return false; } } - closedir(d_handle); + if (closedir(d_handle) == -1) { + MS_LOG(WARNING) << "Dump dir " << dir_path << " close failed."; + } return true; } } // namespace mindspore diff --git a/mindspore/ccsrc/pipeline/jit/parse/resolve.h b/mindspore/ccsrc/pipeline/jit/parse/resolve.h index ad8bdc27454..2e878284001 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/resolve.h +++ b/mindspore/ccsrc/pipeline/jit/parse/resolve.h @@ -126,7 +126,7 @@ class SymbolResolver { SymbolPtr symbol() { return symbol_; } - py::object &result() { return result_; } + const py::object &result() { return result_; } AnfNodePtr resolved_node() { return resolved_node_; } diff --git a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc index fab6f07feeb..b6025ed84aa 100644 --- a/mindspore/ccsrc/utils/context/graph_kernel_flags.cc +++ b/mindspore/ccsrc/utils/context/graph_kernel_flags.cc @@ -113,7 +113,7 @@ class FlagRegister { return !result->empty(); } - bool ParseValue(const std::string &s, bool *result) { + bool ParseValue(const std::string &s, bool *result) const { *result = (s.empty() || s == "true" || s == "on" || s == "1"); return *result || s == "false" || s == "off" || s == "0"; } diff --git a/mindspore/ccsrc/utils/primitive_utils.cc b/mindspore/ccsrc/utils/primitive_utils.cc index a0e991cfa10..59db1c276de 100644 --- a/mindspore/ccsrc/utils/primitive_utils.cc +++ b/mindspore/ccsrc/utils/primitive_utils.cc @@ -25,7 +25,7 @@ #include "pybind_api/ir/base_ref_py.h" namespace mindspore { -py::function GetBpropFunctionByObj(py::object obj) { +py::function GetBpropFunctionByObj(const py::object &obj) { static const std::string get_bprop_fn = "get_bprop_fn"; static const std::string ad_module = "mindspore.ops._grad"; static const std::string ad_experimental_module = "mindspore.ops._grad_experimental"; @@ -36,12 +36,12 @@ py::function GetBpropFunctionByObj(py::object obj) { return fn; } -py::function GetBpropFunction(std::string name) { +py::function GetBpropFunction(const std::string &name) { auto fn = GetBpropFunctionByObj(py::str(name)); return fn; } -py::function GetComputeFunction(std::string name) { +py::function GetComputeFunction(const std::string &name) { static const std::string module = "mindspore._extends.builtin_operations"; py::module mod = py::module::import(common::SafeCStr(module)); if (!py::hasattr(mod, common::SafeCStr(name))) { diff --git a/mindspore/ccsrc/utils/primitive_utils.h b/mindspore/ccsrc/utils/primitive_utils.h index cb3ad2c3b2d..b10bc48cf7b 100644 --- a/mindspore/ccsrc/utils/primitive_utils.h +++ b/mindspore/ccsrc/utils/primitive_utils.h @@ -25,11 +25,11 @@ namespace py = pybind11; namespace mindspore { -py::function GetBpropFunctionByObj(py::object obj); +py::function GetBpropFunctionByObj(const py::object &obj); -py::function GetBpropFunction(std::string name); +py::function GetBpropFunction(const std::string &name); -py::function GetComputeFunction(std::string name); +py::function GetComputeFunction(const std::string &name); BaseRef RunComputeFunction(const PrimitivePtr &prim, const VectorRef &args);