Fix Some gcc warnings 383 to 208 lines

Left explicit #warning and deprecated.
Some lines are wrong indented and produce mal formed code.
This commit is contained in:
Phenom 2016-10-22 23:48:19 +02:00
parent 74aa55e347
commit 674b6de381
63 changed files with 379 additions and 346 deletions

View file

@ -297,13 +297,13 @@ uint32_t RsChatLobbyConnectChallengeItem::serial_size()
}
uint32_t RsChatLobbyBouncingObject::serialized_size(bool include_signature)
{
uint32_t s = 0 ; // no header!
s += 8 ; // lobby_id
s += 8 ; // msg_id
s += GetTlvStringSize(nick) ; // nick
uint32_t s = 0; // no header!
s += 8; // lobby_id
s += 8; // msg_id
s += GetTlvStringSize(nick); // nick
if(include_signature)
s += signature.TlvSize() ; // signature
if (include_signature)
s += signature.TlvSize(); // signature
return s ;
}

View file

@ -755,12 +755,12 @@ bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinary
// serialise directory subfiles, with info for each of them
unsigned char *file_section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE);
unsigned char *file_section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE) ;
if(!file_section_data)
return false ;
uint32_t file_section_size = FL_BASE_TMP_SECTION_SIZE;
uint32_t file_section_size = FL_BASE_TMP_SECTION_SIZE ;
for(uint32_t i=0;i<dir->subfiles.size();++i)
{
@ -865,12 +865,12 @@ bool RemoteDirectoryStorage::deserialiseUpdateDirEntry(const EntryIndex& indx,co
// deserialise directory subfiles, with info for each of them
std::vector<InternalFileHierarchyStorage::FileEntry> subfiles_array ;
unsigned char *file_section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE);
unsigned char *file_section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE) ;
if(!file_section_data)
return false ;
uint32_t file_section_size = FL_BASE_TMP_SECTION_SIZE;
uint32_t file_section_size = FL_BASE_TMP_SECTION_SIZE ;
for(uint32_t i=0;i<n_subfiles;++i)
{

View file

@ -1397,7 +1397,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem *sitem)
if(!item)
return ;
time_t now = time(NULL) ;
time_t now = time(NULL);
// check the hash. If anything goes wrong (in the chunking for instance) the hash will not match

View file

