Browse Source

fix open source static check

pull/15793/head
jiangshuqiang 5 years ago
parent
commit
e90697801e
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

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

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

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;
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;
}



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

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

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(std::string tensor_name);

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

void CheckDebuggerEnabledParam();
void CheckDebuggerEnabledParam() const;

bool CheckDebuggerPartialMemoryEnabled();

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

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

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


Loading…
Cancel
Save