diff --git a/libretroshare/src/grouter/grouteritems.h b/libretroshare/src/grouter/grouteritems.h index 505f35361..9777c074b 100644 --- a/libretroshare/src/grouter/grouteritems.h +++ b/libretroshare/src/grouter/grouteritems.h @@ -59,7 +59,7 @@ const uint8_t QOS_PRIORITY_RS_GROUTER = 4 ; // relevant for items that travel class RsGRouterItem: public RsItem { public: - RsGRouterItem(uint8_t grouter_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GROUTER,grouter_subtype) {} + explicit RsGRouterItem(uint8_t grouter_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GROUTER,grouter_subtype) {} virtual ~RsGRouterItem() {} @@ -90,7 +90,7 @@ class RsGRouterNonCopyableObject class RsGRouterAbstractMsgItem: public RsGRouterItem { public: - RsGRouterAbstractMsgItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {} + explicit RsGRouterAbstractMsgItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype), flags(0) {} virtual ~RsGRouterAbstractMsgItem() {} GRouterMsgPropagationId routing_id ; @@ -103,7 +103,7 @@ public: class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRouterNonCopyableObject { public: - RsGRouterGenericDataItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; } + RsGRouterGenericDataItem() : RsGRouterAbstractMsgItem(RS_PKT_SUBTYPE_GROUTER_DATA), data_size(0), data_bytes(NULL), duplication_factor(0) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; } virtual ~RsGRouterGenericDataItem() { clear() ; } virtual void clear() @@ -144,7 +144,7 @@ class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem class RsGRouterTransactionItem: public RsGRouterItem { public: - RsGRouterTransactionItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {} + explicit RsGRouterTransactionItem(uint8_t pkt_subtype) : RsGRouterItem(pkt_subtype) {} virtual ~RsGRouterTransactionItem() {} @@ -156,7 +156,7 @@ class RsGRouterTransactionItem: public RsGRouterItem class RsGRouterTransactionChunkItem: public RsGRouterTransactionItem, public RsGRouterNonCopyableObject { public: - RsGRouterTransactionChunkItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_CHUNK) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; } + RsGRouterTransactionChunkItem() : RsGRouterTransactionItem(RS_PKT_SUBTYPE_GROUTER_TRANSACTION_CHUNK), chunk_start(0), chunk_size(0), total_size(0), chunk_data(NULL) { setPriorityLevel(QOS_PRIORITY_RS_GROUTER) ; } virtual ~RsGRouterTransactionChunkItem() { free(chunk_data) ; } @@ -217,7 +217,7 @@ class RsGRouterMatrixCluesItem: public RsGRouterItem class RsGRouterMatrixTrackItem: public RsGRouterItem { public: - RsGRouterMatrixTrackItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_MATRIX_TRACK) + RsGRouterMatrixTrackItem() : RsGRouterItem(RS_PKT_SUBTYPE_GROUTER_MATRIX_TRACK), time_stamp(0) { setPriorityLevel(0) ; } // this item is never sent through the network virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); @@ -271,7 +271,7 @@ class RsGRouterRoutingInfoItem: public RsGRouterItem, public GRouterRoutingInfo, class RsGRouterSerialiser: public RsServiceSerializer { public: - RsGRouterSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) : RsServiceSerializer(RS_SERVICE_TYPE_GROUTER,RsGenericSerializer::FORMAT_BINARY,flags) {} + explicit RsGRouterSerialiser(SerializationFlags flags = SERIALIZATION_FLAG_NONE) : RsServiceSerializer(RS_SERVICE_TYPE_GROUTER,RsGenericSerializer::FORMAT_BINARY,flags) {} virtual RsItem *create_item(uint16_t service,uint8_t subtype) const ; }; diff --git a/libretroshare/src/grouter/groutertypes.h b/libretroshare/src/grouter/groutertypes.h index 91eb1608b..df8c90d48 100644 --- a/libretroshare/src/grouter/groutertypes.h +++ b/libretroshare/src/grouter/groutertypes.h @@ -97,11 +97,17 @@ class GRouterRoutingInfo // ovoids lots of duplications if the class is copied. public: GRouterRoutingInfo() - { - data_transaction_TS = 0 ; // this is not serialised. - data_item = NULL ; - receipt_item = NULL ; - } + : data_status(0) + , tunnel_status(0) + , received_time_TS(0) + , last_sent_TS(0) + , last_tunnel_request_TS(0) + , sending_attempts(0) + , routing_flags(0) + , data_item(NULL) + , receipt_item(NULL) + , data_transaction_TS(0) // this is not serialised. + {} uint32_t data_status ; // pending, waiting, etc. uint32_t tunnel_status ; // status of tunnel handling. diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index 0717ee15f..75e8fd4d6 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -204,7 +204,7 @@ const std::string p3GRouter::SERVICE_INFO_APP_NAME = "Global Router" ; p3GRouter::p3GRouter(p3ServiceControl *sc, RsGixs *is) - : p3Service(), p3Config(), mServiceControl(sc), mGixs(is), grMtx("GRouter") + : p3Service(), p3Config(), mServiceControl(sc), mTurtle(NULL), mGixs(is), grMtx("GRouter") { addSerialType(new RsGRouterSerialiser()) ; @@ -2292,6 +2292,8 @@ bool p3GRouter::saveList(bool& cleanup,std::list& items) { RsGRouterRoutingInfoItem *item = new RsGRouterRoutingInfoItem ; +#warning: Cppcheck(cstyleCast): C-style pointer casting + // cppcheck-suppress cstyleCast *(GRouterRoutingInfo*)item = it->second ; // copy all members item->data_item = it->second.data_item->duplicate() ; // deep copy, because we call delete on the object, and the item might be removed before we handle it in the client. diff --git a/libretroshare/src/grouter/p3grouter.h b/libretroshare/src/grouter/p3grouter.h index 4ed537496..71b2fc138 100644 --- a/libretroshare/src/grouter/p3grouter.h +++ b/libretroshare/src/grouter/p3grouter.h @@ -79,7 +79,7 @@ class GRouterDataInfo { // ! This class does not have a copy constructor that duplicates the incoming data buffer. This is on purpose! public: - GRouterDataInfo() + GRouterDataInfo() : last_activity_TS(0) { incoming_data_buffer = NULL ; } @@ -339,7 +339,7 @@ private: p3ServiceControl *mServiceControl ; p3turtle *mTurtle ; RsGixs *mGixs ; - p3LinkMgr *mLinkMgr ; + //p3LinkMgr *mLinkMgr ; // Multi-thread protection mutex. // diff --git a/libretroshare/src/gxs/gxstokenqueue.h b/libretroshare/src/gxs/gxstokenqueue.h index 4883fecbf..1099cd338 100644 --- a/libretroshare/src/gxs/gxstokenqueue.h +++ b/libretroshare/src/gxs/gxstokenqueue.h @@ -48,7 +48,7 @@ struct GxsTokenQueueItem class GxsTokenQueue { public: - GxsTokenQueue(RsGenExchange *gxs) : + explicit GxsTokenQueue(RsGenExchange *gxs) : mGenExchange(gxs), mQueueMtx("GxsTokenQueueMtx") {} bool queueRequest(uint32_t token, uint32_t req_type); diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index d82e5ba45..0c32bab92 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -82,6 +82,7 @@ RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService mLastClean((int)time(NULL) - (int)(RSRandom::random_u32() % MSG_CLEANUP_PERIOD)), // this helps unsynchronising the checks for the different services mMsgCleanUp(NULL), mChecking(false), + mCheckStarted(false), mLastCheck((int)time(NULL) - (int)(RSRandom::random_u32() % INTEGRITY_CHECK_PERIOD) + 120), // this helps unsynchronising the checks for the different services, with 2 min security to avoid checking right away before statistics come up. mIntegrityCheck(NULL), SIGN_MAX_WAITING_TIME(60), @@ -1234,7 +1235,7 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token, #ifdef GEN_EXCH_DEBUG std::cerr << "RsGenExchange::getMsgMeta(): retrieving meta data for token " << token << std::endl; #endif - std::list metaL; + //std::list metaL; GxsMsgMetaResult result; bool ok = mDataAccess->getMsgSummary(token, result); @@ -2168,15 +2169,13 @@ void RsGenExchange::publishMsgs() uint32_t size = mSerialiser->size(msgItem); char* mData = new char[size]; - bool serialOk = false; - // for fatal sign creation bool createOk = false; // if sign requests to try later bool tryLater = false; - serialOk = mSerialiser->serialise(msgItem, mData, &size); + bool serialOk = mSerialiser->serialise(msgItem, mData, &size); if(serialOk) { @@ -2266,6 +2265,8 @@ void RsGenExchange::publishMsgs() char* metaDataBuff = new char[size]; bool s = msg->metaData->serialise(metaDataBuff, &size); s &= msg->meta.setBinData(metaDataBuff, size); + if (!s) + std::cerr << "(WW) Can't serialise or set bin data" << std::endl; msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED; msgId = msg->msgId; diff --git a/libretroshare/src/gxs/rsgixs.h b/libretroshare/src/gxs/rsgixs.h index 6e8591a4a..df3c8af46 100644 --- a/libretroshare/src/gxs/rsgixs.h +++ b/libretroshare/src/gxs/rsgixs.h @@ -176,7 +176,7 @@ public: class GixsReputation { public: - GixsReputation() {} + GixsReputation() :reputation_level(0) {} RsGxsId id; uint32_t reputation_level ; diff --git a/libretroshare/src/gxs/rsgxsdataaccess.h b/libretroshare/src/gxs/rsgxsdataaccess.h index 04a785286..ef132dc0e 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.h +++ b/libretroshare/src/gxs/rsgxsdataaccess.h @@ -37,7 +37,7 @@ typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter; class RsGxsDataAccess : public RsTokenService { public: - RsGxsDataAccess(RsGeneralDataService* ds); + explicit RsGxsDataAccess(RsGeneralDataService* ds); virtual ~RsGxsDataAccess() ; public: diff --git a/libretroshare/src/gxstrans/p3gxstrans.h b/libretroshare/src/gxstrans/p3gxstrans.h index 47ef1020d..af79679d9 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.h +++ b/libretroshare/src/gxstrans/p3gxstrans.h @@ -293,7 +293,7 @@ private: enum CheckState { CheckStart, CheckChecking }; public: - GxsTransIntegrityCleanupThread(RsGeneralDataService *const dataService): mDs(dataService),mMtx("GxsTransIntegrityCheck") { mDone=false;} + explicit GxsTransIntegrityCleanupThread(RsGeneralDataService *const dataService): mDs(dataService),mMtx("GxsTransIntegrityCheck") { mDone=false;} bool isDone(); void run(); diff --git a/libretroshare/src/gxstrans/p3gxstransitems.h b/libretroshare/src/gxstrans/p3gxstransitems.h index bfaa98474..f158d0bdd 100644 --- a/libretroshare/src/gxstrans/p3gxstransitems.h +++ b/libretroshare/src/gxstrans/p3gxstransitems.h @@ -39,7 +39,7 @@ public: class RsGxsTransBaseMsgItem : public RsGxsMsgItem { public: - RsGxsTransBaseMsgItem(GxsTransItemsSubtypes subtype) : + explicit RsGxsTransBaseMsgItem(GxsTransItemsSubtypes subtype) : RsGxsMsgItem( RS_SERVICE_TYPE_GXS_TRANS, static_cast(subtype) ), mailId(0) {} diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.h b/libretroshare/src/gxstunnel/p3gxstunnel.h index 0586732ba..cabe520d4 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.h +++ b/libretroshare/src/gxstunnel/p3gxstunnel.h @@ -124,7 +124,7 @@ static const uint32_t GXS_TUNNEL_AES_KEY_SIZE = 16 ; class p3GxsTunnelService: public RsGxsTunnelService, public RsTurtleClientService, public p3Service { public: - p3GxsTunnelService(RsGixs *pids) ; + explicit p3GxsTunnelService(RsGixs *pids) ; virtual void connectToTurtleRouter(p3turtle *) ; // Creates the invite if the public key of the distant peer is available. diff --git a/libretroshare/src/gxstunnel/rsgxstunnelitems.h b/libretroshare/src/gxstunnel/rsgxstunnelitems.h index 1bec905c8..8c4e95ba4 100644 --- a/libretroshare/src/gxstunnel/rsgxstunnelitems.h +++ b/libretroshare/src/gxstunnel/rsgxstunnelitems.h @@ -53,7 +53,7 @@ typedef uint64_t GxsTunnelDHSessionId ; class RsGxsTunnelItem: public RsItem { public: - RsGxsTunnelItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GXS_TUNNEL,item_subtype) + explicit RsGxsTunnelItem(uint8_t item_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_GXS_TUNNEL,item_subtype) { setPriorityLevel(QOS_PRIORITY_RS_CHAT_ITEM) ; } @@ -72,8 +72,8 @@ class RsGxsTunnelItem: public RsItem class RsGxsTunnelDataItem: public RsGxsTunnelItem { public: - RsGxsTunnelDataItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA) { data=NULL ;data_size=0;service_id=0;unique_item_counter=0; } - RsGxsTunnelDataItem(uint8_t subtype) :RsGxsTunnelItem(subtype) { data=NULL ;data_size=0; } + RsGxsTunnelDataItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA), unique_item_counter(0), flags(0), service_id(0), data_size(0), data(NULL) {} + explicit RsGxsTunnelDataItem(uint8_t subtype) :RsGxsTunnelItem(subtype) , unique_item_counter(0), flags(0), service_id(0), data_size(0), data(NULL) {} virtual ~RsGxsTunnelDataItem() {} virtual void clear() {} @@ -108,7 +108,7 @@ class RsGxsTunnelStatusItem: public RsGxsTunnelItem class RsGxsTunnelDataAckItem: public RsGxsTunnelItem { public: - RsGxsTunnelDataAckItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA_ACK) {} + RsGxsTunnelDataAckItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DATA_ACK), unique_item_counter(0) {} RsGxsTunnelDataAckItem(void *data,uint32_t size) ; // deserialization virtual ~RsGxsTunnelDataAckItem() {} @@ -125,7 +125,7 @@ class RsGxsTunnelDataAckItem: public RsGxsTunnelItem class RsGxsTunnelDHPublicKeyItem: public RsGxsTunnelItem { public: - RsGxsTunnelDHPublicKeyItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY) {} + RsGxsTunnelDHPublicKeyItem() :RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY), public_key(NULL) {} RsGxsTunnelDHPublicKeyItem(void *data,uint32_t size) ; // deserialization virtual ~RsGxsTunnelDHPublicKeyItem() ; @@ -141,8 +141,8 @@ class RsGxsTunnelDHPublicKeyItem: public RsGxsTunnelItem private: // make the object non copy-able - RsGxsTunnelDHPublicKeyItem(const RsGxsTunnelDHPublicKeyItem&) : RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY) {} - const RsGxsTunnelDHPublicKeyItem& operator=(const RsGxsTunnelDHPublicKeyItem&) { return *this ;} + RsGxsTunnelDHPublicKeyItem(const RsGxsTunnelDHPublicKeyItem&) : RsGxsTunnelItem(RS_PKT_SUBTYPE_GXS_TUNNEL_DH_PUBLIC_KEY), public_key(NULL) {} + const RsGxsTunnelDHPublicKeyItem& operator=(const RsGxsTunnelDHPublicKeyItem&) { public_key = NULL; return *this ;} }; class RsGxsTunnelSerialiser: public RsServiceSerializer