Fixed code issues resulting in excessive warnings

Cleaned up GXS code a bit, removed unused functions and types from nxs and serialise items

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7203 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-03-23 12:13:44 +00:00
parent 057939270f
commit 5440aec17b
12 changed files with 83 additions and 117 deletions

View File

@ -153,9 +153,9 @@ const std::string RsGeneralDataService::MSG_META_STATUS = KEY_MSG_STATUS;
const uint32_t RsGeneralDataService::GXS_MAX_ITEM_SIZE = 1572864; // 1.5 Mbytes
RsDataService::RsDataService(const std::string &serviceDir, const std::string &dbName, uint16_t serviceType,
RsGxsSearchModule *mod, const std::string& key)
: RsGeneralDataService(), mServiceDir(serviceDir), mDbName(mServiceDir + "/" + dbName), mServType(serviceType),
mDbMutex("RsDataService"), mDb( new RetroDb(mDbName, RetroDb::OPEN_READWRITE_CREATE, key)) {
RsGxsSearchModule * /* mod */, const std::string& key)
: RsGeneralDataService(), mDbMutex("RsDataService"), mServiceDir(serviceDir), mDbName(mServiceDir + "/" + dbName), mServType(serviceType),
mDb( new RetroDb(mDbName, RetroDb::OPEN_READWRITE_CREATE, key)) {
initialise();
@ -792,7 +792,7 @@ bool RsDataService::validSize(RsNxsGrp* grp) const
return false;
}
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool cache){
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool /* cache */){
if(grp.empty()){
@ -888,7 +888,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
}
}
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool cache, bool withMeta)
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */, bool withMeta)
{
GxsMsgReq::const_iterator mit = reqIds.begin();
@ -1455,7 +1455,7 @@ uint32_t RsDataService::cacheSize() const {
return 0;
}
int RsDataService::setCacheSize(uint32_t size)
int RsDataService::setCacheSize(uint32_t /* size */)
{
return 0;
}

View File

@ -56,13 +56,31 @@
RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService *ns,
RsSerialType *serviceSerialiser, uint16_t servType, RsGixs* gixs,
uint32_t authenPolicy, uint32_t messageStorePeriod)
: mGenMtx("GenExchange"), mDataStore(gds), mNetService(ns), mSerialiser(serviceSerialiser),
mServType(servType), mGixs(gixs), mAuthenPolicy(authenPolicy), MESSAGE_STORE_PERIOD(messageStorePeriod),
CREATE_FAIL(0), CREATE_SUCCESS(1), CREATE_FAIL_TRY_LATER(2), SIGN_MAX_ATTEMPTS(5),
SIGN_FAIL(0), SIGN_SUCCESS(1), SIGN_FAIL_TRY_LATER(2),
VALIDATE_FAIL(0), VALIDATE_SUCCESS(1), VALIDATE_FAIL_TRY_LATER(2), VALIDATE_MAX_ATTEMPTS(5),
mCleaning(false), mLastClean(time(NULL)), mMsgCleanUp(NULL), mChecking(false), mIntegrityCheck(NULL),
mLastCheck(time(NULL))
: mGenMtx("GenExchange"),
mDataStore(gds),
mNetService(ns),
mSerialiser(serviceSerialiser),
mServType(servType),
mGixs(gixs),
mAuthenPolicy(authenPolicy),
MESSAGE_STORE_PERIOD(messageStorePeriod),
mCleaning(false),
mLastClean(time(NULL)),
mMsgCleanUp(NULL),
mChecking(false),
mLastCheck(time(NULL)),
mIntegrityCheck(NULL),
CREATE_FAIL(0),
CREATE_SUCCESS(1),
CREATE_FAIL_TRY_LATER(2),
SIGN_MAX_ATTEMPTS(5),
SIGN_FAIL(0),
SIGN_SUCCESS(1),
SIGN_FAIL_TRY_LATER(2),
VALIDATE_FAIL(0),
VALIDATE_SUCCESS(1),
VALIDATE_FAIL_TRY_LATER(2),
VALIDATE_MAX_ATTEMPTS(5)
{
mDataAccess = new RsGxsDataAccess(gds);
@ -284,7 +302,6 @@ void RsGenExchange::generatePublicFromPrivateKeys(const RsTlvSecurityKeySet &pri
typedef std::map<std::string, RsTlvSecurityKey> keyMap;
const keyMap& allKeys = privatekeySet.keys;
keyMap::const_iterator cit = allKeys.begin();
bool adminFound = false, publishFound = false;
for(; cit != allKeys.end(); cit++)
{
const RsTlvSecurityKey& privKey = cit->second;
@ -842,14 +859,12 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, RsTlvSecu
}
int RsGenExchange::validateGrp(RsNxsGrp* grp, RsTlvSecurityKeySet& grpKeySet)
int RsGenExchange::validateGrp(RsNxsGrp* grp)
{
bool needIdentitySign = false, idValidate = false;
RsGxsGrpMetaData& metaData = *(grp->metaData);
int id_ret;
uint8_t author_flag = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN;
PrivacyBitPos pos = GRP_OPTION_BITS;
@ -2388,7 +2403,7 @@ void RsGenExchange::processRecvdGroups()
if(deserialOk)
{
grp->metaData = meta;
uint8_t ret = validateGrp(grp, meta->keys);
uint8_t ret = validateGrp(grp);
if(ret == VALIDATE_SUCCESS)

View File

@ -752,11 +752,10 @@ private:
/*!
* Attempts to validate group signatures
* @param grp group to be validated
* @param grpKeySet the keys set user has for the group
* @return VALIDATE_SUCCESS for success, VALIDATE_FAIL for fail,
* VALIDATE_ID_SIGN_NOT_AVAIL for Id sign key not avail (but requested)
*/
int validateGrp(RsNxsGrp* grp, RsTlvSecurityKeySet& grpKeySet);
int validateGrp(RsNxsGrp* grp);
/*!
* Checks flag against a given privacy bit block

View File

@ -44,10 +44,10 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
RsNxsNetMgr *netMgr, RsNxsObserver *nxsObs,
const RsServiceInfo serviceInfo,
RsGixsReputation* reputations, RsGcxs* circles, bool grpAutoSync)
: p3Config(servType), p3ThreadedService(),
mTransactionTimeOut(TRANSAC_TIMEOUT), mServType(servType), mDataStore(gds), mTransactionN(0),
mObserver(nxsObs), mNxsMutex("RsGxsNetService"), mNetMgr(netMgr), mSYNC_PERIOD(SYNC_PERIOD),
mSyncTs(0), mReputations(reputations), mCircles(circles), mGrpAutoSync(grpAutoSync), mGrpServerUpdateItem(NULL),
: p3ThreadedService(), p3Config(servType), mTransactionN(0),
mObserver(nxsObs), mDataStore(gds), mServType(servType),
mTransactionTimeOut(TRANSAC_TIMEOUT), mNetMgr(netMgr), mNxsMutex("RsGxsNetService"),
mSyncTs(0), mSYNC_PERIOD(SYNC_PERIOD), mCircles(circles), mReputations(reputations), mGrpAutoSync(grpAutoSync), mGrpServerUpdateItem(NULL),
mServiceInfo(serviceInfo)
{
@ -2405,12 +2405,12 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
/** inherited methods **/
void RsGxsNetService::pauseSynchronisation(bool enabled)
void RsGxsNetService::pauseSynchronisation(bool /* enabled */)
{
}
void RsGxsNetService::setSyncAge(uint32_t age)
void RsGxsNetService::setSyncAge(uint32_t /* age */)
{
}

View File

@ -92,21 +92,6 @@ public:
*/
void setSyncAge(uint32_t age);
/*!
* Explicitly requests all the groups contained by a peer
* Circumvents polling of peers for message
* @param peerId id of peer
*/
void requestGroupsOfPeer(const RsPeerId& peerId){ return;}
/*!
* get messages of a peer for a given group id, this circumvents the normal
* polling of peers for messages of given group id
* @param peerId Id of peer
* @param grpId id of group to request messages for
*/
void requestMessagesOfPeer(const RsPeerId& peerId, const std::string& grpId){ return; }
/*!
* pauses synchronisation of subscribed groups and request for group id
* from peers
@ -121,7 +106,7 @@ public:
* @param msgId the messages to retrieve
* @return request token to be redeemed
*/
int requestMsg(const RsGxsGrpMsgIdPair& msgId){ return 0;}
int requestMsg(const RsGxsGrpMsgIdPair& /* msgId */){ return 0;}
/*!
* Request for this group is sent through to peers on your network

View File

@ -157,7 +157,7 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> s
return res ;
}
void chris_test();
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const std::string& s)
{
try
@ -166,7 +166,6 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t
if(s.length() != ID_SIZE_IN_BYTES*2)
{
throw std::runtime_error("t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size.") ;
chris_test();
}
for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; ++i)
@ -191,7 +190,6 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
chris_test();
clear() ;
}
}

View File

@ -1837,9 +1837,3 @@ int RsServer::StartupRetroShare()
return 1;
}
void chris_test()
{
std::cout << "tested\n";
}

View File

@ -38,8 +38,13 @@ void RsGxsGrpUpdateItem::clear()
std::ostream& RsGxsGrpUpdateItem::print(std::ostream& out, uint16_t indent)
{
printRsItemBase(out, "RsGxsGrpUpdateItem", indent);
uint16_t int_Indent = indent + 2;
out << "peerId: " << peerId << std::endl;
printIndent(out, int_Indent);
out << "grpUpdateTS: " << grpUpdateTS << std::endl;
printIndent(out, int_Indent);
return out ;
}
@ -52,6 +57,25 @@ void RsGxsMsgUpdateItem::clear()
std::ostream& RsGxsMsgUpdateItem::print(std::ostream& out, uint16_t indent)
{
RsPeerId peerId;
std::map<RsGxsGroupId, uint32_t> msgUpdateTS;
printRsItemBase(out, "RsGxsMsgUpdateItem", indent);
uint16_t int_Indent = indent + 2;
out << "peerId: " << peerId << std::endl;
printIndent(out, int_Indent);
std::map<RsGxsGroupId, uint32_t>::const_iterator cit = msgUpdateTS.begin();
out << "msgUpdateTS map:" << std::endl;
int_Indent += 2;
for(; cit != msgUpdateTS.end(); cit++)
{
out << "grpId: " << cit->first << std::endl;
printIndent(out, int_Indent);
out << "Msg time stamp: " << cit->second << std::endl;
printIndent(out, int_Indent);
}
return out;
}
@ -65,7 +89,13 @@ void RsGxsServerMsgUpdateItem::clear()
std::ostream& RsGxsServerMsgUpdateItem::print(std::ostream& out, uint16_t indent)
{
return out;
printRsItemBase(out, "RsGxsServerMsgUpdateItem", indent);
uint16_t int_Indent = indent + 2;
out << "grpId: " << grpId << std::endl;
printIndent(out, int_Indent);
out << "msgUpdateTS: " << msgUpdateTS << std::endl;
printIndent(out, int_Indent);
return out;
}
@ -76,6 +106,11 @@ void RsGxsServerGrpUpdateItem::clear()
std::ostream& RsGxsServerGrpUpdateItem::print(std::ostream& out, uint16_t indent)
{
printRsItemBase(out, "RsGxsServerGrpUpdateItem", indent);
uint16_t int_Indent = indent + 2;
out << "grpUpdateTS: " << grpUpdateTS << std::endl;
printIndent(out, int_Indent);
return out;
}
@ -182,7 +217,7 @@ uint32_t RsGxsUpdateSerialiser::sizeGxsGrpUpdate(RsGxsGrpUpdateItem* item)
return s;
}
uint32_t RsGxsUpdateSerialiser::sizeGxsServerGrpUpdate(RsGxsServerGrpUpdateItem* item)
uint32_t RsGxsUpdateSerialiser::sizeGxsServerGrpUpdate(RsGxsServerGrpUpdateItem* /* item */)
{
uint32_t s = 8; // header size
s += 4; // time stamp

View File

@ -109,8 +109,6 @@ RsItem* RsNxsSerialiser::deserialise(void *data, uint32_t *size) {
return deserialNxsMsg(data, size);
case RS_PKT_SUBTYPE_NXS_TRANS:
return deserialNxsTrans(data, size);
case RS_PKT_SUBTYPE_NXS_EXTENDED:
return deserialNxsExtended(data, size);
default:
{
#ifdef RSSERIAL_DEBUG
@ -133,7 +131,6 @@ bool RsNxsSerialiser::serialise(RsItem *item, void *data, uint32_t *size){
RsNxsSyncGrpItem* sgl;
RsNxsSyncMsg* sgm;
RsNxsSyncMsgItem* sgml;
RsNxsExtended* nxt;
RsNxsTransac* ntx;
if((sg = dynamic_cast<RsNxsSyncGrp*>(item)) != NULL)
@ -160,9 +157,6 @@ bool RsNxsSerialiser::serialise(RsItem *item, void *data, uint32_t *size){
}else if((nmg = dynamic_cast<RsNxsMsg*>(item)) != NULL)
{
return serialiseNxsMsg(nmg, data, size);
}else if((nxt = dynamic_cast<RsNxsExtended*>(item)) != NULL){
return serialiseNxsExtended(nxt, data, size);
}
#ifdef NXS_DEBUG
@ -524,12 +518,6 @@ bool RsNxsSerialiser::serialiseNxsSyncMsg(RsNxsSyncMsg *item, void *data, uint32
return ok;
}
bool RsNxsSerialiser::serialiseNxsExtended(RsNxsExtended *item, void *data, uint32_t *size){
return false;
}
/*** deserialisation ***/
@ -1015,12 +1003,6 @@ RsNxsSyncMsg* RsNxsSerialiser::deserialNxsSyncMsg(void *data, uint32_t *size)
}
RsNxsExtended* RsNxsSerialiser::deserialNxsExtended(void *data, uint32_t *size){
return NULL;
}
/*** size functions ***/
@ -1122,10 +1104,6 @@ uint32_t RsNxsSerialiser::sizeNxsTrans(RsNxsTransac *item){
return s;
}
uint32_t RsNxsSerialiser::sizeNxsExtended(RsNxsExtended *item){
return 0;
}
int RsNxsGrp::refcount = 0;
/** print and clear functions **/
@ -1205,19 +1183,6 @@ std::ostream& RsNxsSyncGrp::print(std::ostream &out, uint16_t indent)
return out;
}
std::ostream& RsNxsExtended::print(std::ostream &out, uint16_t indent){
printRsItemBase(out, "RsNxsExtended", indent);
uint16_t int_Indent = indent + 2;
printIndent(out , int_Indent);
out << "type: " << type << std::endl;
printIndent(out , int_Indent);
extData.print(out, int_Indent);
printRsItemEnd(out ,"RsNxsExtended", indent);
return out;
}
std::ostream& RsNxsSyncMsg::print(std::ostream &out, uint16_t indent)
{

View File

@ -48,7 +48,6 @@ const uint8_t RS_PKT_SUBTYPE_NXS_TRANS = 0x0040;
// possibility create second service to deal with this functionality
const uint8_t RS_PKT_SUBTYPE_NXS_EXTENDED = 0x0080; // in order to extend supported pkt subtypes
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_GRP = 0x0001;
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_MSG = 0x0002;
const uint8_t RS_PKT_SUBTYPE_EXT_DELETE_GRP = 0x0004;
@ -335,25 +334,6 @@ public:
};
/*!
* used to extend data types processed
*/
class RsNxsExtended : public RsNxsItem
{
public:
RsNxsExtended(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_EXTENDED), extData(servtype) { return; }
virtual ~RsNxsExtended() { return; }
virtual void clear() {}
virtual std::ostream &print(std::ostream &out, uint16_t indent);
RsTlvBinaryData extData;
uint32_t type;
};
/*!
* Used to respond to a RsGrpSearchReq
* with grpId/MsgIds that satisfy search request
@ -480,11 +460,6 @@ private:
virtual bool serialiseNxsTrans(RsNxsTransac* item, void* data, uint32_t* size);
virtual RsNxsTransac* deserialNxsTrans(void* data, uint32_t *size);
/* RS_PKT_SUBTYPE_EXTENDED */
virtual RsNxsExtended* deserialNxsExtended(void* data, uint32_t *size);
virtual uint32_t sizeNxsExtended(RsNxsExtended* item);
virtual bool serialiseNxsExtended(RsNxsExtended* item, void* data, uint32_t* size);
private:
const uint16_t SERVICE_TYPE;

View File

@ -176,12 +176,12 @@ template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem
std::cerr << "(EE) deserialisaiton error in " << __PRETTY_FUNCTION__ << std::endl;
return *offset == tlvend ;
}
virtual std::ostream &print(std::ostream &out, uint16_t indent)
virtual std::ostream &print(std::ostream &out, uint16_t /* indent */)
{
std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl;
return out ;
}
virtual std::ostream &printHex(std::ostream &out, uint16_t indent) /* SPECIAL One */
virtual std::ostream &printHex(std::ostream &out, uint16_t /* indent */) /* SPECIAL One */
{
std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl;
return out ;

View File

@ -154,7 +154,7 @@ int checkOutgoingMessages();
#endif
virtual bool handleTunnelRequest(const Sha1CheckSum& hash,const RsPeerId& peer_id) ;
// virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const Sha1CheckSum& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) {}
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction /* dir */) {}
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) {}
// Utility functions