From 10233ef1cc071ed7daebbc61264acf74c5055662 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 13:53:44 +0200 Subject: [PATCH 01/11] Fix CppCheck in groutertypes.h /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::data_status' is not initialized in the constructor. /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::tunnel_status' is not initialized in the constructor. /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::received_time_TS' is not initialized in the constructor. /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::last_sent_TS' is not initialized in the constructor. /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::last_tunnel_request_TS' is not initialized in the constructor. /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::sending_attempts' is not initialized in the constructor. /libretroshare/src/grouter/groutertypes.h:99: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterRoutingInfo::routing_flags' is not initialized in the constructor. --- libretroshare/src/grouter/groutertypes.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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. From 10721945a374a662244022aac6a8d79e2f146a5e Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 14:01:20 +0200 Subject: [PATCH 02/11] Fix CppCheck in grouteritems.h /libretroshare/src/grouter/grouteritems.h:93: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterAbstractMsgItem::flags' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:106: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterGenericDataItem::data_size' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:106: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterGenericDataItem::data_bytes' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:106: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterGenericDataItem::duplication_factor' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:159: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterTransactionChunkItem::chunk_start' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:159: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterTransactionChunkItem::chunk_size' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:159: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterTransactionChunkItem::total_size' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:159: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterTransactionChunkItem::chunk_data' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:220: warning: Cppcheck(uninitMemberVar): Member variable 'RsGRouterMatrixTrackItem::time_stamp' is not initialized in the constructor. /libretroshare/src/grouter/grouteritems.h:62: warning: Cppcheck(noExplicitConstructor): Class 'RsGRouterItem' has a constructor with 1 argument that is not explicit. /libretroshare/src/grouter/grouteritems.h:93: warning: Cppcheck(noExplicitConstructor): Class 'RsGRouterAbstractMsgItem' has a constructor with 1 argument that is not explicit. /libretroshare/src/grouter/grouteritems.h:147: warning: Cppcheck(noExplicitConstructor): Class 'RsGRouterTransactionItem' has a constructor with 1 argument that is not explicit. /libretroshare/src/grouter/grouteritems.h:274: warning: Cppcheck(noExplicitConstructor): Class 'RsGRouterSerialiser' has a constructor with 1 argument that is not explicit. --- libretroshare/src/grouter/grouteritems.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 ; }; From f81c6aea03dfe4d7c45c80b1f4394e34c87331d7 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 15:54:29 +0200 Subject: [PATCH 03/11] Fix CppCheck in p3grouter /libretroshare/src/grouter/p3grouter.cc:2295: warning: Cppcheck(cstyleCast): C-style pointer casting /libretroshare/src/grouter/p3grouter.h:82: warning: Cppcheck(uninitMemberVar): Member variable 'GRouterDataInfo::last_activity_TS' is not initialized in the constructor. /libretroshare/src/grouter/p3grouter.cc:206: warning: Cppcheck(uninitMemberVar): Member variable 'p3GRouter::mTurtle' is not initialized in the constructor. /libretroshare/src/grouter/p3grouter.cc:206: warning: Cppcheck(uninitMemberVar): Member variable 'p3GRouter::mLinkMgr' is not initialized in the constructor. --- libretroshare/src/grouter/p3grouter.cc | 4 +++- libretroshare/src/grouter/p3grouter.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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. // From 344bc27ff75a8f5f0cbab7060ecd58234d5fd8ba Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 15:55:40 +0200 Subject: [PATCH 04/11] Fix CppCheck in gxstokenqueue.h /libretroshare/src/gxs/gxstokenqueue.h:51: warning: Cppcheck(noExplicitConstructor): Class 'GxsTokenQueue' has a constructor with 1 argument that is not explicit. --- libretroshare/src/gxs/gxstokenqueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From eb7655c14f832a3af4dadc92c1a423dd9acd949c Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 16:18:09 +0200 Subject: [PATCH 05/11] Fix CppCheck in rsgenexchange.cc /libretroshare/src/gxs/rsgenexchange.cc:2165: warning: Cppcheck(redundantAssignment): Variable 'serialOk' is reassigned a value before the old one has been used. /libretroshare/src/gxs/rsgenexchange.cc:1227: warning: Cppcheck(unusedVariable): Unused variable: metaL /libretroshare/src/gxs/rsgenexchange.cc:2254: warning: Cppcheck(unreadVariable): Variable 's' is assigned a value that is never used. /libretroshare/src/gxs/rsgenexchange.cc:71: warning: Cppcheck(uninitMemberVar): Member variable 'RsGenExchange::mCheckStarted' is not initialized in the constructor. --- libretroshare/src/gxs/rsgenexchange.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; From 718c09e6d75f8e85abf2ecf08594021129909692 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 16:29:49 +0200 Subject: [PATCH 06/11] Fix CppCheck in rsgixs.h /libretroshare/src/gxs/rsgixs.h:179: warning: Cppcheck(uninitMemberVar): Member variable 'GixsReputation::reputation_level' is not initialized in the constructor. --- libretroshare/src/gxs/rsgixs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ; From 77c1ab4dd74f74de3471be1bbb9d8feed4fdd64c Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 16:31:17 +0200 Subject: [PATCH 07/11] Fix CppCheck in rsgxsdataaccess.h /libretroshare/src/gxs/rsgxsdataaccess.h:40: warning: Cppcheck(noExplicitConstructor): Class 'RsGxsDataAccess' has a constructor with 1 argument that is not explicit. --- libretroshare/src/gxs/rsgxsdataaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From 3702cf259a926b3da1d3fc914f3fdc8d45561a6c Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 17:20:11 +0200 Subject: [PATCH 08/11] Fix CppCheck in p3gxstrans.h /libretroshare/src/gxstrans/p3gxstrans.h:296: warning: Cppcheck(noExplicitConstructor): Class 'GxsTransIntegrityCleanupThread' has a constructor with 1 argument that is not explicit. --- libretroshare/src/gxstrans/p3gxstrans.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 242cc9d1990df2353f50527b833a2a9dee9ffcf7 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 17:22:16 +0200 Subject: [PATCH 09/11] Fix CppCheck in p3gxstransitems.h /libretroshare/src/gxstrans/p3gxstransitems.h:42: warning: Cppcheck(noExplicitConstructor): Class 'RsGxsTransBaseMsgItem' has a constructor with 1 argument that is not explicit. --- libretroshare/src/gxstrans/p3gxstransitems.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) {} From 4ed663a5c1645876bc7c6af4bbc9ef7b58aba257 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 17:23:02 +0200 Subject: [PATCH 10/11] Fix CppCheck in p3gxstunnel.h /libretroshare/src/gxstunnel/p3gxstunnel.h:127: warning: Cppcheck(noExplicitConstructor): Class 'p3GxsTunnelService' has a constructor with 1 argument that is not explicit. --- libretroshare/src/gxstunnel/p3gxstunnel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 722d98e43e1ba7df606b90735110ed40675c8baa Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Jul 2017 17:30:26 +0200 Subject: [PATCH 11/11] Fix CppCheck in rsgxstunnelitems.h /libretroshare/src/gxstunnel/rsgxstunnelitems.h:75: warning: Cppcheck(uninitMemberVar): Member variable 'RsGxsTunnelDataItem::flags' is not initialized in the constructor. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:76: warning: Cppcheck(uninitMemberVar): Member variable 'RsGxsTunnelDataItem::unique_item_counter' is not initialized in the constructor. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:76: warning: Cppcheck(uninitMemberVar): Member variable 'RsGxsTunnelDataItem::flags' is not initialized in the constructor. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:76: warning: Cppcheck(uninitMemberVar): Member variable 'RsGxsTunnelDataItem::service_id' is not initialized in the constructor. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:111: warning: Cppcheck(uninitMemberVar): Member variable 'RsGxsTunnelDataAckItem::unique_item_counter' is not initialized in the constructor. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:128: warning: Cppcheck(uninitMemberVar): Member variable 'RsGxsTunnelDHPublicKeyItem::public_key' is not initialized in the constructor. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:145: warning: Cppcheck(operatorEqVarError): Member variable 'RsGxsTunnelDHPublicKeyItem::public_key' is not assigned a value in 'RsGxsTunnelDHPublicKeyItem::operator='. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:56: warning: Cppcheck(noExplicitConstructor): Class 'RsGxsTunnelItem' has a constructor with 1 argument that is not explicit. /libretroshare/src/gxstunnel/rsgxstunnelitems.h:76: warning: Cppcheck(noExplicitConstructor): Class 'RsGxsTunnelDataItem' has a constructor with 1 argument that is not explicit. --- libretroshare/src/gxstunnel/rsgxstunnelitems.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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