@ -350,7 +350,7 @@ bool ftExtraList::search(const RsFileHash &hash, FileSearchFlags /*hintflags*
// Now setup the file storage flags so that the client can know how to handle permissions
//
#warning make sure this is right
#warning mr-alice: make sure this is right
info.storage_permission_flags = FileStorageFlags(0) ;//DIR_FLAGS_BROWSABLE_OTHERS ;
if(info.transfer_info_flags & RS_FILE_REQ_ANONYMOUS_ROUTING) info.storage_permission_flags |= DIR_FLAGS_ANONYMOUS_DOWNLOAD ;

View file

@ -250,18 +250,19 @@ RsGRouterRoutingInfoItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoI
else
ok = false ;
// receipt item is optional.
// Receipt item is optional.
if (offset < pktsize)
{ //
item->receipt_item = deserialise_RsGRouterSignedReceiptItem(&((uint8_t*)data)[offset],pktsize - offset);
if (item->receipt_item != NULL)
offset += item->receipt_item->serial_size();
else //
ok = false;
}
else //
item->receipt_item = NULL;
if(offset < pktsize)
{
item->receipt_item = deserialise_RsGRouterSignedReceiptItem(&((uint8_t*)data)[offset],pktsize - offset) ;
if(item->receipt_item != NULL)
offset += item->receipt_item->serial_size() ;
else
ok = false ;
}
else
item->receipt_item = NULL ;
if (offset != rssize || !ok)

View file

@ -554,10 +554,10 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
if(!EVP_SealInit(&ctx, EVP_aes_128_cbc(), &ek, &eklen, iv, &public_key, 1)) return false;
// now assign memory to out accounting for data, and cipher block size, key length, and key length val
out = (uint8_t*)rs_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH);
out = (uint8_t*)rs_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH) ;
if(out == NULL)
return false ;
if (out == NULL)
return false;
net_ekl = htonl(eklen);
memcpy((unsigned char*)out + out_offset, &net_ekl, size_net_ekl);

View file

@ -2226,7 +2226,7 @@ void RsGenExchange::processMessageDelete()
}
#warning TODO: notify for deleted messages
#warning csoler: TODO: notify for deleted messages
#ifdef SUSPENDED
std::list<RsGxsGroupId> grpDeleted;
std::map<uint32_t, GrpNote>::iterator mit = toNotify.begin();
@ -2402,7 +2402,7 @@ void RsGenExchange::publishGrps()
{
RsTemporaryMemory metaData(mdSize);
serialOk = grp->metaData->serialise(metaData, mdSize,RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
#warning TODO: grp->meta should be renamed grp->public_meta !
#warning csoler: TODO: grp->meta should be renamed grp->public_meta !
grp->meta.setBinData(metaData, mdSize);
}
@ -2419,7 +2419,7 @@ void RsGenExchange::publishGrps()
mDataAccess->updateGroupData(grp);
else
mDataAccess->addGroupData(grp);
#warning this is bad: addGroupData/updateGroupData actially deletes grp. But it may be used below? grp should be a class object and not deleted manually!
#warning csoler: this is bad: addGroupData/updateGroupData actially deletes grp. But it may be used below? grp should be a class object and not deleted manually!
groups_to_subscribe.push_back(grpId) ;
}

View file

@ -361,8 +361,9 @@ uint32_t RsGxsDataAccess::requestStatus(uint32_t token)
if(mPublicToken.find(token) != mPublicToken.end())
return mPublicToken[token];
}
if(!checkRequestStatus(token, status, reqtype, anstype, ts))
return RsTokenService::GXS_REQUEST_V2_STATUS_FAILED ;
if (!checkRequestStatus(token, status, reqtype, anstype, ts))
return RsTokenService::GXS_REQUEST_V2_STATUS_FAILED;
return status;
}

View file

@ -1641,7 +1641,9 @@ void RsGxsNetService::recvNxsItemQueue()
default:
if(ni->PacketSubType() != RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM)
std::cerr << "Unhandled item subtype " << (uint32_t) ni->PacketSubType() << " in RsGxsNetService: " << std::endl; break;
{
std::cerr << "Unhandled item subtype " << (uint32_t) ni->PacketSubType() << " in RsGxsNetService: " << std::endl ; break ;
}
}
delete item ;
}
@ -3291,8 +3293,8 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr)
if(!grps.empty())
mDataStore->retrieveNxsGrps(grps, false, false);
else
return;
else
return;
NxsTransaction* newTr = new NxsTransaction();
newTr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM;
@ -3304,7 +3306,7 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr)
RsPeerId peerId = tr->mTransaction->PeerId();
for(;mit != grps.end(); ++mit)
{
#warning Should make sure that no private key information is sneaked in here for the grp
#warning csoler: Should make sure that no private key information is sneaked in here for the grp
mit->second->PeerId(peerId); // set so it gets sent to right peer
mit->second->transactionNumber = transN;
newTr->mItems.push_back(mit->second);

View file

@ -276,14 +276,14 @@ uint32_t PGPKeyParser::read_125Size(unsigned char *& data)
uint8_t b1 = *data ;
++data ;
if(b1 < 192) //192 Size is coded with One Char. See RFC4880
if (b1 < 192) //192 Size is coded with One Char. See RFC4880 https://tools.ietf.org/html/rfc4880#section-4.2.2.1
return b1 ;
uint8_t b2 = *data ;
++data ;
if(b1 < 224)//224 = 0xC0+0x20 Size is coded with Two Chars
return ((b1-192) << 8) + b2 + 192 ; // see RFC4880
if (b1 < 224)//224 = 0xC0+0x20 Size is coded with Two Chars
return ( (b1-192) << 8 ) + b2 + 192 ; // see RFC4880
if(b1 != 0xFF)// Else Coded with 4 Chars but first == 0xFF
throw std::runtime_error("GPG parsing error") ;

View file

@ -476,10 +476,10 @@ static int initLib = 0;
mOwnCert = new sslcert(x509, mOwnId);
// new locations don't store the name in the cert
// if empty, use the external supplied value
if(mOwnCert->location == "")
mOwnCert->location = alternative_location_name;
// New locations don't store the name in the cert.
// If empty, use the external supplied value.
if (mOwnCert->location == "")
mOwnCert->location = alternative_location_name ;
std::cerr << "Inited SSL context: " << std::endl;
std::cerr << " Certificate: " << mOwnId << std::endl;

View file

@ -175,16 +175,16 @@ void p3ConfigMgr::addConfiguration(std::string file, pqiConfig *conf)
std::cerr << "\tIgnoring new filename " << filename;
std::cerr << std::endl;
return;
}
// also check that the filename is not already registered for another config
}
// Also check that the filename is not already registered for another config
for(std::list<pqiConfig*>::const_iterator it = mConfigs.begin();it!= mConfigs.end();++it)
if( (*it)->filename == filename )
{
std::cerr << "!!!!!!!!!!! Trying to register a config for file \"" << filename << "\" that is already registered" << std::endl;
std::cerr << "!!!!!!!!!!! Please correct the code !" << std::endl;
return ;
}
for(std::list<pqiConfig*>::const_iterator it = mConfigs.begin(); it!= mConfigs.end(); ++it)
if((*it)->filename == filename)
{
std::cerr << "!!!!!!!!!! Trying to register a config for file \"" << filename << "\" that is already registered" << std::endl;
std::cerr << "!!!!!!!!!! Please correct the code !" << std::endl;
return;
}
conf->setFilename(filename);
mConfigs.push_back(conf);
@ -511,9 +511,8 @@ bool p3GeneralConfig::saveList(bool &cleanup, std::list<RsItem *>& savelist)
if (item->tlvkvs.pairs.size() > 0)
{
savelist.push_back(item);
}
else
delete item;
} else
delete item;
return true;
}

View file

@ -812,7 +812,7 @@ void p3NetMgrIMPL::netExtCheck()
address_votes[tmpip].n++ ;
/* XXX HACK TO FIX */
#warning "ALLOWING ExtAddrFinder -> ExtAddrStableOk = true (which it is not normally)"
#warning drbob: ALLOWING ExtAddrFinder -> ExtAddrStableOk = true (which it is not normally)
mNetFlags.mExtAddrStableOk = true;
std::cerr << "ExtAddrFinder reported external address " << sockaddr_storage_iptostring(tmpip) << std::endl;

View file

@ -2561,7 +2561,7 @@ bool p3PeerMgrIMPL::removeGroup(const RsNodeGroupId& groupId)
std::cerr << "(EE) cannot remove standard group with ID " << groupId << std::endl;
return false ;
}
#warning we need to check that the local group is not used. Otherwise deleting it is going to cause problems!
#warning csoler: we need to check that the local group is not used. Otherwise deleting it is going to cause problems!
// else if(!it->second.used_gxs_groups.empty())
// {
// std::cerr << "(EE) cannot remove standard group with ID " << groupId << " because it is used in the following groups: " << std::endl;
@ -2619,8 +2619,8 @@ bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo>& groupInfoList)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
for (std::map<RsNodeGroupId,RsGroupInfo> ::const_iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
groupInfoList.push_back(groupIt->second);
for(std::map<RsNodeGroupId,RsGroupInfo> ::const_iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
groupInfoList.push_back(groupIt->second) ;
return true;
}
@ -2845,10 +2845,11 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
const time_t now = time(NULL);
std::list<RsPgpId> pgpList;
std::list<RsPgpId> pgpList ;
if (!rsPeers->getGPGAcceptedList(pgpList))
return false ;
if(!rsPeers->getGPGAcceptedList(pgpList))
return false;
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -2881,8 +2882,8 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
}
}
for( std::list<RsPeerId>::iterator it = toRemove.begin(); it != toRemove.end(); ++it)
removeFriend(*it, false);
for (std::list<RsPeerId>::iterator it = toRemove.begin(); it != toRemove.end(); ++it)
removeFriend(*it, false) ;
return true;
}

