Fix CppCheck in p3servicecontrol

/libretroshare/src/pqi/p3servicecontrol.cc:840: warning:
Cppcheck(unreadVariable): Variable 'changes' is assigned a value that is
never used.
/libretroshare/src/pqi/p3servicecontrol.cc:941: warning:
Cppcheck(unusedVariable): Unused variable: mit
/libretroshare/src/pqi/p3servicecontrol.cc:972: warning:
Cppcheck(unusedVariable): Unused variable: mit
/libretroshare/src/pqi/p3servicecontrol.cc:88: warning:
Cppcheck(uninitMemberVar): Member variable
'p3ServiceControl::mServiceServer' is not initialized in the
constructor.
/libretroshare/src/pqi/p3servicecontrol.h:69: warning:
Cppcheck(noExplicitConstructor): Class 'p3ServiceControl' has a
constructor with 1 argument that is not explicit.
/libretroshare/src/pqi/p3servicecontrol.cc:45: warning:
Cppcheck(noExplicitConstructor): Class 'RsServiceControlItem' has a
constructor with 1 argument that is not explicit.
/libretroshare/src/pqi/p3servicecontrol.cc:52: warning:
Cppcheck(noExplicitConstructor): Class 'RsServicePermissionItem' has a
constructor with 1 argument that is not explicit.
/libretroshare/src/pqi/p3servicecontrol.cc:359: warning:
Cppcheck(passedByValue): Function parameter 'serviceName' should be
passed by reference.
This commit is contained in:
Phenom 2017-07-21 19:08:38 +02:00 committed by csoler
parent d21b41f871
commit 50a9d8a1e3
2 changed files with 19 additions and 18 deletions

View File

@ -42,17 +42,17 @@ static const uint8_t RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS = 0x01 ;
class RsServiceControlItem: public RsItem
{
public:
RsServiceControlItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_SERVICE_CONTROL,item_subtype) {}
explicit RsServiceControlItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_SERVICE_CONTROL,item_subtype) {}
};
class RsServicePermissionItem: public RsServiceControlItem, public RsServicePermissions
{
public:
RsServicePermissionItem(): RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS) {}
RsServicePermissionItem(const RsServicePermissions& perms) : RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS), RsServicePermissions(perms) {}
RsServicePermissionItem(): RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS) {}
explicit RsServicePermissionItem(const RsServicePermissions& perms) : RsServiceControlItem(RS_PKT_SUBTYPE_SERVICE_CONTROL_SERVICE_PERMISSIONS), RsServicePermissions(perms) {}
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mServiceId,"mServiceId") ;
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,mServiceName,"mServiceName") ;
RsTypeSerializer::serial_process<bool> (j,ctx,mDefaultAllowed,"mDefaultAllowed") ;
@ -86,9 +86,10 @@ public:
RsServiceControl *rsServiceControl = NULL;
p3ServiceControl::p3ServiceControl(p3LinkMgr *linkMgr)
:RsServiceControl(), p3Config(),
mLinkMgr(linkMgr), mOwnPeerId(linkMgr->getOwnId()),
mCtrlMtx("p3ServiceControl"), mMonitorMtx("P3ServiceControl::Monitor")
: RsServiceControl(), p3Config(),
mLinkMgr(linkMgr), mOwnPeerId(linkMgr->getOwnId()),
mCtrlMtx("p3ServiceControl"), mMonitorMtx("P3ServiceControl::Monitor"),
mServiceServer(NULL)
{
mSerialiser = new ServiceControlSerialiser ;
}
@ -356,7 +357,7 @@ bool p3ServiceControl::getServicePermissions(uint32_t serviceId, RsServicePermis
return true;
}
bool p3ServiceControl::createDefaultPermissions_locked(uint32_t serviceId, std::string serviceName, bool defaultOn)
bool p3ServiceControl::createDefaultPermissions_locked(uint32_t serviceId, const std::string& serviceName, bool defaultOn)
{
std::map<uint32_t, RsServicePermissions>::iterator it;
it = mServicePermissionMap.find(serviceId);
@ -780,7 +781,7 @@ void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
#endif
/* find differences */
std::map<uint32_t, bool> changes;
//std::map<uint32_t, bool> changes;
std::set<uint32_t>::const_iterator it1, it2, eit1, eit2;
it1 = originalFilter.mAllowedServices.begin();
eit1 = originalFilter.mAllowedServices.end();
@ -796,7 +797,7 @@ void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
std::cerr << std::endl;
#endif
// removal
changes[*it1] = false;
//changes[*it1] = false;
filterChangeRemoved_locked(peerId, *it1);
++it1;
}
@ -808,7 +809,7 @@ void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
#endif
// addition.
filterChangeAdded_locked(peerId, *it2);
changes[*it2] = true;
//changes[*it2] = true;
++it2;
}
else
@ -826,7 +827,7 @@ void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
std::cerr << std::endl;
#endif
// removal
changes[*it1] = false;
//changes[*it1] = false;
filterChangeRemoved_locked(peerId, *it1);
}
@ -837,7 +838,7 @@ void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
std::cerr << std::endl;
#endif
// addition.
changes[*it2] = true;
//changes[*it2] = true;
filterChangeAdded_locked(peerId, *it2);
}
@ -938,7 +939,7 @@ void p3ServiceControl::filterChangeRemoved_locked(const RsPeerId &peerId, uint32
std::cerr << std::endl;
#endif
std::map<uint32_t, std::set<RsPeerId> >::iterator mit;
//std::map<uint32_t, std::set<RsPeerId> >::iterator mit;
std::set<RsPeerId> &peerSet = mServicePeerMap[serviceId];
std::set<RsPeerId>::iterator sit;
@ -969,7 +970,7 @@ void p3ServiceControl::filterChangeAdded_locked(const RsPeerId &peerId, uint32_t
std::cerr << std::endl;
#endif
std::map<uint32_t, std::set<RsPeerId> >::iterator mit;
//std::map<uint32_t, std::set<RsPeerId> >::iterator mit;
std::set<RsPeerId> &peerSet = mServicePeerMap[serviceId];

View File

@ -66,7 +66,7 @@ public:
/**
*/
p3ServiceControl(p3LinkMgr *linkMgr);
explicit p3ServiceControl(p3LinkMgr *linkMgr);
/**
* checks and update all added configurations
@ -171,7 +171,7 @@ bool updateFilterByPeer_locked(const RsPeerId &peerId);
void filterChangeAdded_locked(const RsPeerId &peerId, uint32_t serviceId);
void filterChangeRemoved_locked(const RsPeerId &peerId, uint32_t serviceId);
bool createDefaultPermissions_locked(uint32_t serviceId, std::string serviceName, bool defaultOn);
bool createDefaultPermissions_locked(uint32_t serviceId, const std::string& serviceName, bool defaultOn);
bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t serviceId);
p3LinkMgr *mLinkMgr;