Skip to content

Commit 3cad50f

Browse files
committed
address cppcheck warnings
Change-Id: Idffcdf4528b59dd6bf9c4c35db6957b472ccc67b
1 parent 9e68351 commit 3cad50f

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/cpucounters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4659,7 +4659,7 @@ std::string PCM::getCPUFamilyModelString(const uint32 cpu_family_, const uint32
46594659
{
46604660
char buffer[sizeof(int)*4*3+6];
46614661
std::fill(buffer, buffer + sizeof(buffer), 0);
4662-
std::snprintf(buffer,sizeof(buffer),"GenuineIntel-%d-%2X-%X", cpu_family_, internal_cpu_model_, cpu_stepping_);
4662+
std::snprintf(buffer,sizeof(buffer),"GenuineIntel-%u-%2X-%X", cpu_family_, internal_cpu_model_, cpu_stepping_);
46634663
std::string result(buffer);
46644664
return result;
46654665
}

src/cpucounters.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,7 @@ class PCM_API PCM
15961596
typedef std::pair<std::shared_ptr<MMIORange>, uint32> MMIORegisterEncoding; // MMIORange shared ptr, offset
15971597
struct MMIORegisterEncodingHash : public PCICFGRegisterEncodingHash
15981598
{
1599+
// cppcheck-suppress duplInheritedMember
15991600
std::size_t operator()(const RawEventEncoding& e) const
16001601
{
16011602
std::size_t h4 = std::hash<uint64>{}(e[MMIOEventPosition::membar_bits1]);
@@ -1605,6 +1606,7 @@ class PCM_API PCM
16051606
};
16061607
struct MMIORegisterEncodingCmp : public PCICFGRegisterEncodingCmp
16071608
{
1609+
// cppcheck-suppress duplInheritedMember
16081610
bool operator ()(const RawEventEncoding& a, const RawEventEncoding& b) const
16091611
{
16101612
return PCICFGRegisterEncodingCmp::operator()(a,b)
@@ -3944,20 +3946,23 @@ class SocketCounterState : public BasicCounterState, public UncoreCounterState
39443946
friend class PCM;
39453947

39463948
protected:
3949+
// cppcheck-suppress duplInheritedMember
39473950
void readAndAggregate(std::shared_ptr<SafeMsrHandle> handle)
39483951
{
39493952
BasicCounterState::readAndAggregate(handle);
39503953
UncoreCounterState::readAndAggregate(handle);
39513954
}
39523955

39533956
public:
3957+
// cppcheck-suppress duplInheritedMember
39543958
SocketCounterState& operator += ( const BasicCounterState& ccs )
39553959
{
39563960
BasicCounterState::operator += ( ccs );
39573961

39583962
return *this;
39593963
}
39603964

3965+
// cppcheck-suppress duplInheritedMember
39613966
SocketCounterState& operator += ( const UncoreCounterState& ucs )
39623967
{
39633968
UncoreCounterState::operator += ( ucs );
@@ -3970,6 +3975,7 @@ class SocketCounterState : public BasicCounterState, public UncoreCounterState
39703975
SocketCounterState( SocketCounterState&& ) = default;
39713976
SocketCounterState & operator = ( SocketCounterState&& ) = default;
39723977

3978+
// cppcheck-suppress duplInheritedMember
39733979
SocketCounterState & operator = ( UncoreCounterState&& ucs ) {
39743980
UncoreCounterState::operator = ( std::move(ucs) );
39753981
return *this;
@@ -4000,6 +4006,7 @@ class SystemCounterState : public SocketCounterState
40004006
std::unordered_map<PCM::RawEventEncoding, std::vector<uint64>, PCM::PMTRegisterEncodingHash2> PMTValues{};
40014007

40024008
protected:
4009+
// cppcheck-suppress duplInheritedMember
40034010
void readAndAggregate(std::shared_ptr<SafeMsrHandle> handle)
40044011
{
40054012
BasicCounterState::readAndAggregate(handle);
@@ -4039,6 +4046,7 @@ class SystemCounterState : public SocketCounterState
40394046
SystemCounterState( SystemCounterState&& ) = default;
40404047
SystemCounterState & operator = ( SystemCounterState&& ) = default;
40414048

4049+
// cppcheck-suppress duplInheritedMember
40424050
SystemCounterState & operator += ( const SocketCounterState& scs )
40434051
{
40444052
BasicCounterState::operator += ( scs );
@@ -4047,6 +4055,7 @@ class SystemCounterState : public SocketCounterState
40474055
return *this;
40484056
}
40494057

4058+
// cppcheck-suppress duplInheritedMember
40504059
SystemCounterState & operator += ( const UncoreCounterState& ucs )
40514060
{
40524061
UncoreCounterState::operator += ( ucs );

src/msr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ uint32 MsrHandle::decrementNumInstances()
165165
MsrHandle::MsrHandle(uint32 cpu) : fd(-1), cpu_id(cpu)
166166
{
167167
char path[200];
168-
snprintf(path, 200, "/dev/cpuctl%d", cpu);
168+
snprintf(path, 200, "/dev/cpuctl%u", cpu);
169169
int handle = ::open(path, O_RDWR);
170170
if (handle < 0) throw std::exception();
171171
fd = handle;
@@ -228,11 +228,11 @@ MsrHandle::MsrHandle(uint32 cpu) : fd(-1), cpu_id(cpu)
228228
}
229229
char * path = new char[200];
230230
if (!path) throw std::runtime_error("Allocation of 200 bytes failed.");
231-
snprintf(path, 200, "/dev/cpu/%d/msr", cpu);
231+
snprintf(path, 200, "/dev/cpu/%u/msr", cpu);
232232
int handle = ::open(path, O_RDWR);
233233
if (handle < 0)
234234
{ // try Android msr device path
235-
snprintf(path, 200, "/dev/msr%d", cpu);
235+
snprintf(path, 200, "/dev/msr%u", cpu);
236236
handle = ::open(path, O_RDWR);
237237
}
238238
deleteAndNullifyArray(path);

src/pci.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ PciHandle::~PciHandle()
198198
#elif __APPLE__
199199

200200
PciHandle::PciHandle(uint32 groupnr_, uint32 bus_, uint32 device_, uint32 function_) :
201+
fd(-1),
201202
bus(bus_),
202203
device(device_),
203204
function(function_)

0 commit comments

Comments
 (0)