View file

@ -143,13 +143,13 @@ public:
ok &= getRawUInt32(data, rssize, &offset, &item->mServiceId);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->mServiceName);
uint8_t v ;
uint8_t v;
ok &= getRawUInt8(data, rssize, &offset, &v) ;
if(v != 0 && v != 1)
ok = false ;
else
item->mDefaultAllowed = (bool)v;
if (v != 0 && v != 1)
ok = false;
else
item->mDefaultAllowed = (bool)v ;
uint32_t tmp ;
ok &= getRawUInt32(data, rssize, &offset, &tmp);

View file

@ -578,9 +578,9 @@ int pqiperson::gatherStatistics(std::list<RSTrafficClue>& out_lst,
{
RS_STACK_MUTEX(mPersonMtx);
// get the rate from the active one.
if ((!active) || (activepqi == NULL))
return 0;
// Get the rate from the active one.
if( (!active) || (activepqi == NULL) )
return 0 ;
return activepqi->gatherStatistics(out_lst, in_lst);
}

View file

@ -1624,10 +1624,10 @@ int pqissl::readdata(void *data, int len)
#ifdef PQISSL_DEBUG
std::cout << "Reading data thread=" << pthread_self() << ", ssl=" << (void*)this << std::endl ;
#endif
// safety check. Apparently this avoids some SIGSEGV.
//
if(ssl_connection == NULL)
return -1;
// Safety check. Apparently this avoids some SIGSEGV.
//
if (ssl_connection == NULL)
return -1 ;
// There is a do, because packets can be splitted into multiple ssl buffers
// when they are larger than 16384 bytes. Such packets have to be read in

View file

@ -161,20 +161,19 @@ pqistreamer::~pqistreamer()
if (mRsSerialiser)
delete mRsSerialiser;
free_pend_locked();
free_pend_locked() ;
// clean up incoming.
while(!mIncoming.empty())
while (!mIncoming.empty())
{
RsItem *i = mIncoming.front();
mIncoming.pop_front();
--mIncomingSize ;
mIncoming.pop_front() ;
--mIncomingSize;
delete i;
}
}
if(mIncomingSize != 0)
std::cerr << "(EE) inconsistency after deleting pqistreamer queue. Remaining items: " << mIncomingSize << std::endl;
if (mIncomingSize != 0)
std::cerr << "(EE) inconsistency after deleting pqistreamer queue. Remaining items: " << mIncomingSize << std::endl ;
return;
}

