Skip to content

Commit

Permalink
use std::snprintf
Browse files Browse the repository at this point in the history
Change-Id: I0b7f554a6db89752be7d198dd4602c5fb163936e
  • Loading branch information
rdementi committed May 22, 2024
1 parent 6d442e9 commit f4eb81a
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/pcm-accel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "pcm-accel-common.h"
#ifdef _MSC_VER
#pragma warning(disable : 4996) // for sprintf
#include <windows.h>
#include "windows/windriver.h"
#else
Expand Down
1 change: 0 additions & 1 deletion src/pcm-iio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "cpucounters.h"

#ifdef _MSC_VER
#pragma warning(disable : 4996) // for sprintf
#include <windows.h>
#include "windows/windriver.h"
#else
Expand Down
1 change: 0 additions & 1 deletion src/pcm-latency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// written by Subhiksha Ravisundar
#include "cpucounters.h"
#ifdef _MSC_VER
#pragma warning(disable : 4996) // for sprintf
#include <windows.h>
#include "windows/windriver.h"
#else
Expand Down
1 change: 0 additions & 1 deletion src/pcm-lspci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// written by Patrick Lu
#include "cpucounters.h"
#ifdef _MSC_VER
#pragma warning(disable : 4996) // for sprintf
#include <windows.h>
#include "windows/windriver.h"
#else
Expand Down
4 changes: 2 additions & 2 deletions src/pcm-msr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit f4eb81a

Please sign in to comment.