Browse Source

!15752 fix open source static check

From: @jiang-shuqiang
Reviewed-by: @yelihua
Signed-off-by:
pull/15752/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
a094de8702
2 changed files with 15 additions and 12 deletions
  1. +12
    -9
      mindspore/ccsrc/debug/debugger/debugger.cc
  2. +3
    -3
      mindspore/ccsrc/debug/debugger/debugger.h

+ 12
- 9
mindspore/ccsrc/debug/debugger/debugger.cc View File

@@ -237,7 +237,7 @@ bool Debugger::CheckDebuggerEnabled() const {
return false; return false;
} }


void Debugger::CheckDebuggerEnabledParam() {
void Debugger::CheckDebuggerEnabledParam() const {
// check the value of env variable ENABLE_MS_DEBUGGER // check the value of env variable ENABLE_MS_DEBUGGER
const char *env_enable_char = std::getenv("ENABLE_MS_DEBUGGER"); const char *env_enable_char = std::getenv("ENABLE_MS_DEBUGGER");
if (env_enable_char != nullptr) { if (env_enable_char != nullptr) {
@@ -1098,16 +1098,19 @@ std::vector<std::string> Debugger::CheckOpOverflow() {


void Debugger::SetTrainingDone(bool training_done) { training_done_ = training_done; } void Debugger::SetTrainingDone(bool training_done) { training_done_ = training_done; }


bool Debugger::CheckPort(const char *port) {
char *p = const_cast<char *>(port);
bool Debugger::CheckPort(const char *port) const {
int num = 0; int num = 0;
if (*p == '0' && *(p + 1) != '\0') return false;
while (*p != '\0') {
if (*p < '0' || *p > '9') return false;
num = num * 10 + (*p) - '0';
if (num < 1 || num > 65535) return false;
p++;
const int min_port_num = 1;
const int max_port_num = 65535;
if (*port == '0' && *(port + 1) != '\0') return false;
int i = 0;
while (*(port + i) != '\0') {
if (*(port + i) < '0' || *(port + i) > '9') return false;
num = num * 10 + (*(port + i)) - '0';
if (num > max_port_num) return false;
i++;
} }
if (num < min_port_num) return false;
return true; return true;
} }




+ 3
- 3
mindspore/ccsrc/debug/debugger/debugger.h View File

@@ -143,7 +143,7 @@ class Debugger : public std::enable_shared_from_this<Debugger> {


void SetGraphPtr(const KernelGraphPtr &graph_ptr) { graph_ptr_ = graph_ptr; } void SetGraphPtr(const KernelGraphPtr &graph_ptr) { graph_ptr_ = graph_ptr; }


std::list<KernelGraphPtr> GetGraphPtrList() { return graph_ptr_list_; }
std::list<KernelGraphPtr> GetGraphPtrList() const { return graph_ptr_list_; }


bool TensorExistsInCurrent(const std::string &tensor_name); bool TensorExistsInCurrent(const std::string &tensor_name);


@@ -164,7 +164,7 @@ class Debugger : public std::enable_shared_from_this<Debugger> {
// check if debugger enabled // check if debugger enabled
bool CheckDebuggerEnabled() const; bool CheckDebuggerEnabled() const;


void CheckDebuggerEnabledParam();
void CheckDebuggerEnabledParam() const;


bool CheckDebuggerPartialMemoryEnabled() const; bool CheckDebuggerPartialMemoryEnabled() const;


@@ -219,7 +219,7 @@ class Debugger : public std::enable_shared_from_this<Debugger> {
std::vector<std::string> CheckOpOverflow(); std::vector<std::string> CheckOpOverflow();


// Check if the port is valid // Check if the port is valid
bool CheckPort(const char *port);
bool CheckPort(const char *port) const;


// Check if the IP is valid // Check if the IP is valid
bool CheckIp(const char *host) const; bool CheckIp(const char *host) const;


Loading…
Cancel
Save