fix codedex

pull/2017/head
leopz 5 years ago
parent 9dfb1011fe
commit 6d155e5f4a

@ -1982,7 +1982,11 @@ class IrParser {
MS_LOG(EXCEPTION) << "Cast to type 'PrimitivePyPtr' error";
}
} else {
ptr = std::make_shared<PrimitivePy>(id.substr(strlen("PrimitivePy::")), py_obj);
auto len = strlen("PrimitivePy::");
if (id.size() < len) {
return TOK_ERROR;
}
ptr = std::make_shared<PrimitivePy>(id.substr(len), py_obj);
}
*val_ptr = ptr;
@ -1999,7 +2003,7 @@ class IrParser {
return next;
}
Token ParseValueGraphAndNamespace(const std::string &id, ValuePtr *val_ptr) {
Token ParseValueGraphAndNamespace(const std::string &id, ValuePtr *const val_ptr) {
if (Match(id, "MultitypeFuncGraph::")) {
std::string name = id.substr(strlen("MultitypeFuncGraph::"));
auto mt_func_graph = std::make_shared<prim::MultitypeFuncGraph>(name);
@ -2039,7 +2043,7 @@ class IrParser {
}
}
Token ParseValueBasic(const FuncGraphPtr &func_graph, const std::string &id, ValuePtr *val_ptr,
Token ParseValueBasic(const FuncGraphPtr &func_graph, const std::string &id, ValuePtr *const val_ptr,
AnfNodePtr *const node_ptr = nullptr) {
if (id == "None") {
*val_ptr = std::make_shared<None>();

@ -90,7 +90,7 @@ class Primitive : public Named {
}
const std::unordered_map<std::string, ValuePtr> &attrs() const { return attrs_; }
std::unordered_map<std::string, ValuePtr> &evaluate_added_attrs() { return evaluate_added_attrs_; }
const std::unordered_map<std::string, ValuePtr> &evaluate_added_attrs() const { return evaluate_added_attrs_; }
// if Primitive has any attribute, for Primitives like scalar_add, return, etc, don't have any attribute.
bool HasAttr() const { return !attrs_.empty(); }

@ -646,7 +646,7 @@ void ProcessVmArgInner(const py::tuple &args, const ResourcePtr &res, VectorRef
}
}
void ExecutorPy::ProcessVmArg(const py::tuple &args, const std::string &phase, VectorRef *arg_list) {
void ExecutorPy::ProcessVmArg(const py::tuple &args, const std::string &phase, VectorRef *const arg_list) {
ProcessVmArgInner(args, GetResource(phase), arg_list);
}

@ -289,7 +289,7 @@ class LogConfigLexer {
return '\0';
}
LogConfigToken GetNext(std::string *ptr) {
LogConfigToken GetNext(std::string *const ptr) {
#ifdef DEBUG
std::string text;
auto tok = GetNextInner(&text);

@ -261,12 +261,12 @@ const std::set<std::string> kNeedTransFormatSet = {kOpFormat_FRAC_Z, kOpFo
kOpFormat_FRACTAL_Z_C04};
static inline void ChangeFileMode(const std::string &file_name, mode_t mode) {
if (access(file_name.c_str(), F_OK) != 0) {
MS_LOG(DEBUG) << "File `" << file_name << "` does not exist.";
return;
}
if (chmod(file_name.c_str(), mode) != 0) {
MS_LOG(WARNING) << "Change file `" << file_name << "` to mode " << std::oct << mode << " fail.";
try {
if (chmod(file_name.c_str(), mode) != 0) {
MS_LOG(WARNING) << "Change file `" << file_name << "` to mode " << std::oct << mode << " fail.";
}
} catch (std::exception &e) {
MS_LOG(DEBUG) << "File `" << file_name << "` change mode failed! May be not exist.";
}
}
} // namespace mindspore

Loading…
Cancel
Save