diff options
Diffstat (limited to 'cpp/src')
28 files changed, 59 insertions, 46 deletions
diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp index b124f1bdb41..dc86b39c1cc 100644 --- a/cpp/src/Glacier2/RouterI.cpp +++ b/cpp/src/Glacier2/RouterI.cpp @@ -37,7 +37,7 @@ Glacier2::RouterI::RouterI(const ObjectAdapterPtr& clientAdapter, const ObjectAd ident.name = "dummy"; ident.category.resize(20); char buf[20]; - IceUtil::generateRandom(buf, sizeof(buf)); + IceUtil::generateRandom(buf, static_cast<int>(sizeof(buf))); for(unsigned int i = 0; i < sizeof(buf); ++i) { const unsigned char c = static_cast<unsigned char>(buf[i]); // A value between 0-255 diff --git a/cpp/src/Ice/GC.cpp b/cpp/src/Ice/GC.cpp index f8334d41e97..19b545ad231 100755 --- a/cpp/src/Ice/GC.cpp +++ b/cpp/src/Ice/GC.cpp @@ -218,10 +218,10 @@ IceInternal::GC::collectGarbage() for(GCObjectSet::const_iterator i = liveObjects.begin(); i != liveObjects.end(); ++i) { #ifndef NDEBUG - bool erased = + size_t erased = #endif counts.erase(*i); - assert(erased); + assert(erased != 0); } } } diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index f341f3b79de..bc917c4299c 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -1315,7 +1315,7 @@ IceInternal::getLocalHosts() // while(true) { - int bufsize = numaddrs * sizeof(struct ifreq); + int bufsize = numaddrs * static_cast<int>(sizeof(struct ifreq)); ifc.ifc_len = bufsize; ifc.ifc_buf = (char*)malloc(bufsize); @@ -1344,7 +1344,7 @@ IceInternal::getLocalHosts() free(ifc.ifc_buf); } - numaddrs = ifc.ifc_len / sizeof(struct ifreq); + numaddrs = ifc.ifc_len / static_cast<int>(sizeof(struct ifreq)); struct ifreq* ifr = ifc.ifc_req; for(int i = 0; i < numaddrs; ++i) { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index 86841af06e3..6ded5007926 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -26,6 +26,8 @@ #include <IceUtil/StringUtil.h> #include <IceUtil/Random.h> +#include <functional> + using namespace std; using namespace Ice; using namespace IceInternal; @@ -33,7 +35,16 @@ using namespace IceInternal; void IceInternal::incRef(IceInternal::Reference* p) { p->__incRef(); } void IceInternal::decRef(IceInternal::Reference* p) { p->__decRef(); } -pointer_to_unary_function<int, int> Reference::_rand(IceUtil::random); +namespace +{ +struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t> +{ + ptrdiff_t operator()(ptrdiff_t d) + { + return IceUtil::random(static_cast<int>(d)); + } +}; +} CommunicatorPtr IceInternal::Reference::getCommunicator() const @@ -652,7 +663,7 @@ IceInternal::FixedReference::filterConnections(const vector<ConnectionIPtr>& all // // Randomize the order of connections. // - random_shuffle(connections.begin(), connections.end(), _rand); + random_shuffle(connections.begin(), connections.end(), RandomNumberGenerator()); // // If a secure connection is requested, remove all non-secure @@ -1054,7 +1065,7 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all { case Random: { - random_shuffle(endpoints.begin(), endpoints.end(), _rand); + random_shuffle(endpoints.begin(), endpoints.end(), RandomNumberGenerator()); break; } case Ordered: diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index c9623a33191..8c9575fcaac 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -119,8 +119,6 @@ protected: mutable Ice::Int _hashValue; mutable bool _hashInitialized; - static std::pointer_to_unary_function<int, int> _rand; - private: const InstancePtr _instance; diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp index 952a58d7686..7a43d8c7d54 100644 --- a/cpp/src/IceGrid/AdapterCache.cpp +++ b/cpp/src/IceGrid/AdapterCache.cpp @@ -16,11 +16,11 @@ #include <IceGrid/NodeCache.h> #include <IceGrid/SessionI.h> +#include <functional> + using namespace std; using namespace IceGrid; -pointer_to_unary_function<int, int> ReplicaGroupEntry::_rand(IceUtil::random); - namespace IceGrid { @@ -365,14 +365,14 @@ ReplicaGroupEntry::getProxies(int& nReplicas, bool& replicaGroup) else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing)) { replicas = _replicas; - random_shuffle(replicas.begin(), replicas.end(), _rand); + random_shuffle(replicas.begin(), replicas.end(), RandomNumberGenerator()); adaptive = true; loadSample = _loadSample; } else// if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing)) { replicas = _replicas; - random_shuffle(replicas.begin(), replicas.end(), _rand); + random_shuffle(replicas.begin(), replicas.end(), RandomNumberGenerator()); } } @@ -439,7 +439,7 @@ ReplicaGroupEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const // This must be done outside the synchronization block since // min_element() will call and lock each server entry. // - random_shuffle(replicas.begin(), replicas.end(), _rand); + random_shuffle(replicas.begin(), replicas.end(), RandomNumberGenerator()); vector<ReplicaLoadComp::ReplicaLoad> rl; transform(replicas.begin(), replicas.end(), back_inserter(rl), ToReplicaLoad(loadSample)); AdapterEntryPtr adpt = min_element(rl.begin(), rl.end(), ReplicaLoadComp())->second.second; diff --git a/cpp/src/IceGrid/AdapterCache.h b/cpp/src/IceGrid/AdapterCache.h index aa17a733f2e..b5fdc7958b2 100644 --- a/cpp/src/IceGrid/AdapterCache.h +++ b/cpp/src/IceGrid/AdapterCache.h @@ -98,8 +98,6 @@ private: LoadSample _loadSample; ReplicaSeq _replicas; int _lastReplica; - - static std::pointer_to_unary_function<int, int> _rand; }; typedef IceUtil::Handle<ReplicaGroupEntry> ReplicaGroupEntryPtr; diff --git a/cpp/src/IceGrid/AllocatableObjectCache.cpp b/cpp/src/IceGrid/AllocatableObjectCache.cpp index b13d8175bb5..f5275da7e43 100644 --- a/cpp/src/IceGrid/AllocatableObjectCache.cpp +++ b/cpp/src/IceGrid/AllocatableObjectCache.cpp @@ -17,8 +17,6 @@ using namespace std; using namespace IceGrid; -pointer_to_unary_function<int, int> AllocatableObjectCache::_rand(IceUtil::random); - namespace IceGrid { @@ -198,7 +196,7 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio } vector<AllocatableObjectEntryPtr> objects = p->second.getObjects(); - random_shuffle(objects.begin(), objects.end(), _rand); // TODO: OPTIMIZE + random_shuffle(objects.begin(), objects.end(), RandomNumberGenerator()); // TODO: OPTIMIZE try { for(vector<AllocatableObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q) diff --git a/cpp/src/IceGrid/AllocatableObjectCache.h b/cpp/src/IceGrid/AllocatableObjectCache.h index 9779314dd54..db5805836df 100644 --- a/cpp/src/IceGrid/AllocatableObjectCache.h +++ b/cpp/src/IceGrid/AllocatableObjectCache.h @@ -111,8 +111,6 @@ private: const Ice::CommunicatorPtr _communicator; std::map<std::string, TypeEntry> _types; std::map<std::string, std::vector<Ice::Identity> > _allocatablesByType; - - static std::pointer_to_unary_function<int, int> _rand; }; }; diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 523d6ec077c..251745fafb2 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -27,7 +27,6 @@ using namespace IceGrid; const string Database::_descriptorDbName = "applications"; const string Database::_adapterDbName = "adapters"; const string Database::_objectDbName = "objects"; -pointer_to_unary_function<int, int> Database::_rand(IceUtil::random); namespace IceGrid { @@ -810,7 +809,7 @@ Database::getAdapters(const string& id, int& endpointCount, bool& replicaGroup) adpts.push_back(make_pair(p->first, adpt)); ++p; } - random_shuffle(adpts.begin(), adpts.end(), _rand); + random_shuffle(adpts.begin(), adpts.end(), RandomNumberGenerator()); replicaGroup = true; endpointCount = static_cast<int>(adpts.size()); return adpts; @@ -1073,7 +1072,7 @@ Ice::ObjectPrx Database::getObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample) { Ice::ObjectProxySeq objs = getObjectsByType(type); - random_shuffle(objs.begin(), objs.end(), _rand); + random_shuffle(objs.begin(), objs.end(), RandomNumberGenerator()); vector<pair<Ice::ObjectPrx, float> > objectsWithLoad; objectsWithLoad.reserve(objs.size()); for(Ice::ObjectProxySeq::const_iterator p = objs.begin(); p != objs.end(); ++p) diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h index 580e74d6a05..49cf5be1cfc 100644 --- a/cpp/src/IceGrid/Database.h +++ b/cpp/src/IceGrid/Database.h @@ -128,8 +128,7 @@ private: static const std::string _objectDbName; static const std::string _adapterDbName; static const std::string _replicaGroupDbName; - static std::pointer_to_unary_function<int, int> _rand; - + const Ice::CommunicatorPtr _communicator; const Ice::ObjectAdapterPtr _internalAdapter; const std::string _envName; diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp index 0c3b45896a5..d6e608f1049 100644 --- a/cpp/src/IceGrid/SessionI.cpp +++ b/cpp/src/IceGrid/SessionI.cpp @@ -55,13 +55,13 @@ private: TPtr _cb; }; -template<class T> static AllocateObject<T>* +template<class T> AllocateObject<T>* newAllocateObject(const SessionIPtr& session, const IceUtil::Handle<T>& cb) { return new AllocateObject<T>(session, cb); } -}; +} BaseSessionI::BaseSessionI(const string& id, const string& prefix, diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h index d2196853427..c7f6ed142a3 100644 --- a/cpp/src/IceGrid/Util.h +++ b/cpp/src/IceGrid/Util.h @@ -13,10 +13,22 @@ #include <IceGrid/Descriptor.h> #include <IceUtil/StringUtil.h> #include <IceGrid/Exception.h> +#include <IceUtil/Random.h> + +#include <functional> namespace IceGrid { +struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t> +{ + ptrdiff_t operator()(ptrdiff_t d) + { + return IceUtil::random(static_cast<int>(d)); + } +}; + + template<typename T> std::insert_iterator<T> inline set_inserter(T& container) { diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp index b16203054fa..d8522353f21 100644 --- a/cpp/src/IcePatch2/Util.cpp +++ b/cpp/src/IcePatch2/Util.cpp @@ -125,7 +125,7 @@ IcePatch2::readFileInfo(FILE* fp, FileInfo& info) { string data; char buf[BUFSIZ]; - while(fgets(buf, sizeof(buf), fp) != 0) + while(fgets(buf, static_cast<int>(sizeof(buf)), fp) != 0) { data += buf; @@ -971,7 +971,7 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G } } - unsigned int bytesLeft = buf.st_size; + unsigned int bytesLeft = static_cast<unsigned int>(buf.st_size); while(bytesLeft > 0) { ByteSeq bytes(min(bytesLeft, 1024u*1024)); diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp index 15e03fbe49b..030f798042a 100755 --- a/cpp/src/IceSSL/Certificate.cpp +++ b/cpp/src/IceSSL/Certificate.cpp @@ -518,7 +518,7 @@ Certificate::getSubjectAlternativeNames() int Certificate::getVersion() const { - return X509_get_version(_cert); + return static_cast<int>(X509_get_version(_cert)); } string diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp index fd3e2b3324d..8e9f97d62a7 100644 --- a/cpp/src/IceSSL/Instance.cpp +++ b/cpp/src/IceSSL/Instance.cpp @@ -786,9 +786,9 @@ IceSSL::Instance::verifyCallback(int ok, SSL* ssl, X509_STORE_CTX* c) Trace out(_logger, _securityTraceCategory); out << "certificate verification failure\n"; - X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)); + X509_NAME_oneline(X509_get_issuer_name(cert), buf, static_cast<int>(sizeof(buf))); out << "issuer = " << buf << '\n'; - X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)); + X509_NAME_oneline(X509_get_subject_name(cert), buf, static_cast<int>(sizeof(buf))); out << "subject = " << buf << '\n'; out << "depth = " << X509_STORE_CTX_get_error_depth(c) << '\n'; out << "error = " << X509_verify_cert_error_string(err) << '\n'; diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp index f2927d35f64..3daec473553 100644 --- a/cpp/src/IceUtil/Random.cpp +++ b/cpp/src/IceUtil/Random.cpp @@ -208,7 +208,7 @@ int IceUtil::random(int limit) { int r; - generateRandom(reinterpret_cast<char*>(&r), sizeof(int)); + generateRandom(reinterpret_cast<char*>(&r), static_cast<int>(sizeof(int))); if(limit > 0) { r = r % limit; diff --git a/cpp/src/IceUtil/UUID.cpp b/cpp/src/IceUtil/UUID.cpp index 0f1c9a905b8..de9618b1c3f 100644 --- a/cpp/src/IceUtil/UUID.cpp +++ b/cpp/src/IceUtil/UUID.cpp @@ -112,7 +112,7 @@ IceUtil::generateUUID() // Randoms by the last 15 bits of the process id. // char* buffer = reinterpret_cast<char*>(&uuid); - generateRandom(buffer, sizeof(UUID)); + generateRandom(buffer, static_cast<int>(sizeof(UUID))); // // Adjust the bits that say "version 4" UUID diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 21567e366fb..7a59173d5e4 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -183,7 +183,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2cppe/Main.cpp b/cpp/src/slice2cppe/Main.cpp index c9261337313..125e72f43ab 100644 --- a/cpp/src/slice2cppe/Main.cpp +++ b/cpp/src/slice2cppe/Main.cpp @@ -174,7 +174,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 63d1d74ad63..4c42f058052 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -171,7 +171,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index a4a79ccd923..cbce4b99090 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -171,7 +171,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 992289e0f14..8c051ecdb55 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -1665,7 +1665,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 8b0467c4708..7efb1e5aeb1 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -1397,7 +1397,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index 7d9f6e853d2..efa0aab8be1 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -185,7 +185,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2javae/Main.cpp b/cpp/src/slice2javae/Main.cpp index c3be420adc5..3cace01643f 100644 --- a/cpp/src/slice2javae/Main.cpp +++ b/cpp/src/slice2javae/Main.cpp @@ -164,7 +164,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 9fe1b0a8974..5b625547355 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -496,7 +496,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { diff --git a/cpp/src/slice2vb/Main.cpp b/cpp/src/slice2vb/Main.cpp index 8c015418e80..60d7591057b 100644 --- a/cpp/src/slice2vb/Main.cpp +++ b/cpp/src/slice2vb/Main.cpp @@ -172,7 +172,7 @@ main(int argc, char* argv[]) if(preprocess) { char buf[4096]; - while(fgets(buf, sizeof(buf), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) { if(fputs(buf, stdout) == EOF) { |