Skip to content

Commit 9899e74

Browse files
committed
address cppcheck warnings
Change-Id: Idffcdf4528b59dd6bf9c4c35db6957b472ccc67b
1 parent 642c133 commit 9899e74

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
@@ -4641,7 +4641,7 @@ std::string PCM::getCPUFamilyModelString(const uint32 cpu_family_, const uint32
46414641
{
46424642
char buffer[sizeof(int)*4*3+6];
46434643
std::fill(buffer, buffer + sizeof(buffer), 0);
4644-
std::snprintf(buffer,sizeof(buffer),"GenuineIntel-%d-%2X-%X", cpu_family_, internal_cpu_model_, cpu_stepping_);
4644+
std::snprintf(buffer,sizeof(buffer),"GenuineIntel-%u-%2X-%X", cpu_family_, internal_cpu_model_, cpu_stepping_);
46454645
std::string result(buffer);
46464646
return result;
46474647
}

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)
@@ -3927,20 +3929,23 @@ class SocketCounterState : public BasicCounterState, public UncoreCounterState
39273929
friend class PCM;
39283930

39293931
protected:
3932+
// cppcheck-suppress duplInheritedMember
39303933
void readAndAggregate(std::shared_ptr<SafeMsrHandle> handle)
39313934
{
39323935
BasicCounterState::readAndAggregate(handle);
39333936
UncoreCounterState::readAndAggregate(handle);
39343937
}
39353938

39363939
public:
3940+
// cppcheck-suppress duplInheritedMember
39373941
SocketCounterState& operator += ( const BasicCounterState& ccs )
39383942
{
39393943
BasicCounterState::operator += ( ccs );
39403944

39413945
return *this;
39423946
}
39433947

3948+
// cppcheck-suppress duplInheritedMember
39443949
SocketCounterState& operator += ( const UncoreCounterState& ucs )
39453950
{
39463951
UncoreCounterState::operator += ( ucs );
@@ -3953,6 +3958,7 @@ class SocketCounterState : public BasicCounterState, public UncoreCounterState
39533958
SocketCounterState( SocketCounterState&& ) = default;
39543959
SocketCounterState & operator = ( SocketCounterState&& ) = default;
39553960

3961+
// cppcheck-suppress duplInheritedMember
39563962
SocketCounterState & operator = ( UncoreCounterState&& ucs ) {
39573963
UncoreCounterState::operator = ( std::move(ucs) );
39583964
return *this;
@@ -3983,6 +3989,7 @@ class SystemCounterState : public SocketCounterState
39833989
std::unordered_map<PCM::RawEventEncoding, std::vector<uint64>, PCM::PMTRegisterEncodingHash2> PMTValues{};
39843990

39853991
protected:
3992+
// cppcheck-suppress duplInheritedMember
39863993
void readAndAggregate(std::shared_ptr<SafeMsrHandle> handle)
39873994
{
39883995
BasicCounterState::readAndAggregate(handle);
@@ -4022,6 +4029,7 @@ class SystemCounterState : public SocketCounterState
40224029
SystemCounterState( SystemCounterState&& ) = default;
40234030
SystemCounterState & operator = ( SystemCounterState&& ) = default;
40244031

4032+
// cppcheck-suppress duplInheritedMember
40254033
SystemCounterState & operator += ( const SocketCounterState& scs )
40264034
{
40274035
BasicCounterState::operator += ( scs );
@@ -4030,6 +4038,7 @@ class SystemCounterState : public SocketCounterState
40304038
return *this;
40314039
}
40324040

4041+
// cppcheck-suppress duplInheritedMember
40334042
SystemCounterState & operator += ( const UncoreCounterState& ucs )
40344043
{
40354044
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)