View file

@ -231,7 +231,7 @@ uint32_t getRawStringSize(const std::string &outStr)
bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr)
{
#warning "I had to change this. It seems like a bug to not clear the string. Should make sure it's not introducing any side effect."
#warning Gio: "I had to change this. It seems like a bug to not clear the string. Should make sure it's not introducing any side effect."
outStr.clear();
uint32_t len = 0;

View file

@ -574,8 +574,8 @@ bool RsGxsRecognSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsi
RsItem *RsGxsRecognSerialiser::deserialise(void *data, uint32_t *pktsize)
{
if(*pktsize < getRsPktBaseSize())
return NULL;
if (*pktsize < getRsPktBaseSize())
return NULL ;
/* get the type and size */
uint32_t rstype = getRsItemId(data);

View file

@ -249,8 +249,8 @@ void p3BanList::autoFigureOutBanRanges()
#endif
BanListPeer& peer(mBanRanges[it->first]) ;
if(peer.reason == RSBANLIST_REASON_USER)
continue ;
if (peer.reason == RSBANLIST_REASON_USER)
continue;
peer.addr = it->first ;
peer.masked_bytes = 1 ;
@ -969,10 +969,10 @@ bool p3BanList::addBanEntry(const RsPeerId &peerId, const struct sockaddr_storag
it->second.mLastUpdate = now;
updated = true;
}
}
}
if(updated)
IndicateConfigChanged();
if (updated)
IndicateConfigChanged() ;
return updated;
}
@ -1056,12 +1056,12 @@ int p3BanList::condenseBanSources_locked()
struct sockaddr_storage bannedaddr;
sockaddr_storage_clear(bannedaddr);
bannedaddr.ss_family = AF_INET ;
bannedaddr.ss_family = AF_INET;
sockaddr_storage_copyip(bannedaddr, lit->second.addr);
sockaddr_storage_setport(bannedaddr, 0);
if(isWhiteListed_locked(bannedaddr))
continue ;
if (isWhiteListed_locked(bannedaddr))
continue;
/* check if it exists in the Set already */
std::map<struct sockaddr_storage, BanListPeer>::iterator sit;

View file

