diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 58aba98d..66b84b56 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -4432,11 +4432,7 @@ std::string PCM::getCPUFamilyModelString(const uint32 cpu_family_, const uint32 { char buffer[sizeof(int)*4*3+6]; std::fill(buffer, buffer + sizeof(buffer), 0); -#ifdef _MSC_VER - sprintf_s(buffer,sizeof(buffer),"GenuineIntel-%d-%2X-%X", cpu_family_, cpu_model_, cpu_stepping_); -#else - snprintf(buffer,sizeof(buffer),"GenuineIntel-%d-%2X-%X", cpu_family_, cpu_model_, cpu_stepping_); -#endif + std::snprintf(buffer,sizeof(buffer),"GenuineIntel-%d-%2X-%X", cpu_family_, cpu_model_, cpu_stepping_); std::string result(buffer); return result; } diff --git a/src/pcm-accel.cpp b/src/pcm-accel.cpp index 5f560114..8c8d79a9 100644 --- a/src/pcm-accel.cpp +++ b/src/pcm-accel.cpp @@ -4,7 +4,6 @@ #include "pcm-accel-common.h" #ifdef _MSC_VER -#pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" #else diff --git a/src/pcm-iio.cpp b/src/pcm-iio.cpp index 0ab606b5..bfc8f570 100644 --- a/src/pcm-iio.cpp +++ b/src/pcm-iio.cpp @@ -7,7 +7,6 @@ #include "cpucounters.h" #ifdef _MSC_VER - #pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" #else diff --git a/src/pcm-latency.cpp b/src/pcm-latency.cpp index 05610f65..36c86e2e 100644 --- a/src/pcm-latency.cpp +++ b/src/pcm-latency.cpp @@ -4,7 +4,6 @@ // written by Subhiksha Ravisundar #include "cpucounters.h" #ifdef _MSC_VER -#pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" #else diff --git a/src/pcm-lspci.cpp b/src/pcm-lspci.cpp index 72b52942..6dc716e9 100644 --- a/src/pcm-lspci.cpp +++ b/src/pcm-lspci.cpp @@ -4,7 +4,6 @@ // written by Patrick Lu #include "cpucounters.h" #ifdef _MSC_VER -#pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" #else diff --git a/src/pcm-msr.cpp b/src/pcm-msr.cpp index ca6f5263..6a40cf36 100644 --- a/src/pcm-msr.cpp +++ b/src/pcm-msr.cpp @@ -167,8 +167,8 @@ int mainThrows(int argc, char * argv[]) uint64 value2 = value; extractBitsPrintHelper(bits, value, dec); char cname[100]; - if (core_in_dec) sprintf(cname,"%d",core); - else sprintf(cname,"0x%x",core); + if (core_in_dec) std::snprintf(cname, sizeof(cname), "%d", core); + else std::snprintf(cname, sizeof(cname), "0x%x", core); std::cout << " from MSR " << msr << " on core " << cname << "\n"; auto itx = it; itx++; diff --git a/src/utils.h b/src/utils.h index c2b42543..b8c56de9 100644 --- a/src/utils.h +++ b/src/utils.h @@ -37,6 +37,9 @@ #include #include +#ifdef __linux__ +#include +#endif namespace pcm { std::string safe_getenv(const char* env); }