Browse Source

!6109 [MD] replace snprinf with snprintf_s

Merge pull request !6109 from magemomou/print_s
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
3ed015e645
1 changed files with 6 additions and 7 deletions
  1. +6
    -7
      mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_dp_log.h

+ 6
- 7
mindspore/ccsrc/minddata/dataset/kernels/image/soft_dvpp/utils/soft_dp_log.h View File

@@ -65,19 +65,18 @@
#elif defined(USE_GLOG) #elif defined(USE_GLOG)
#include <securec.h>
#include <cstdio> #include <cstdio>
#include "glog/logging.h" #include "glog/logging.h"
template <typename... Args> template <typename... Args>
inline std::string GetFormatString(const char *format, Args... args) { inline std::string GetFormatString(const char *format, Args... args) {
char buf[BUFSIZ]; char buf[BUFSIZ];
int new_len = snprintf(&buf[0], BUFSIZ, format, args...);
new_len++;
if (new_len > BUFSIZ) {
std::vector<char> buf2(new_len);
snprintf(buf2.data(), new_len, format, args...);
return std::string(buf2.data());
}
#ifdef _WIN32
_snprintf_s(&buf[0], BUFSIZ, BUFSIZ - 1, format, args...);
#else
snprintf_s(&buf[0], BUFSIZ, BUFSIZ - 1, format, args...);
#endif
return buf; return buf;
} }


Loading…
Cancel
Save