@ -1645,8 +1645,8 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{
mis.msgflags = 0;
if (msg->msgFlags & RS_MSG_FLAGS_DISTANT)
mis.msgflags |= RS_MSG_DISTANT;
if(msg->msgFlags & RS_MSG_FLAGS_DISTANT)
mis.msgflags |= RS_MSG_DISTANT ;
if (msg->msgFlags & RS_MSG_FLAGS_SIGNED)
mis.msgflags |= RS_MSG_SIGNED ;

View file

@ -284,22 +284,19 @@ RsTurtleRegExpSearchRequestItem::RsTurtleRegExpSearchRequestItem(void *data,uint
uint32_t n =0 ;
ok &= getRawUInt32(data,pktsize,&offset,&n) ;
if(ok)
expr._tokens.resize(n) ;
if(ok) expr._tokens.resize(n) ;
for(uint32_t i=0;i<n && ok;++i) ok &= getRawUInt8(data,pktsize,&offset,&expr._tokens[i]) ;
ok &= getRawUInt32(data,pktsize,&offset,&n) ;
if(ok)
expr._ints.resize(n) ;
if(ok) expr._ints.resize(n) ;
for(uint32_t i=0;i<n && ok;++i) ok &= getRawUInt32(data,pktsize,&offset,&expr._ints[i]) ;
ok &= getRawUInt32(data,pktsize,&offset,&n) ;
ok &= getRawUInt32(data,pktsize,&offset,&n);
if(ok)
expr._strings.resize(n) ;
if (ok) expr._strings.resize(n);
for(uint32_t i=0;i<n && ok;++i) ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_VALUE, expr._strings[i]);

View file

@ -1304,10 +1304,10 @@ int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*
// Somehow, this is unreliable. UPNP_DISCOVERY_ADVERTISEMENT_ALIVE events
// happen with a wrong cookie and... boom!
// CUPnPControlPoint *upnpCP = static_cast<CUPnPControlPoint *>(Cookie);
CUPnPControlPoint *upnpCP = CUPnPControlPoint::s_CtrlPoint;
CUPnPControlPoint *upnpCP = CUPnPControlPoint::s_CtrlPoint ;
if(upnpCP == NULL)
return 0 ;
if (upnpCP == NULL)
return 0;
//fprintf(stderr, "Callback: %d, Cookie: %p\n", EventType, Cookie);
switch (EventType) {

View file

@ -296,8 +296,8 @@ namespace
const char* desc,
bool mandatory)
: longName_(l),
value_(&v),
valueName_(valueName),
value_(&v),
initialValue_(v),
description_(desc),
mandatory_(mandatory)
@ -310,9 +310,9 @@ namespace
const char* desc,
bool mandatory)
: shortName_(1,s),
valueName_(valueName),
value_(&v),
initialValue_(v),
valueName_(valueName),
description_(desc),
mandatory_(mandatory)
{

View file

@ -113,7 +113,7 @@ bool FolderIterator::updateFileInfo(bool& should_skip)
mFullPath = mFolderName + "/" + mFileName ;
#warning should we take care of symbolic links on windows?
#warning cyril soler: should we take care of symbolic links on windows?
#ifndef WINDOWS_SYS
if( ent->d_type == DT_LNK)
{

View file

@ -483,7 +483,7 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir)
std::string RsDirUtil::removeSymLinks(const std::string& path)
{
#if defined(WINDOWS_SYS) || defined(__APPLE__)
#warning (Mr.Alice): I don't know how to do this on windows/MacOS. See https://msdn.microsoft.com/en-us/library/windows/desktop/hh707084(v=vs.85).aspx
#warning (Mr.Alice): I don't know how to do this on windows/MacOS. See https://msdn.microsoft.com/en-us/library/windows/desktop/hh707084(v=vs.85).aspx'
//if(!S_OK == PathCchCanonicalizeEx(tmp,...) ;
return path ;
#else

View file

@ -327,7 +327,7 @@ bool rsa_sanity_check(RSA *rsa)
}
#warning this code should be using GxsSecurity signature code. Not some own made signature call.
#warning csoler: this code should be using GxsSecurity signature code. Not some own made signature call.
bool RsRecogn::signTag(EVP_PKEY *signKey, RsGxsRecognTagItem *item)
{
@ -375,7 +375,7 @@ bool RsRecogn::signTag(EVP_PKEY *signKey, RsGxsRecognTagItem *item)
return true;
}
#warning this code should be using GxsSecurity signature code. Not some own made signature call.
#warning csoler: this code should be using GxsSecurity signature code. Not some own made signature call.
bool RsRecogn::signSigner(EVP_PKEY *signKey, RsGxsRecognSignerItem *item)
{
@ -432,7 +432,7 @@ bool RsRecogn::signSigner(EVP_PKEY *signKey, RsGxsRecognSignerItem *item)
return true;
}
#warning this code should be using GxsSecurity signature code. Not some own made signature call.
#warning csoler: this code should be using GxsSecurity signature code. Not some own made signature call.
bool RsRecogn::signTagRequest(EVP_PKEY *signKey, RsGxsRecognReqItem *item)
{