diff options
64 files changed, 341 insertions, 243 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index 29af6af4506..6a0bcd683c5 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -41,8 +41,8 @@ Changes since version 1.0.1 thread. Previously, only requests forwarded as batch would be sent from a separate thread. -- Added support for SPARC/Solaris with the Sun C++ 5.4 compiler - (32 bits only). See INSTALL.SOLARIS for details. +- Added support for SPARC/Solaris with the Sun C++ 5.3 and 5.4 compilers + (32 and 64 bit). See INSTALL.SOLARIS for details. - Replaced the Freeze::EvictorPersistenceMode enumeration with the interface Freeze::PersistenceStrategy. diff --git a/cpp/INSTALL.SOLARIS b/cpp/INSTALL.SOLARIS index 26ef616fb4c..3418dc79d29 100644 --- a/cpp/INSTALL.SOLARIS +++ b/cpp/INSTALL.SOLARIS @@ -12,6 +12,12 @@ Solaris 9; on Solaris 8, you need to install patch 112438-01. C++ compiler ------------ +- Sun C++ 5.3 (part of Forte 6 update 2 aka Sun WorkShop 6 update 2) + It is necessary to setup Sun C++ 5.3 to use the shared version of + libCstd, as described in + <F6U2 install base>/SUNWspro/READMEs/c++ C.1.b (line 168). + +or - Sun C++ 5.4 (part of Sun ONE Studio Compiler Collection 7.0 aka Forte Developer 7) @@ -26,28 +32,32 @@ Third-party libraries - bzip2 1.0 -Xerces-C++ can be download from: +bzip2 may already be installed on your system. If not, we recommend to +download it (in binary form) from http://www.sunfreeware.com. +OpenSSL 0.97 can be downloaded (in binary form) from +http://www.sunfreeware.com; or you can download the source from +http://www.openssl.org. + +Xerces-C++ can be downloaded from: http://xml.apache.org/xerces-c And Berkeley DB from: - http://www.sleepycat.com/download -And OpenSSL from: - -http://www.openssl.org -And bzip2 from: - -http://sources.redhat.com/bzip2 +GNU Make 3.80 +------------- +GNU Make 3.80 is required to build Ice on SPARC/Solaris. +You can download GNU Make from http://www.sunfreeware.com. Python 2.2 ---------- To run the automated test suite, you will need Python 2.2. If you have no interest in running the test scripts, Python is not required. +You can download Python from http://www.sunfreeware.com. ====================================================================== @@ -70,13 +80,13 @@ and /usr/include. Now you're ready to build Ice: -$ make +$ gmake This will build the Ice core library, all add-ons, all tests, and all examples. After a successful build, you can run the test suite, provided that you installed Python: -$ make test +$ gmake test This is equivalent to: @@ -86,17 +96,31 @@ If everything worked out, you should see lots of "ok". In case of a failure, the tests abort with "failed". If you want to try out any of the demos, make sure to add "bin" to -PATH and "lib" to LD_LIBRARY_PATH: +PATH and "lib" to LD_LIBRARY_PATH or LD_LIBRARY_PATH_64 (for 64 bit +builds): $ export PATH=`pwd`/bin:$PATH -$ export LD_LIBRARY_PATH=`pwd`/bin:$LD_LIBRARY_PATH +$ export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH +$ export LD_LIBRARY_PATH_64=`pwd`/lib:$LD_LIBRARY_PATH_64 + +====================================================================== +64 bit builds +====================================================================== + +To build Ice in 64 bit mode, you need to: + - Obtain or build all the third party dependencies, and put the 64 bit + libraries in the "lib/sparcv9" directories. For example put + Berkeley DB 64 bit libraries in $DB_HOME/lib/sparcv9. + - Set the environment variable LP64 to yes, e.g.: + $ export LP64=yes + - Build and test as described above. ====================================================================== Installation ====================================================================== -Simply run "make install". This will install Ice in the "prefix" +Simply run "gmake install". This will install Ice in the "prefix" directory specified in the file Make.rules. After installation, make sure that the <prefix>/bin directory is in @@ -105,3 +129,8 @@ LD_LIBRARY_PATH. When compiling Ice programs, you must also make sure to pass the location of the <prefix>/include directory to the compiler with the -I option, and the location of the <prefix>/lib directory with the -L option. + +If you built in 64 bit mode, the libraries are installed in +<prefix>/lib/sparcv9 and the programs are installed in +<prefix>/bin/sparcv9. Other files are identical for 32 and 64 bit. +
\ No newline at end of file diff --git a/cpp/Makefile b/cpp/Makefile index 157ef496ecf..ead8cfd553a 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -29,14 +29,14 @@ install:: @if test ! -d $(install_bindir) ; \ then \ echo "Creating $(install_bindir)..." ; \ - mkdir $(install_bindir) ; \ + mkdir -p $(install_bindir) ; \ chmod a+rx $(install_bindir) ; \ fi @if test ! -d $(install_libdir) ; \ then \ echo "Creating $(install_libdir)..." ; \ - mkdir $(install_libdir) ; \ + mkdir -p $(install_libdir) ; \ chmod a+rx $(install_libdir) ; \ fi diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index c6b4bcd4b7c..ffd1a010440 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -106,10 +106,15 @@ bindir = $(top_srcdir)/bin libdir = $(top_srcdir)/lib includedir = $(top_srcdir)/include slicedir = $(top_srcdir)/slice -export LD_LIBRARY_PATH := $(libdir):$(LD_LIBRARY_PATH) -install_bindir = $(prefix)/bin -install_libdir = $(prefix)/lib +ifeq ($(LP64),yes) + install_bindir = $(prefix)/bin/$(lp64dir) + install_libdir = $(prefix)/lib/$(lp64dir) +else + install_bindir = $(prefix)/bin + install_libdir = $(prefix)/lib +endif + install_includedir = $(prefix)/include install_slicedir = $(prefix)/slice install_schemadir = $(prefix)/schema @@ -127,13 +132,18 @@ UNAME := $(shell uname) # include $(top_srcdir)/config/Make.rules.$(UNAME) +ifeq ($(LP64),yes) + libsubdir := lib/$(lp64dir) +else + libsubdir := lib +endif ifneq ($(STLPORT_HOME),) STLPORT_FLAGS = -I$(STLPORT_HOME)/include/stlport ifeq ($(OPTIMIZE),yes) - STLPORT_LIBS = -L$(STLPORT_HOME)/lib -lstlport_gcc + STLPORT_LIBS = -L$(STLPORT_HOME)/$(libsubdir) -lstlport_gcc else - STLPORT_LIBS = -L$(STLPORT_HOME)/lib -lstlport_gcc_stldebug + STLPORT_LIBS = -L$(STLPORT_HOME)/$(libsubdir) -lstlport_gcc_stldebug endif else STLPORT_FLAGS = @@ -142,7 +152,7 @@ endif ifneq ($(OPENSSL_HOME),) OPENSSL_FLAGS = -I$(OPENSSL_HOME)/include - OPENSSL_LIBS = -L$(OPENSSL_HOME)/lib -lssl -lcrypto + OPENSSL_LIBS = -L$(OPENSSL_HOME)/$(libsubdir) -lssl -lcrypto else OPENSSL_FLAGS = OPENSSL_LIBS = -lssl -lcrypto @@ -154,7 +164,7 @@ endif ifneq ($(DB_HOME),) DB_FLAGS = -I$(DB_HOME)/include - DB_LIBS = -L$(DB_HOME)/lib -ldb + DB_LIBS = -L$(DB_HOME)/$(libsubdir) -ldb else DB_FLAGS = DB_LIBS = -ldb @@ -162,7 +172,7 @@ endif ifneq ($(XERCESC_HOME),) XERCESC_FLAGS = -I$(XERCESC_HOME)/include - XERCESC_LIBS = -L$(XERCESC_HOME)/lib -lxerces-c + XERCESC_LIBS = -L$(XERCESC_HOME)/$(libsubdir) -lxerces-c else XERCESC_FLAGS = XERCESC_LIBS = -lxerces-c @@ -172,7 +182,7 @@ ifeq ($(PLATFORM_HAS_READLINE),yes) ifeq ($(USE_READLINE),yes) ifneq ($(READLINE_HOME),) READLINE_FLAGS = -DHAVE_READLINE -I$(READLINE_HOME)/include - READLINE_LIBS = -L$(READLINE_HOME)/lib -lreadline -lncurses + READLINE_LIBS = -L$(READLINE_HOME)/$(libsubdir) -lreadline -lncurses else READLINE_FLAGS = -DHAVE_READLINE READLINE_LIBS = -lreadline -lncurses @@ -185,8 +195,20 @@ CPPFLAGS = -I$(includedir) $(STLPORT_FLAGS) ICECPPFLAGS = -I$(slicedir) SLICE2CPPFLAGS = $(ICECPPFLAGS) -LDFLAGS = -L$(libdir) +LDFLAGS = $(CXXFLAGS) -L$(libdir) +ifeq ($(FLEX_NOLINE),yes) + FLEXFLAGS := -L +else + FLEXFLAGS := +endif + +ifeq ($(BISON_NOLINE),yes) + BISONFLAGS := -dvtl +else + BISONFLAGS := -dvt +endif + SLICE2CPP = $(bindir)/slice2cpp SLICE2XSD = $(bindir)/slice2xsd @@ -225,13 +247,13 @@ $(HDIR)/%.h %.cpp: $(SDIR)/%.ice $(SLICE2CPP) %.h %.cpp: %.y rm -f $(*F).h $(*F).cpp - bison -dvt $< + bison $(BISONFLAGS) $< mv $(*F).tab.c $(*F).cpp mv $(*F).tab.h $(*F).h rm -f $(*F).output %.cpp: %.l - flex $< + flex $(FLEXFLAGS) $< rm -f $@ echo '#include <IceUtil/Config.h>' > $@ cat lex.yy.c >> $@ diff --git a/cpp/config/Make.rules.Linux b/cpp/config/Make.rules.Linux index ce127a75e56..d9c80ed3607 100644 --- a/cpp/config/Make.rules.Linux +++ b/cpp/config/Make.rules.Linux @@ -35,3 +35,5 @@ LIBS = -lIce -ldl -lbz2 $(BASELIBS) ICEUTIL_OS_LIBS = -lpthread PLATFORM_HAS_READLINE := yes + +export LD_LIBRARY_PATH := $(libdir):$(LD_LIBRARY_PATH) diff --git a/cpp/config/Make.rules.SunOS b/cpp/config/Make.rules.SunOS index f9ed5db8f0b..f4aba0a3690 100644 --- a/cpp/config/Make.rules.SunOS +++ b/cpp/config/Make.rules.SunOS @@ -16,15 +16,29 @@ # This file is included by Make.rules when uname is SunOS. # -CXX = CC -CXXFLAGS = -KPIC -mt +w +p +CXX := CC + +# +# Which version of CC are we using? +# +CCVERSION := $(filter 5.%, $(shell CC -V 2>&1)) ifeq ($(LP64),yes) - CXXFLAGS = -xarch=v9 $(CXXFLAGS) + CXXARCHFLAGS := -xarch=v9 endif +ifeq ($(CCVERSION),5.3) + CXXWARNFLAGS := + FLEX_NOLINE := yes + BISON_NOLINE := yes +else + CXXWARNFLAGS := +w +endif + +CXXFLAGS = -KPIC -mt +p $(CXXWARNFLAGS) $(CXXARCHFLAGS) + -TEMPLATE_REPOSITORY = SunWS_cache +TEMPLATE_REPOSITORY := SunWS_cache ifeq ($(OPTIMIZE),yes) CXXFLAGS := -O -DNDEBUG $(CXXFLAGS) @@ -34,10 +48,19 @@ endif SHLIB_LDFLAGS = -G -h $(@F) -LIBEXT = so +LIBEXT := so BASELIBS = -lIceUtil $(STLPORT_LIBS) -lpthread LIBS = -lIce -lbz2 $(BASELIBS) -ldl -ICEUTIL_OS_LIBS = -lpthread -lrt -ICE_OS_LIBS = -lsocket
\ No newline at end of file +ICEUTIL_OS_LIBS := -lpthread -lrt +ICE_OS_LIBS := -lsocket + + +lp64dir := sparcv9 + +ifeq ($(LP64),yes) + export LD_LIBRARY_PATH_64 := $(libdir):$(LD_LIBRARY_PATH_64) +else + export LD_LIBRARY_PATH := $(libdir):$(LD_LIBRARY_PATH) +endif diff --git a/cpp/config/TestUtil.py b/cpp/config/TestUtil.py index d22ca9b32e7..1d509d58f79 100644 --- a/cpp/config/TestUtil.py +++ b/cpp/config/TestUtil.py @@ -141,6 +141,7 @@ if isWin32(): os.environ["PATH"] = os.path.join(toplevel, "bin") + ";" + os.getenv("PATH", "") else: os.environ["LD_LIBRARY_PATH"] = os.path.join(toplevel, "lib") + ":" + os.getenv("LD_LIBRARY_PATH", "") + os.environ["LD_LIBRARY_PATH_64"] = os.path.join(toplevel, "lib") + ":" + os.getenv("LD_LIBRARY_PATH_64", "") if protocol == "ssl": plugin = " --Ice.Plugin.IceSSL=IceSSL:create" diff --git a/cpp/demo/Freeze/library/Parser.cpp b/cpp/demo/Freeze/library/Parser.cpp index 5a8b84f291e..fd06a2a77fb 100644 --- a/cpp/demo/Freeze/library/Parser.cpp +++ b/cpp/demo/Freeze/library/Parser.cpp @@ -421,7 +421,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } } - result = line.length(); + result = static_cast<int>(line.length()); if(result > maxSize) { error("input line too long"); @@ -437,7 +437,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } else { - if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = static_cast<int>(fread(buf, 1, maxSize, yyin))) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; diff --git a/cpp/demo/Freeze/library/Scanner.l b/cpp/demo/Freeze/library/Scanner.l index bb8bec0d7d8..581208e1a6e 100644 --- a/cpp/demo/Freeze/library/Scanner.l +++ b/cpp/demo/Freeze/library/Scanner.l @@ -124,8 +124,8 @@ NL [\n] } {WS}*(\\{WS}*{NL})? { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\\') { @@ -139,8 +139,8 @@ NL [\n] } {NL}|; { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\n') { diff --git a/cpp/demo/Freeze/phonebook/Parser.cpp b/cpp/demo/Freeze/phonebook/Parser.cpp index 2990a996ada..b36b5426569 100644 --- a/cpp/demo/Freeze/phonebook/Parser.cpp +++ b/cpp/demo/Freeze/phonebook/Parser.cpp @@ -396,7 +396,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } } - result = line.length(); + result = static_cast<int>(line.length()); if(result > maxSize) { error("input line too long"); @@ -412,7 +412,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } else { - if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = static_cast<int>(fread(buf, 1, maxSize, yyin))) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; diff --git a/cpp/demo/Freeze/phonebook/Scanner.l b/cpp/demo/Freeze/phonebook/Scanner.l index 6200a68471d..30295590e54 100644 --- a/cpp/demo/Freeze/phonebook/Scanner.l +++ b/cpp/demo/Freeze/phonebook/Scanner.l @@ -124,8 +124,8 @@ NL [\n] } {WS}*(\\{WS}*{NL})? { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\\') { @@ -139,8 +139,8 @@ NL [\n] } {NL}|; { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\n') { diff --git a/cpp/include/Freeze/Application.h b/cpp/include/Freeze/Application.h index 0db2ee5bfdd..279ccf1ad92 100644 --- a/cpp/include/Freeze/Application.h +++ b/cpp/include/Freeze/Application.h @@ -37,6 +37,6 @@ private: const std::string _dbEnvName; }; -}; +} #endif diff --git a/cpp/include/Ice/RoutingTable.h b/cpp/include/Ice/RoutingTable.h index ce5ef69f6d9..b4b82a62c06 100644 --- a/cpp/include/Ice/RoutingTable.h +++ b/cpp/include/Ice/RoutingTable.h @@ -26,7 +26,7 @@ namespace Ice struct Identity; -}; +} namespace IceInternal { diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index 75490ce00ec..862ec6723e4 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -526,7 +526,7 @@ DBCursorI::set(const Value& value) memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); dbData.data = const_cast<void*>(static_cast<const void*>(&value[0])); - dbData.size = value.size(); + dbData.size = (unsigned int) value.size(); if(_trace >= 1) { @@ -1036,7 +1036,7 @@ Freeze::DBI::getCursorAtKeyImpl(::DB_TXN* txn, const Key& key) dbData.flags = DB_DBT_PARTIAL; dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); - dbKey.size = key.size(); + dbKey.size = (unsigned int) key.size(); try { checkBerkeleyDBReturn(cursor->c_get(cursor, &dbKey, &dbData, DB_SET), _errorPrefix, "DBcursor->c_get"); @@ -1071,9 +1071,9 @@ Freeze::DBI::putImpl(::DB_TXN* txn, const Key& key, const Value& value) memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); - dbKey.size = key.size(); + dbKey.size = (unsigned int) key.size(); dbData.data = const_cast<void*>(static_cast<const void*>(&value[0])); - dbData.size = value.size(); + dbData.size = (unsigned int) value.size(); if(_trace >= 1) { @@ -1101,7 +1101,7 @@ Freeze::DBI::containsImpl(::DB_TXN* txn, const Key& key) DBT dbKey; memset(&dbKey, 0, sizeof(dbKey)); dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); - dbKey.size = key.size(); + dbKey.size = (unsigned int) key.size(); DBT dbData; memset(&dbData, 0, sizeof(dbData)); @@ -1141,7 +1141,7 @@ Freeze::DBI::getImpl(::DB_TXN* txn, const Key& key) memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); - dbKey.size = key.size(); + dbKey.size = (unsigned int) key.size(); if(_trace >= 1) { @@ -1171,7 +1171,7 @@ Freeze::DBI::delImpl(::DB_TXN* txn, const Key& key) DBT dbKey; memset(&dbKey, 0, sizeof(dbKey)); dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); - dbKey.size = key.size(); + dbKey.size = (unsigned int) key.size(); if(_trace >= 1) { diff --git a/cpp/src/Glacier/Makefile b/cpp/src/Glacier/Makefile index 8570ca5de30..4779f0bcf96 100644 --- a/cpp/src/Glacier/Makefile +++ b/cpp/src/Glacier/Makefile @@ -66,7 +66,7 @@ $(ROUTER): $(ROBJS) $(NAME) $(STARTER): $(SOBJS) $(NAME) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(SOBJS) -lGlacier -lIceSSL $(LIBS) $(OPENSSL_LIBS) -lcrypt + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) -lGlacier -lIceSSL -lcrypt $(OPENSSL_LIBS) $(LIBS) install:: all $(INSTALL_LIBRARY) $(VERSIONED_NAME) $(install_libdir) diff --git a/cpp/src/Glacier/Request.h b/cpp/src/Glacier/Request.h index 9ad965a1a96..f8485fd6f06 100644 --- a/cpp/src/Glacier/Request.h +++ b/cpp/src/Glacier/Request.h @@ -77,7 +77,7 @@ private: bool _destroy; }; -}; +} #endif diff --git a/cpp/src/Glacier/StarterI.cpp b/cpp/src/Glacier/StarterI.cpp index f3dcaae308e..ac52b9dbf24 100644 --- a/cpp/src/Glacier/StarterI.cpp +++ b/cpp/src/Glacier/StarterI.cpp @@ -57,7 +57,7 @@ Glacier::StarterI::StarterI(const CommunicatorPtr& communicator, const PasswordV Int bitStrength = _properties->getPropertyAsIntWithDefault( "Glacier.Starter.Certificate.BitStrength", 1024); Int secondsValid = _properties->getPropertyAsIntWithDefault( - "Glacier.Starter.Certificate.SecondsValid", IceSSL::RSACertificateGenContext::daysToSeconds(1)); + "Glacier.Starter.Certificate.SecondsValid", static_cast<Int>(IceSSL::RSACertificateGenContext::daysToSeconds(1))); Int issuedAdjust = _properties->getPropertyAsIntWithDefault("Glacier.Starter.Certificate.IssuedAdjust", 0); _certContext.setCountry(country); @@ -288,7 +288,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt // // Convert to standard argc/argv. // - int argc = args.size() + 1; + int argc = static_cast<int>(args.size()) + 1; char** argv = static_cast<char**>(malloc((argc + 1) * sizeof(char*))); StringSeq::iterator p; int i; diff --git a/cpp/src/Ice/Acceptor.h b/cpp/src/Ice/Acceptor.h index 3da8d56abc4..a752cfbec57 100644 --- a/cpp/src/Ice/Acceptor.h +++ b/cpp/src/Ice/Acceptor.h @@ -19,7 +19,9 @@ #include <Ice/AcceptorF.h> #include <Ice/TransceiverF.h> -#ifndef _WIN32 +#ifdef _WIN32 +typedef int ssize_t; +#else # define SOCKET int #endif diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 4f3414ac270..324b2795cc1 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -77,14 +77,14 @@ IceInternal::BasicStream::swap(BasicStream& other) } void inline -inlineResize(Buffer* buffer, int total) +inlineResize(Buffer* buffer, size_t total) { if(total > 1024 * 1024) // TODO: configurable { throw MemoryLimitException(__FILE__, __LINE__); } - int capacity = buffer->b.capacity(); + size_t capacity = buffer->b.capacity(); if(capacity < total) { buffer->b.reserve(max(total, 2 * capacity)); @@ -125,7 +125,7 @@ void IceInternal::BasicStream::endWriteEncaps() { assert(_currentWriteEncaps); - int start = _currentWriteEncaps->start; + Container::size_type start = _currentWriteEncaps->start; _writeEncapsStack.pop_back(); if(_writeEncapsStack.empty()) { @@ -135,7 +135,7 @@ IceInternal::BasicStream::endWriteEncaps() { _currentWriteEncaps = &_writeEncapsStack.back(); } - Int sz = b.size() - start + sizeof(Int) + 2; // Size includes size and version + Int sz = static_cast<Int>(b.size() - start + sizeof(Int) + 2); // Size includes size and version const Byte* p = reinterpret_cast<const Byte*>(&sz); #ifdef ICE_BIG_ENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int) - 2); // - 2 for major and minor version byte @@ -202,7 +202,7 @@ void IceInternal::BasicStream::skipReadEncaps() { assert(_currentReadEncaps); - int start = _currentReadEncaps->start; + Container::size_type start = _currentReadEncaps->start; _readEncapsStack.pop_back(); if(_readEncapsStack.empty()) { @@ -230,7 +230,7 @@ void IceInternal::BasicStream::checkReadEncaps() { assert(_currentReadEncaps); - int start = _currentReadEncaps->start; + Container::size_type start = _currentReadEncaps->start; Container::iterator save = i; i = b.begin() + start - sizeof(Int) - 2; // - 2 for major and minor version byte Int sz; @@ -250,7 +250,7 @@ Int IceInternal::BasicStream::getReadEncapsSize() { assert(_currentReadEncaps); - int start = _currentReadEncaps->start; + Container::size_type start = _currentReadEncaps->start; Container::iterator save = i; i = b.begin() + start - sizeof(Int) - 2; // - 2 for major and minor version byte Int sz; @@ -260,7 +260,7 @@ IceInternal::BasicStream::getReadEncapsSize() throw NegativeSizeException(__FILE__, __LINE__); } i = save; - return sz - sizeof(Int) - 2; + return static_cast<Int>(sz - sizeof(Int) - 2); } void @@ -315,7 +315,7 @@ IceInternal::BasicStream::readSize(Ice::Int& v) void IceInternal::BasicStream::writeBlob(const vector<Byte>& v) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + v.size()); ice_copy(v.begin(), v.end(), b.begin() + pos); } @@ -336,7 +336,7 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz) void IceInternal::BasicStream::writeBlob(const Ice::Byte* v, size_t len) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + len); ice_copy(&v[0], &v[0 + len], b.begin() + pos); } @@ -356,9 +356,9 @@ IceInternal::BasicStream::readBlob(Ice::Byte* v, size_t len) void IceInternal::BasicStream::write(const vector<Byte>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz); ice_copy(v.begin(), v.end(), b.begin() + pos); } @@ -391,9 +391,9 @@ IceInternal::BasicStream::read(vector<Byte>& v) void IceInternal::BasicStream::write(const vector<bool>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz); ice_copy(v.begin(), v.end(), b.begin() + pos); } @@ -426,7 +426,7 @@ IceInternal::BasicStream::read(vector<bool>& v) void IceInternal::BasicStream::write(Short v) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sizeof(Short)); const Byte* p = reinterpret_cast<const Byte*>(&v); #ifdef ICE_BIG_ENDIAN @@ -439,11 +439,11 @@ IceInternal::BasicStream::write(Short v) void IceInternal::BasicStream::write(const vector<Short>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); if(sz > 0) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz * sizeof(Short)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_BIG_ENDIAN @@ -505,7 +505,7 @@ IceInternal::BasicStream::read(vector<Short>& v) void IceInternal::BasicStream::write(Int v) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sizeof(Int)); const Byte* p = reinterpret_cast<const Byte*>(&v); #ifdef ICE_BIG_ENDIAN @@ -518,11 +518,11 @@ IceInternal::BasicStream::write(Int v) void IceInternal::BasicStream::write(const vector<Int>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); if(sz > 0) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz * sizeof(Int)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_BIG_ENDIAN @@ -584,7 +584,7 @@ IceInternal::BasicStream::read(vector<Int>& v) void IceInternal::BasicStream::write(Long v) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sizeof(Long)); const Byte* p = reinterpret_cast<const Byte*>(&v); #ifdef ICE_BIG_ENDIAN @@ -597,11 +597,11 @@ IceInternal::BasicStream::write(Long v) void IceInternal::BasicStream::write(const vector<Long>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); if(sz > 0) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz * sizeof(Long)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_BIG_ENDIAN @@ -663,7 +663,7 @@ IceInternal::BasicStream::read(vector<Long>& v) void IceInternal::BasicStream::write(Float v) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sizeof(Float)); const Byte* p = reinterpret_cast<const Byte*>(&v); #ifdef ICE_BIG_ENDIAN @@ -676,11 +676,11 @@ IceInternal::BasicStream::write(Float v) void IceInternal::BasicStream::write(const vector<Float>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); if(sz > 0) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz * sizeof(Float)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_BIG_ENDIAN @@ -742,7 +742,7 @@ IceInternal::BasicStream::read(vector<Float>& v) void IceInternal::BasicStream::write(Double v) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sizeof(Double)); const Byte* p = reinterpret_cast<const Byte*>(&v); #ifdef ICE_BIG_ENDIAN @@ -755,11 +755,11 @@ IceInternal::BasicStream::write(Double v) void IceInternal::BasicStream::write(const vector<Double>& v) { - Int sz = v.size(); + Int sz = static_cast<Int>(v.size()); writeSize(sz); if(sz > 0) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + sz * sizeof(Double)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_BIG_ENDIAN @@ -821,11 +821,11 @@ IceInternal::BasicStream::read(vector<Double>& v) void IceInternal::BasicStream::write(const string& v) { - Int len = v.size(); + Int len = static_cast<Int>(v.size()); writeSize(len); if(len > 0) { - int pos = b.size(); + size_t pos = b.size(); inlineResize(this, pos + len); ice_copy(v.begin(), v.end(), b.begin() + pos); } @@ -910,7 +910,7 @@ IceInternal::BasicStream::write(const ObjectPtr& v) if(v) { - Int num = _currentWriteEncaps->objectsWritten.size(); + Int num = static_cast<Int>(_currentWriteEncaps->objectsWritten.size()); _currentWriteEncaps->objectsWritten[v.get()] = num; write(v->ice_id()); v->__write(this); @@ -1021,7 +1021,7 @@ IceInternal::BasicStream::throwException(const string* throwsBegin, const string pair<const string*, const string*> p = equal_range(throwsBegin, throwsEnd, id); if(p.first != p.second) { - return p.first - throwsBegin; + return static_cast<Int>(p.first - throwsBegin); } NoUserExceptionFactoryException ex(__FILE__, __LINE__); diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 919f9d5a570..30fa07e37cc 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -219,7 +219,7 @@ IceInternal::Connection::validate() assert(is.i - is.b.begin() >= headerSize); is.i = is.b.begin(); MagicBytes m(sizeof(magic), 0); - is.readBlob(m, sizeof(magic)); + is.readBlob(m, static_cast<Int>(sizeof(magic))); if(!equal(m.begin(), m.end(), magic)) { BadMagicException ex(__FILE__, __LINE__); @@ -435,7 +435,7 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway) // No compression, just fill in the message size. // const Byte* p; - Int sz = os->b.size(); + Int sz = static_cast<Int>(os->b.size()); p = reinterpret_cast<const Byte*>(&sz); #ifdef ICE_BIG_ENDIAN reverse_copy(p, p + sizeof(Int), os->b.begin() + 10); @@ -543,7 +543,7 @@ IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out) // // No compression, just fill in the message size. // - Int sz = os->b.size(); + Int sz = static_cast<Int>(os->b.size()); p = reinterpret_cast<const Byte*>(&sz); #ifdef ICE_BIG_ENDIAN reverse_copy(p, p + sizeof(Int), os->b.begin() + 10); @@ -700,7 +700,7 @@ IceInternal::Connection::flushBatchRequest() // // No compression, just fill in the message size. // - Int sz = _batchStream.b.size(); + Int sz = static_cast<Int>(_batchStream.b.size()); p = reinterpret_cast<const Byte*>(&sz); #ifdef ICE_BIG_ENDIAN @@ -792,7 +792,7 @@ IceInternal::Connection::sendResponse(BasicStream* os, Byte compressFlag) // No compression, just fill in the message size. // const Byte* p; - Int sz = os->b.size(); + Int sz = static_cast<Int>(os->b.size()); p = reinterpret_cast<const Byte*>(&sz); #ifdef ICE_BIG_ENDIAN @@ -960,7 +960,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa stream.i = stream.b.begin(); MagicBytes m(sizeof(magic), 0); - stream.readBlob(m, sizeof(magic)); + stream.readBlob(m, static_cast<Int>(sizeof(magic))); if(!equal(m.begin(), m.end(), magic)) { BadMagicException ex(__FILE__, __LINE__); @@ -1674,8 +1674,8 @@ IceInternal::Connection::doCompress(BasicStream& uncompressed, BasicStream& comp // // Compress the message body, but not the header. // - unsigned int uncompressedLen = uncompressed.b.size() - headerSize; - unsigned int compressedLen = static_cast<int>(uncompressedLen * 1.01 + 600); + unsigned int uncompressedLen = static_cast<unsigned int>(uncompressed.b.size() - headerSize); + unsigned int compressedLen = static_cast<unsigned int>(uncompressedLen * 1.01 + 600); compressed.b.resize(headerSize + sizeof(Int) + compressedLen); int bzError = BZ2_bzBuffToBuffCompress(&compressed.b[0] + headerSize + sizeof(Int), &compressedLen, &uncompressed.b[0] + headerSize, uncompressedLen, @@ -1693,7 +1693,7 @@ IceInternal::Connection::doCompress(BasicStream& uncompressed, BasicStream& comp // uncompressed stream. Since the header will be copied, this size // will also be in the header of the compressed stream. // - Int compressedSize = compressed.b.size(); + Int compressedSize = static_cast<Int>(compressed.b.size()); p = reinterpret_cast<const Byte*>(&compressedSize); #ifdef ICE_BIG_ENDIAN @@ -1705,7 +1705,7 @@ IceInternal::Connection::doCompress(BasicStream& uncompressed, BasicStream& comp // Add the size of the uncompressed stream before the message body // of the compressed stream. // - Int uncompressedSize = uncompressed.b.size(); + Int uncompressedSize = static_cast<Int>(uncompressed.b.size()); p = reinterpret_cast<const Byte*>(&uncompressedSize); #ifdef ICE_BIG_ENDIAN @@ -1733,7 +1733,7 @@ IceInternal::Connection::doUncompress(BasicStream& compressed, BasicStream& unco uncompressed.resize(uncompressedSize); unsigned int uncompressedLen = uncompressedSize - headerSize; - unsigned int compressedLen = compressed.b.size() - headerSize - sizeof(Int); + unsigned int compressedLen = static_cast<unsigned int>(compressed.b.size() - headerSize - sizeof(Int)); int bzError = BZ2_bzBuffToBuffDecompress(&uncompressed.b[0] + headerSize, &uncompressedLen, &compressed.b[0] + headerSize + sizeof(Int), diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index d99564a7a72..9ad9cff4fde 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -388,7 +388,9 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, if(_globalStateCounter == 1) // Only on first call { - srand(static_cast<timeval>(IceUtil::Time::now()).tv_usec); + unsigned int seed = + static_cast<unsigned int>(IceUtil::Time::now().toMicroSeconds()); + srand(seed); if(_properties->getPropertyAsInt("Ice.NullHandleAbort") > 0) { diff --git a/cpp/src/Ice/LocalObject.cpp b/cpp/src/Ice/LocalObject.cpp index 39eb86ac9ec..b4ba1c0bc4c 100644 --- a/cpp/src/Ice/LocalObject.cpp +++ b/cpp/src/Ice/LocalObject.cpp @@ -42,5 +42,5 @@ Ice::LocalObject::operator<(const LocalObject& r) const Int Ice::LocalObject::ice_hash() const { - return reinterpret_cast<Int>(this) >> 4; + return static_cast<Int>(reinterpret_cast<Long>(this) >> 4); } diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index acee6758900..fbd895675d4 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -296,7 +296,7 @@ void IceInternal::setTcpNoDelay(SOCKET fd) { int flag = 1; - if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -309,7 +309,7 @@ void IceInternal::setKeepAlive(SOCKET fd) { int flag = 1; - if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&flag, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -321,7 +321,7 @@ IceInternal::setKeepAlive(SOCKET fd) void IceInternal::setSendBufferSize(SOCKET fd, int sz) { - if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, int(sizeof(int))) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -333,7 +333,7 @@ IceInternal::setSendBufferSize(SOCKET fd, int sz) void IceInternal::setRecvBufferSize(SOCKET fd, int sz) { - if(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, int(sizeof(int))) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -347,7 +347,7 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr) { #ifndef _WIN32 int flag = 1; - if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -356,7 +356,7 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr) } #endif - if(bind(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) + if(bind(fd, reinterpret_cast<struct sockaddr*>(&addr), int(sizeof(addr))) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -364,7 +364,7 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr) throw ex; } - socklen_t len = sizeof(addr); + socklen_t len = static_cast<socklen_t>(sizeof(addr)); #ifdef NDEBUG getsockname(fd, reinterpret_cast<struct sockaddr*>(&addr), &len); #else @@ -403,7 +403,7 @@ IceInternal::doConnect(SOCKET fd, struct sockaddr_in& addr, int timeout) #endif repeatConnect: - if(::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) + if(::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), int(sizeof(addr))) == SOCKET_ERROR) { if(interrupted()) { @@ -471,7 +471,7 @@ repeatConnect: // Sleep(0); #endif - socklen_t len = sizeof(socklen_t); + socklen_t len = static_cast<socklen_t>(sizeof(socklen_t)); int val; if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR) { @@ -1020,7 +1020,7 @@ IceInternal::fdToString(SOCKET fd) return "<closed>"; } - socklen_t localLen = sizeof(struct sockaddr_in); + socklen_t localLen = static_cast<socklen_t>(sizeof(struct sockaddr_in)); struct sockaddr_in localAddr; if(getsockname(fd, reinterpret_cast<struct sockaddr*>(&localAddr), &localLen) == SOCKET_ERROR) { @@ -1031,7 +1031,7 @@ IceInternal::fdToString(SOCKET fd) } bool peerNotConnected = false; - socklen_t remoteLen = sizeof(struct sockaddr_in); + socklen_t remoteLen = static_cast<socklen_t>(sizeof(struct sockaddr_in)); struct sockaddr_in remoteAddr; if(getpeername(fd, reinterpret_cast<struct sockaddr*>(&remoteAddr), &remoteLen) == SOCKET_ERROR) { diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index ddd12a6b8a1..2ed6c3d084b 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -19,6 +19,7 @@ #ifdef _WIN32 # include <winsock.h> +typedef int ssize_t; #else # include <unistd.h> # include <fcntl.h> diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index b2b8d81a458..a57551c1673 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -53,7 +53,7 @@ Ice::Object::operator<(const Object& r) const Int Ice::Object::ice_hash() const { - return reinterpret_cast<Int>(this) >> 4; + return static_cast<Int>(reinterpret_cast<Long>(this) >> 4); } const string Ice::Object::__ids[] = @@ -238,7 +238,7 @@ Ice::Object::__marshal(const ::Ice::StreamPtr& __os) const { IceUtil::Mutex::Lock sync(_activeFacetMapMutex); - __os->startWriteDictionary("ice:facets", _activeFacetMap.size()); + __os->startWriteDictionary("ice:facets", static_cast<Int>(_activeFacetMap.size())); for(map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) { __os->startWriteDictionaryElement(); @@ -388,7 +388,7 @@ Ice::Object::ice_findFacet(const string& name) ObjectPtr Ice::Object::ice_findFacetPath(const vector<string>& path, int start) { - int sz = path.size(); + int sz = static_cast<int>(path.size()); if(start > sz) { diff --git a/cpp/src/Ice/StringUtil.cpp b/cpp/src/Ice/StringUtil.cpp index 08b55a223b5..2603dfdea9e 100644 --- a/cpp/src/Ice/StringUtil.cpp +++ b/cpp/src/Ice/StringUtil.cpp @@ -146,7 +146,7 @@ IceInternal::decodeString(const string& s, string::size_type start, string::size while(start < end) { - string::size_type ch = s[start]; + char ch = s[start]; if(ch == '\\') { start++; diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index 79aff442209..f4fbd688dde 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -62,7 +62,7 @@ IceInternal::TcpTransceiver::shutdown() void IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) { - int packetSize = buf.b.end() - buf.i; + Buffer::Container::difference_type packetSize = buf.b.end() - buf.i; #ifdef _WIN32 // @@ -77,7 +77,7 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) while(buf.i != buf.b.end()) { assert(_fd != INVALID_SOCKET); - int ret = ::send(_fd, &*buf.i, packetSize, 0); + ssize_t ret = ::send(_fd, &*buf.i, packetSize, 0); if(ret == 0) { @@ -161,7 +161,7 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) if(_stats) { - _stats->bytesSent(_name, ret); + _stats->bytesSent(_name, static_cast<Int>(ret)); } buf.i += ret; @@ -176,12 +176,12 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) void IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) { - int packetSize = buf.b.end() - buf.i; + Buffer::Container::difference_type packetSize = buf.b.end() - buf.i; while(buf.i != buf.b.end()) { assert(_fd != INVALID_SOCKET); - int ret = ::recv(_fd, &*buf.i, packetSize, 0); + ssize_t ret = ::recv(_fd, &*buf.i, packetSize, 0); if(ret == 0) { @@ -265,7 +265,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) if(_stats) { - _stats->bytesReceived(_name, ret); + _stats->bytesReceived(_name, static_cast<Int>(ret)); } buf.i += ret; diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 5f4f6dfb6f2..53152fd03d8 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -634,11 +634,11 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) assert(stream.i == stream.b.end()); } - int pos = stream.i - stream.b.begin(); + ptrdiff_t pos = stream.i - stream.b.begin(); assert(pos >= headerSize); stream.i = stream.b.begin(); MagicBytes m(sizeof(magic), 0); - stream.readBlob(m, sizeof(magic)); + stream.readBlob(m, static_cast<Int>(sizeof(magic))); if(!equal(m.begin(), m.end(), magic)) { BadMagicException ex(__FILE__, __LINE__); diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index 28fd8adbb98..b5cd431fdae 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -18,7 +18,9 @@ #include <IceUtil/Shared.h> #include <Ice/TransceiverF.h> -#ifndef _WIN32 +#ifdef _WIN32 +typedef int ssize_t; +#else # define SOCKET int #endif diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index d33c96c5473..889adf46f79 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -63,7 +63,7 @@ IceInternal::UdpTransceiver::write(Buffer& buf, int) repeat: assert(_fd != INVALID_SOCKET); - int ret = ::send(_fd, &buf.b[0], buf.b.size(), 0); + ssize_t ret = ::send(_fd, &buf.b[0], buf.b.size(), 0); if(ret == SOCKET_ERROR) { @@ -108,10 +108,10 @@ repeat: if(_stats) { - _stats->bytesSent(_name, ret); + _stats->bytesSent(_name, static_cast<Int>(ret)); } - assert(ret == static_cast<int>(buf.b.size())); + assert(ret == static_cast<ssize_t>(buf.b.size())); buf.i = buf.b.end(); } @@ -126,7 +126,7 @@ IceInternal::UdpTransceiver::read(Buffer& buf, int) repeat: - int ret; + ssize_t ret; if(_connect) { // @@ -135,7 +135,7 @@ repeat: // struct sockaddr_in peerAddr; memset(&peerAddr, 0, sizeof(struct sockaddr_in)); - socklen_t len = sizeof(peerAddr); + socklen_t len = static_cast<socklen_t>(sizeof(peerAddr)); assert(_fd != INVALID_SOCKET); ret = recvfrom(_fd, &buf.b[0], packetSize, 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len); if(ret != SOCKET_ERROR) @@ -199,7 +199,7 @@ repeat: if(_stats) { - _stats->bytesReceived(_name, ret); + _stats->bytesReceived(_name, static_cast<Int>(ret)); } buf.b.resize(ret); diff --git a/cpp/src/IcePack/ActivatorI.cpp b/cpp/src/IcePack/ActivatorI.cpp index 2a123f1e7e0..807dd2e5c10 100644 --- a/cpp/src/IcePack/ActivatorI.cpp +++ b/cpp/src/IcePack/ActivatorI.cpp @@ -168,7 +168,7 @@ IcePack::ActivatorI::activate(const ServerPtr& server) // // Compute arguments. // - int argc = server->description.args.size() + _propertiesOverride.size() + 3; + int argc = static_cast<int>(server->description.args.size() + _propertiesOverride.size() + 3); char** argv = static_cast<char**>(malloc(argc * sizeof(char*))); argv[0] = strdup(path.c_str()); @@ -609,7 +609,7 @@ IcePack::ActivatorI::terminationListener() } char s[16]; - int rs; + ssize_t rs; string message; // diff --git a/cpp/src/IcePack/AdapterFactory.h b/cpp/src/IcePack/AdapterFactory.h index 0a07de56ce9..c614dbc0bce 100644 --- a/cpp/src/IcePack/AdapterFactory.h +++ b/cpp/src/IcePack/AdapterFactory.h @@ -52,6 +52,6 @@ private: typedef ::IceUtil::Handle< AdapterFactory> AdapterFactoryPtr; -}; +} #endif diff --git a/cpp/src/IcePack/NodeI.h b/cpp/src/IcePack/NodeI.h index 2810eef856e..2f53cee988a 100644 --- a/cpp/src/IcePack/NodeI.h +++ b/cpp/src/IcePack/NodeI.h @@ -39,6 +39,6 @@ private: }; -}; +} #endif diff --git a/cpp/src/IcePack/ObjectRegistryI.cpp b/cpp/src/IcePack/ObjectRegistryI.cpp index b26d0c4105e..425352a9197 100644 --- a/cpp/src/IcePack/ObjectRegistryI.cpp +++ b/cpp/src/IcePack/ObjectRegistryI.cpp @@ -168,7 +168,7 @@ IcePack::ObjectRegistryI::findByType(const string& type, const Ice::Current&) co throw ObjectNotExistException(); } - int r = rand() % p->second.size(); + int r = rand() % int(p->second.size()); return p->second[r]; } diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index f0c00c7a1d1..24d2ecc6172 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -733,7 +733,7 @@ IcePack::Parser::getInput(char* buf, int& result, int maxSize) } } - result = line.length(); + result = (int) line.length(); if(result > maxSize) { error("input line too long"); @@ -749,7 +749,7 @@ IcePack::Parser::getInput(char* buf, int& result, int maxSize) } else { - if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l index 16eac61171b..ab945b09369 100644 --- a/cpp/src/IcePack/Scanner.l +++ b/cpp/src/IcePack/Scanner.l @@ -173,8 +173,8 @@ NL [\n] } {WS}*(\\{WS}*{NL})? { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\\') { @@ -188,8 +188,8 @@ NL [\n] } {NL}|; { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\n') { diff --git a/cpp/src/IcePack/ServerFactory.h b/cpp/src/IcePack/ServerFactory.h index ba67510c8a7..f729ed05a88 100644 --- a/cpp/src/IcePack/ServerFactory.h +++ b/cpp/src/IcePack/ServerFactory.h @@ -65,6 +65,6 @@ private: typedef ::IceUtil::Handle< ServerFactory> ServerFactoryPtr; -}; +} #endif diff --git a/cpp/src/IcePack/ServerI.h b/cpp/src/IcePack/ServerI.h index 69813e02c7c..55c03dd4579 100644 --- a/cpp/src/IcePack/ServerI.h +++ b/cpp/src/IcePack/ServerI.h @@ -63,6 +63,6 @@ private: ServerState _state; }; -}; +} #endif diff --git a/cpp/src/IcePack/WaitQueue.h b/cpp/src/IcePack/WaitQueue.h index eb016ea3b04..db3b54d69db 100644 --- a/cpp/src/IcePack/WaitQueue.h +++ b/cpp/src/IcePack/WaitQueue.h @@ -67,6 +67,6 @@ private: typedef IceUtil::Handle<WaitQueue> WaitQueuePtr; -}; +} #endif diff --git a/cpp/src/IcePatch/ClientUtil.cpp b/cpp/src/IcePatch/ClientUtil.cpp index 8c7805ac6d7..b9f54b78b0b 100644 --- a/cpp/src/IcePatch/ClientUtil.cpp +++ b/cpp/src/IcePatch/ClientUtil.cpp @@ -49,12 +49,12 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) FileInfo infoBZ2 = getFileInfo(pathBZ2, false); if(infoBZ2.type == FileTypeRegular) { - ByteSeq remoteBZ2MD5 = regular->getBZ2MD5(infoBZ2.size); - ByteSeq localBZ2MD5 = calcPartialMD5(pathBZ2, infoBZ2.size); + ByteSeq remoteBZ2MD5 = regular->getBZ2MD5(static_cast<Int>(infoBZ2.size)); + ByteSeq localBZ2MD5 = calcPartialMD5(pathBZ2, static_cast<Int>(infoBZ2.size)); if(remoteBZ2MD5 == localBZ2MD5) { - posBZ2 = infoBZ2.size; + posBZ2 = static_cast<Int>(infoBZ2.size); } } @@ -81,7 +81,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) break; } - posBZ2 += bytesBZ2.size(); + posBZ2 += static_cast<Int>(bytesBZ2.size()); fileBZ2.write(&bytesBZ2[0], bytesBZ2.size()); if(!fileBZ2) @@ -167,7 +167,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) throw ex; } - progressCB.updateUncompress(totalBZ2, pos); + progressCB.updateUncompress(totalBZ2, static_cast<Int>(pos)); file.write(bytesBZ2, sz); if(!file) diff --git a/cpp/src/IcePatch/IcePatchI.cpp b/cpp/src/IcePatch/IcePatchI.cpp index ffb7490cbc2..3d84cae16b1 100644 --- a/cpp/src/IcePatch/IcePatchI.cpp +++ b/cpp/src/IcePatch/IcePatchI.cpp @@ -228,7 +228,7 @@ IcePatch::RegularI::getBZ2Size(const Current& current) const } } - return infoBZ2.size; + return static_cast<Int>(infoBZ2.size); } catch(const IceUtil::ThreadLockedException&) { diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index e7465e1192c..036d7d6b1b7 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -790,7 +790,7 @@ IcePatch::createBZ2(const string& path, const Ice::LoggerPtr& logger) if(file.gcount() > 0) { - BZ2_bzWrite(&bzError, bzFile, bytes, file.gcount()); + BZ2_bzWrite(&bzError, bzFile, bytes, static_cast<int>(file.gcount())); if(bzError != BZ_OK) { FileAccessException ex; diff --git a/cpp/src/IceSSL/ConfigParser.cpp b/cpp/src/IceSSL/ConfigParser.cpp index f6315094331..d9c3240e1a6 100644 --- a/cpp/src/IceSSL/ConfigParser.cpp +++ b/cpp/src/IceSSL/ConfigParser.cpp @@ -367,9 +367,9 @@ IceSSL::ConfigParser::getGeneral(ICE_XERCES_NS DOMNode* rootNode, GeneralConfig& ICE_XERCES_NS DOMNamedNodeMap* attributes = general->getAttributes(); - int attrCount = attributes->getLength(); + size_t attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); string nodeName = toString(attribute->getNodeName()); @@ -398,9 +398,9 @@ IceSSL::ConfigParser::getCertAuth(ICE_XERCES_NS DOMNode* rootNode, CertificateAu ICE_XERCES_NS DOMNamedNodeMap* attributes = certAuthNode->getAttributes(); - int attrCount = attributes->getLength(); + size_t attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); nodeName = toString(attribute->getNodeName()); @@ -525,9 +525,9 @@ IceSSL::ConfigParser::getCert(ICE_XERCES_NS DOMNode* rootNode, CertificateDesc& int keySize = 0; ICE_XERCES_NS DOMNamedNodeMap* attributes = rootNode->getAttributes(); - int attrCount = attributes->getLength(); + size_t attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); string nodeName = toString(attribute->getNodeName()); @@ -562,9 +562,9 @@ IceSSL::ConfigParser::getDHParams(ICE_XERCES_NS DOMNode* rootNode, DiffieHellman ICE_XERCES_NS DOMNamedNodeMap* attributes = rootNode->getAttributes(); int keySize = 0; - int attrCount = attributes->getLength(); + size_t attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); string nodeName = toString(attribute->getNodeName()); @@ -591,9 +591,9 @@ IceSSL::ConfigParser::loadCertificateFile(ICE_XERCES_NS DOMNode* rootNode, Certi int encoding = 0; // Initialize, to keep the compiler from complaining. ICE_XERCES_NS DOMNamedNodeMap* attributes = rootNode->getAttributes(); - int attrCount = attributes->getLength(); + size_t attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); string nodeName = toString(attribute->getNodeName()); diff --git a/cpp/src/IceSSL/Convert.cpp b/cpp/src/IceSSL/Convert.cpp index 343a5c000db..6162b772c1c 100644 --- a/cpp/src/IceSSL/Convert.cpp +++ b/cpp/src/IceSSL/Convert.cpp @@ -27,7 +27,7 @@ IceSSL::ucharToByteSeq(unsigned char* ucharBuffer, int length, Ice::ByteSeq& des unsigned char* IceSSL::byteSeqToUChar(const Ice::ByteSeq& sequence) { - int seqSize = sequence.size(); + size_t seqSize = sequence.size(); assert(seqSize > 0); diff --git a/cpp/src/IceSSL/DefaultCertificateVerifier.cpp b/cpp/src/IceSSL/DefaultCertificateVerifier.cpp index b1457aec957..739d1d3ace4 100644 --- a/cpp/src/IceSSL/DefaultCertificateVerifier.cpp +++ b/cpp/src/IceSSL/DefaultCertificateVerifier.cpp @@ -62,7 +62,7 @@ IceSSL::DefaultCertificateVerifier::verify(int preVerifyOkay, X509_STORE_CTX* x5 X509* err_cert = X509_STORE_CTX_get_current_cert(x509StoreContext); - X509_NAME_oneline(X509_get_subject_name(err_cert), buf, sizeof(buf)); + X509_NAME_oneline(X509_get_subject_name(err_cert), buf, int(sizeof(buf))); Ice::Trace out(_logger, _traceLevels->securityCat); @@ -79,7 +79,7 @@ IceSSL::DefaultCertificateVerifier::verify(int preVerifyOkay, X509_STORE_CTX* x5 { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: { - X509_NAME_oneline(X509_get_issuer_name(err_cert), buf, sizeof(buf)); + X509_NAME_oneline(X509_get_issuer_name(err_cert), buf, int(sizeof(buf))); out << "issuer = " << buf << "\n"; break; } diff --git a/cpp/src/IceSSL/OpenSSLUtils.cpp b/cpp/src/IceSSL/OpenSSLUtils.cpp index c8eee143f12..f8fd7a2cd6c 100644 --- a/cpp/src/IceSSL/OpenSSLUtils.cpp +++ b/cpp/src/IceSSL/OpenSSLUtils.cpp @@ -338,7 +338,7 @@ IceSSL::getTempDH(unsigned char* p, int plen, unsigned char* g, int glen) DH* IceSSL::getTempDH512() { - DH* dh = getTempDH(dh512_p, sizeof(dh512_p), dh512_g, sizeof(dh512_g)); + DH* dh = getTempDH(dh512_p, (int) sizeof(dh512_p), dh512_g, (int) sizeof(dh512_g)); return dh; } @@ -346,7 +346,7 @@ IceSSL::getTempDH512() DH* IceSSL::getTempDH1024() { - DH* dh = getTempDH(dh1024_p, sizeof(dh1024_p), dh1024_g, sizeof(dh1024_g)); + DH* dh = getTempDH(dh1024_p, (int) sizeof(dh1024_p), dh1024_g, (int) sizeof(dh1024_g)); return dh; } @@ -354,7 +354,7 @@ IceSSL::getTempDH1024() DH* IceSSL::getTempDH2048() { - DH* dh = getTempDH(dh2048_p, sizeof(dh2048_p), dh2048_g, sizeof(dh2048_g)); + DH* dh = getTempDH(dh2048_p, (int) sizeof(dh2048_p), dh2048_g, (int) sizeof(dh2048_g)); return dh; } @@ -362,7 +362,7 @@ IceSSL::getTempDH2048() DH* IceSSL::getTempDH4096() { - DH* dh = getTempDH(dh4096_p, sizeof(dh4096_p), dh4096_g, sizeof(dh4096_g)); + DH* dh = getTempDH(dh4096_p, (int) sizeof(dh4096_p), dh4096_g, (int) sizeof(dh4096_g)); return dh; } @@ -379,7 +379,7 @@ IceSSL::sslGetErrors() const char* data = 0; int line = 0; int flags = 0; - unsigned errorCode = 0; + unsigned long errorCode = 0; int errorNum = 1; unsigned long es = CRYPTO_thread_id(); @@ -389,7 +389,7 @@ IceSSL::sslGetErrors() sprintf(bigBuffer,"%6d - Thread ID: %lu\n", errorNum, es); errorMessage += bigBuffer; - sprintf(bigBuffer,"%6d - Error: %u\n", errorNum, errorCode); + sprintf(bigBuffer,"%6d - Error: %lu\n", errorNum, errorCode); errorMessage += bigBuffer; // Request an error from the OpenSSL library @@ -451,7 +451,7 @@ static const char* errorStrings[] = }; string -IceSSL::getVerificationError(int errorCode) +IceSSL::getVerificationError(long errorCode) { string errString; diff --git a/cpp/src/IceSSL/OpenSSLUtils.h b/cpp/src/IceSSL/OpenSSLUtils.h index 2815ec4b059..9551fd29193 100644 --- a/cpp/src/IceSSL/OpenSSLUtils.h +++ b/cpp/src/IceSSL/OpenSSLUtils.h @@ -36,7 +36,7 @@ DH* getTempDH4096(); std::string sslGetErrors(); -std::string getVerificationError(int); +std::string getVerificationError(long); } diff --git a/cpp/src/IceSSL/ServerContext.cpp b/cpp/src/IceSSL/ServerContext.cpp index 94e9b6647fe..6b927caffda 100644 --- a/cpp/src/IceSSL/ServerContext.cpp +++ b/cpp/src/IceSSL/ServerContext.cpp @@ -52,7 +52,7 @@ IceSSL::ServerContext::configure(const GeneralConfig& generalConfig, string connectionContext = generalConfig.getContext(); SSL_CTX_set_session_id_context(_sslContext, reinterpret_cast<const unsigned char *>(connectionContext.c_str()), - connectionContext.size()); + (unsigned int) connectionContext.size()); if(_traceLevels->security >= SECURITY_PROTOCOL) { diff --git a/cpp/src/IceSSL/SslClientTransceiver.cpp b/cpp/src/IceSSL/SslClientTransceiver.cpp index bac298101f2..1b58023be0c 100644 --- a/cpp/src/IceSSL/SslClientTransceiver.cpp +++ b/cpp/src/IceSSL/SslClientTransceiver.cpp @@ -42,7 +42,7 @@ IceSSL::SslClientTransceiver::write(Buffer& buf, int timeout) int totalBytesWritten = 0; int bytesWritten = 0; - int packetSize = buf.b.end() - buf.i; + Buffer::Container::difference_type packetSize = buf.b.end() - buf.i; #ifdef _WIN32 // @@ -74,7 +74,7 @@ IceSSL::SslClientTransceiver::write(Buffer& buf, int timeout) break; } - bytesWritten = sslWrite(static_cast<char*>(&*buf.i), packetSize); + bytesWritten = sslWrite(static_cast<char*>(&*buf.i), static_cast<Int>(packetSize)); switch(getLastError()) { @@ -303,7 +303,7 @@ IceSSL::SslClientTransceiver::handshake(int timeout) case SSL_ERROR_SSL: { - int verifyError = SSL_get_verify_result(_sslConnection); + long verifyError = SSL_get_verify_result(_sslConnection); if(verifyError != X509_V_OK && verifyError != 1) { diff --git a/cpp/src/IceSSL/SslServerTransceiver.cpp b/cpp/src/IceSSL/SslServerTransceiver.cpp index e6195d7d13a..88b48696706 100644 --- a/cpp/src/IceSSL/SslServerTransceiver.cpp +++ b/cpp/src/IceSSL/SslServerTransceiver.cpp @@ -44,7 +44,7 @@ IceSSL::SslServerTransceiver::write(Buffer& buf, int timeout) int totalBytesWritten = 0; int bytesWritten = 0; - int packetSize = buf.b.end() - buf.i; + Buffer::Container::difference_type packetSize = buf.b.end() - buf.i; #ifdef _WIN32 // @@ -75,7 +75,7 @@ IceSSL::SslServerTransceiver::write(Buffer& buf, int timeout) break; } - bytesWritten = sslWrite(static_cast<char*>(&*buf.i), packetSize); + bytesWritten = sslWrite(static_cast<char*>(&*buf.i), static_cast<Int>(packetSize)); switch(getLastError()) { diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp index 567d4a9e9e6..f5b3b5c34c2 100644 --- a/cpp/src/IceSSL/SslTransceiver.cpp +++ b/cpp/src/IceSSL/SslTransceiver.cpp @@ -111,7 +111,7 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout) _plugin->registerThread(); - int packetSize = buf.b.end() - buf.i; + Buffer::Container::difference_type packetSize = buf.b.end() - buf.i; int totalBytesRead = 0; int bytesRead; @@ -152,7 +152,7 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout) _readTimeout = timeout; - bytesRead = sslRead(static_cast<char*>(&*buf.i), packetSize); + bytesRead = sslRead(static_cast<char*>(&*buf.i), static_cast<Int>(packetSize)); switch(getLastError()) { @@ -818,10 +818,10 @@ IceSSL::SslTransceiver::showCertificateChain(BIO* bio) for(int i = 0; i < sk_X509_num(sk); i++) { - X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk,i)), buffer, sizeof(buffer)); + X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk,i)), buffer, int(sizeof(buffer))); BIO_printf(bio, "%2d s:%s\n", i, buffer); - X509_NAME_oneline(X509_get_issuer_name(sk_X509_value(sk,i)), buffer, sizeof(buffer)); + X509_NAME_oneline(X509_get_issuer_name(sk_X509_value(sk,i)), buffer, int(sizeof(buffer))); BIO_printf(bio, " i:%s\n", buffer); PEM_write_bio_X509(bio, sk_X509_value(sk, i)); @@ -847,10 +847,10 @@ IceSSL::SslTransceiver::showPeerCertificate(BIO* bio, const char* connType) BIO_printf(bio, "%s Certificate\n", connType); PEM_write_bio_X509(bio, peerCert); - X509_NAME_oneline(X509_get_subject_name(peerCert), buffer, sizeof(buffer)); + X509_NAME_oneline(X509_get_subject_name(peerCert), buffer, int(sizeof(buffer))); BIO_printf(bio, "subject=%s\n", buffer); - X509_NAME_oneline(X509_get_issuer_name(peerCert), buffer, sizeof(buffer)); + X509_NAME_oneline(X509_get_issuer_name(peerCert), buffer, int(sizeof(buffer))); BIO_printf(bio, "issuer=%s\n", buffer); EVP_PKEY *pktmp; @@ -875,7 +875,7 @@ IceSSL::SslTransceiver::showSharedCiphers(BIO* bio) char buffer[4096]; char* strPointer = 0; - if((strPointer = SSL_get_shared_ciphers(_sslConnection, buffer, sizeof(buffer))) != 0) + if((strPointer = SSL_get_shared_ciphers(_sslConnection, buffer, int(sizeof(buffer)))) != 0) { // This works only for SSL 2. In later protocol versions, the client does not know // what other ciphers (in addition to the one to be used in the current connection) @@ -968,8 +968,8 @@ IceSSL::SslTransceiver::showClientCAList(BIO* bio, const char* connType) for(int i = 0; i < sk_X509_NAME_num(sk); i++) { - X509_NAME_oneline(sk_X509_NAME_value(sk, i), buffer, sizeof(buffer)); - BIO_write(bio, buffer, strlen(buffer)); + X509_NAME_oneline(sk_X509_NAME_value(sk, i), buffer, int(sizeof(buffer))); + BIO_write(bio, buffer, int(strlen(buffer))); BIO_write(bio,"\n", 1); } } diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp index 974ca9f8d85..bd238b8846d 100644 --- a/cpp/src/IceStorm/Parser.cpp +++ b/cpp/src/IceStorm/Parser.cpp @@ -461,7 +461,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } } - result = line.length(); + result = (int) line.length(); if(result > maxSize) { error("input line too long"); @@ -477,7 +477,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } else { - if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; diff --git a/cpp/src/IceStorm/Scanner.l b/cpp/src/IceStorm/Scanner.l index 0f7d7da728b..caac4678403 100644 --- a/cpp/src/IceStorm/Scanner.l +++ b/cpp/src/IceStorm/Scanner.l @@ -125,8 +125,8 @@ NL [\n] } {WS}*(\\{WS}*{NL})? { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\\') { @@ -140,8 +140,8 @@ NL [\n] } {NL}|; { - int len = strlen(yytext); - for(int i = 0; i < len; ++i) + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) { if(yytext[i] == '\n') { diff --git a/cpp/src/IceStorm/WeightedGraph.cpp b/cpp/src/IceStorm/WeightedGraph.cpp index 6f006893dce..25c11877998 100644 --- a/cpp/src/IceStorm/WeightedGraph.cpp +++ b/cpp/src/IceStorm/WeightedGraph.cpp @@ -262,12 +262,12 @@ WeightedGraph::getEdgesFor(const std::string& vertex) const map<std::string, int>::const_iterator p = _vlookup.find(vertex); if(p != _vlookup.end()) { - int row = p->second * _vertices.size(); - for(unsigned int i = row; i < row + _vertices.size(); ++i) + size_t row = p->second * _vertices.size(); + for(size_t i = row; i < row + _vertices.size(); ++i) { if(_edges[i] != -1) { - edges.push_back(make_pair(_vertices[i-row], _edges[i])); + edges.push_back(make_pair(_vertices[i - row], _edges[i])); } } } @@ -346,14 +346,14 @@ WeightedGraph::visit(unsigned int vertex, int cost, list<pair<unsigned int, int> // Run through each edges for this vertex (that's a row in the // adjacency matrix). // - int row = vertex * _vertices.size(); - for(unsigned int i = row ; i < row + _vertices.size() ; ++i) + size_t row = vertex * _vertices.size(); + for(size_t i = row ; i < row + _vertices.size() ; ++i) { if(_edges[i] != -1) { if(cost + _edges[i] <= max) { - visit(i - row, cost + _edges[i], visited, max); + visit(static_cast<unsigned int>(i - row), cost + _edges[i], visited, max); } } } diff --git a/cpp/src/IceUtil/UUID.cpp b/cpp/src/IceUtil/UUID.cpp index 9fe4ea8eb64..910158b112a 100644 --- a/cpp/src/IceUtil/UUID.cpp +++ b/cpp/src/IceUtil/UUID.cpp @@ -45,9 +45,9 @@ inline void halfByteToHex(unsigned char hb, char*& hexBuffer) } } -inline void bytesToHex(unsigned char* bytes, int len, char*& hexBuffer) +inline void bytesToHex(unsigned char* bytes, size_t len, char*& hexBuffer) { - for(int i = 0; i < len; i++) + for(size_t i = 0; i < len; i++) { halfByteToHex((bytes[i] & 0xF0) >> 4, hexBuffer); halfByteToHex((bytes[i] & 0x0F), hexBuffer); @@ -134,7 +134,7 @@ IceUtil::generateUUID() assert(sizeof(UUID) == 16); - ssize_t bytesRead = read(fd, &uuid, sizeof(UUID)); + size_t bytesRead = read(fd, &uuid, sizeof(UUID)); if (bytesRead != sizeof(UUID)) { diff --git a/cpp/src/IceXML/StreamI.cpp b/cpp/src/IceXML/StreamI.cpp index 343c99d1547..4ae72e53b1c 100644 --- a/cpp/src/IceXML/StreamI.cpp +++ b/cpp/src/IceXML/StreamI.cpp @@ -244,7 +244,7 @@ IceXML::StreamI::StreamI(const ::Ice::CommunicatorPtr& communicator, std::istrea bool errorsOccured = false; try { - ICE_XERCES_NS MemBufInputSource source((const XMLByte*)_content.data(), _content.size(), "inputsource"); + ICE_XERCES_NS MemBufInputSource source((const XMLByte*)_content.data(), (unsigned int) _content.size(), "inputsource"); parser.parse(source); if(parser.getErrorCount() > 0) { @@ -474,7 +474,7 @@ IceXML::StreamI::readEnum(const string& name, const ::Ice::StringSeq& table) endRead(); - return p - table.begin(); + return ::Ice::Int(p - table.begin()); } void @@ -492,7 +492,7 @@ IceXML::StreamI::writeByte(const string& name, ::Ice::Byte value) void IceXML::StreamI::writeByteSeq(const string& name, const ::Ice::ByteSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::ByteSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { startWriteSequenceElement(); @@ -600,7 +600,7 @@ IceXML::StreamI::writeBool(const string& name, bool value) void IceXML::StreamI::writeBoolSeq(const string& name, const ::Ice::BoolSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::BoolSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e") << (*p ? "true" : "false") << ee; @@ -661,7 +661,7 @@ IceXML::StreamI::writeShort(const string& name, ::Ice::Short value) void IceXML::StreamI::writeShortSeq(const string& name, const ::Ice::ShortSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::ShortSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e") << *p << ee; @@ -727,7 +727,7 @@ IceXML::StreamI::writeInt(const string& name, ::Ice::Int value) void IceXML::StreamI::writeIntSeq(const string& name, const ::Ice::IntSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::IntSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e") << *p << ee; @@ -788,7 +788,7 @@ IceXML::StreamI::writeLong(const string& name, ::Ice::Long value) void IceXML::StreamI::writeLongSeq(const string& name, const ::Ice::LongSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::LongSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e") << *p << ee; @@ -855,7 +855,7 @@ IceXML::StreamI::writeFloat(const string& name, ::Ice::Float value) void IceXML::StreamI::writeFloatSeq(const string& name, const ::Ice::FloatSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::FloatSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e") << *p << ee; @@ -916,7 +916,7 @@ IceXML::StreamI::writeDouble(const string& name, ::Ice::Double value) void IceXML::StreamI::writeDoubleSeq(const string& name, const ::Ice::DoubleSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::DoubleSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e") << *p << ee; @@ -983,7 +983,7 @@ IceXML::StreamI::writeString(const string& name, const string& value) void IceXML::StreamI::writeStringSeq(const string& name, const ::Ice::StringSeq& seq) { - startWriteSequence(name, seq.size()); + startWriteSequence(name, ::Ice::Int(seq.size())); for(::Ice::StringSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << se("e"); @@ -1380,8 +1380,8 @@ void IceXML::StreamI::readAttributes(::std::string& id, ::std::string& type, ::std::string& href) { ICE_XERCES_NS DOMNamedNodeMap* attributes = _input->current->getAttributes(); - int attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + size_t attrCount = attributes->getLength(); + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); string name = toString(attribute->getNodeName()); @@ -1404,8 +1404,8 @@ IceXML::StreamI::readAttributes(::std::string& id, ::std::string& type, ::std::s IceXML::StreamI::readLength() { ICE_XERCES_NS DOMNamedNodeMap* attributes = _input->current->getAttributes(); - int attrCount = attributes->getLength(); - for(int i = 0; i < attrCount; i++) + size_t attrCount = attributes->getLength(); + for(size_t i = 0; i < attrCount; i++) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); string name = toString(attribute->getNodeName()); diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 3976698b4ce..92bd2f0a1dc 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -38,6 +38,7 @@ toLower(string& s) transform(s.begin(), s.end(), s.begin(), ::tolower); } + // ---------------------------------------------------------------------- // SyntaxTreeBase // ---------------------------------------------------------------------- @@ -3021,7 +3022,15 @@ Slice::Const::typesAreCompatible(const string& name, const TypePtr& constType, const UnitPtr& unit) { BuiltinPtr ct = BuiltinPtr::dynamicCast(constType); + +#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530) +// Strange Sun C++ 5.3 bug + const IceUtil::HandleBase<SyntaxTreeBase>& hb = literalType; + BuiltinPtr lt = BuiltinPtr::dynamicCast(hb); +#else BuiltinPtr lt = BuiltinPtr::dynamicCast(literalType); +#endif + if(ct && lt) { switch(ct->kind()) diff --git a/cpp/src/XMLTransform/XMLTransform.cpp b/cpp/src/XMLTransform/XMLTransform.cpp index 4a7e4171c4a..aa193397b55 100644 --- a/cpp/src/XMLTransform/XMLTransform.cpp +++ b/cpp/src/XMLTransform/XMLTransform.cpp @@ -369,7 +369,7 @@ XMLTransform::DocumentInfo::DocumentInfo(ICE_XERCES_NS DOMDocument* document, bo _targetNamespace(targetNamespace) { ICE_XERCES_NS DOMNamedNodeMap* attributes = root->getAttributes(); - unsigned int max = attributes->getLength(); + size_t max = attributes->getLength(); for(unsigned int i = 0; i < max; ++i) { ICE_XERCES_NS DOMNode* attribute = attributes->item(i); @@ -2971,7 +2971,7 @@ XMLTransform::DBTransformer::transform(ICE_XERCES_NS DOMDocument* oldSchema, ICE fullKey.append(header); fullKey.append(&k[0], k.size()); fullKey.append(footer); - ICE_XERCES_NS MemBufInputSource keySource((const XMLByte*)fullKey.data(), fullKey.size(), "key"); + ICE_XERCES_NS MemBufInputSource keySource((const XMLByte*)fullKey.data(), static_cast<unsigned int>(fullKey.size()), "key"); parser.parse(keySource); ICE_XERCES_NS DOMDocument* keyDoc = parser.getDocument(); @@ -2992,8 +2992,9 @@ XMLTransform::DBTransformer::transform(ICE_XERCES_NS DOMDocument* oldSchema, ICE fullValue.append(header); fullValue.append(&value[0], value.size()); fullValue.append(footer); - ICE_XERCES_NS MemBufInputSource valueSource((const XMLByte*)fullValue.data(), fullValue.size(), - "value"); + ICE_XERCES_NS MemBufInputSource valueSource((const XMLByte*)fullValue.data(), + static_cast<unsigned int>(fullValue.size()), + "value"); parser.parse(valueSource); ICE_XERCES_NS DOMDocument* valueDoc = parser.getDocument(); @@ -3149,7 +3150,9 @@ XMLTransform::DBTransformer::transform(const string& schemaStr) try { - ICE_XERCES_NS MemBufInputSource source((const XMLByte*)schemaStr.data(), schemaStr.size(), "schema"); + ICE_XERCES_NS MemBufInputSource source((const XMLByte*)schemaStr.data(), + static_cast<unsigned int>(schemaStr.size()), + "schema"); parser.parse(source); schema = parser.getDocument(); } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 8263d3b959f..22440e3bc06 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -861,7 +861,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) string scoped = fixKwd(p->scoped()); string scope = fixKwd(p->scope()); - int sz = enumerators.size(); + size_t sz = enumerators.size(); assert(sz <= 0x7fffffff); // 64-bit enums are not supported H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");"; @@ -2067,7 +2067,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) StringList::const_iterator firstIter = ids.begin(); StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), p->scoped()); assert(scopedIter != ids.end()); - int scopedPos = ice_distance(firstIter, scopedIter); + StringList::difference_type scopedPos = ice_distance(firstIter, scopedIter); StringList::const_iterator q; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 2cc87fef63e..3abf2d73957 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -387,7 +387,8 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) StringList::const_iterator firstIter = ids.begin(); StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped); assert(scopedIter != ids.end()); - int scopedPos = ice_distance(firstIter, scopedIter); + StringList::difference_type scopedPos + = ice_distance(firstIter, scopedIter); out << sp << nl << "public static final String[] __ids ="; out << sb; @@ -1714,7 +1715,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) string absolute = getAbsolute(scoped); EnumeratorList enumerators = p->getEnumerators(); EnumeratorList::const_iterator en; - int sz = enumerators.size(); + size_t sz = enumerators.size(); if(!open(absolute)) { diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index 89cbf482759..b46011a354e 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -69,7 +69,7 @@ static const char* expressions[] = "5*(2+3)", "10+(10+(20+(8*(2*(3*2+4+5+6)))))" }; -static const int nexpressions = sizeof(expressions)/sizeof(expressions[0]); +static const size_t nexpressions = sizeof(expressions)/sizeof(expressions[0]); static int populate(const DBPtr& db) @@ -78,7 +78,7 @@ populate(const DBPtr& db) cout << "populating the database... "; Parser myParser; - for(int i = 0 ; i < nexpressions; ++i) + for(size_t i = 0 ; i < nexpressions; ++i) { Complex::NodePtr root = myParser.parse(expressions[i]); assert(root); diff --git a/cpp/test/Freeze/cursor/Client.cpp b/cpp/test/Freeze/cursor/Client.cpp index e0e731d5d66..5827c89a896 100644 --- a/cpp/test/Freeze/cursor/Client.cpp +++ b/cpp/test/Freeze/cursor/Client.cpp @@ -92,7 +92,7 @@ populateDB(const DBPtr& db) { for(vector<char>::const_iterator j = alphabet.begin() ; j != alphabet.end(); ++j) { - addValue(db, *j, j-alphabet.begin()); + addValue(db, *j, static_cast<int>(j - alphabet.begin())); } } diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp index c785ac880c6..84466d982f6 100644 --- a/cpp/test/Freeze/dbmap/Client.cpp +++ b/cpp/test/Freeze/dbmap/Client.cpp @@ -60,10 +60,10 @@ populateDB(MAP& m) for(vector<Byte>::const_iterator j = alphabet.begin(); j != alphabet.end(); ++j) { -#ifdef _MSC_VER - m.insert(MAP::value_type(*j, j-alphabet.begin())); +#if defined(_MSC_VER) || (defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x530) + m.insert(MAP::value_type(*j, static_cast<Int>(j - alphabet.begin()))); #else - m.insert(typename MAP::value_type(*j, j-alphabet.begin())); + m.insert(typename MAP::value_type(*j, static_cast<Int>(j - alphabet.begin()))); #endif } } @@ -307,13 +307,13 @@ run(int argc, char* argv[], MAP& m) // j = find(alphabet.begin(), alphabet.end(), 'n'); map<Byte, const Int> pairs; - pairs.insert(pair<const Byte, const Int>(*j, j - alphabet.begin())); + pairs.insert(pair<const Byte, const Int>(*j, static_cast<Int>(j - alphabet.begin()))); ++j; - pairs.insert(pair<const Byte, const Int>(*j, j - alphabet.begin())); + pairs.insert(pair<const Byte, const Int>(*j, static_cast<Int>(j - alphabet.begin()))); ++j; - pairs.insert(pair<const Byte, const Int>(*j, j - alphabet.begin())); + pairs.insert(pair<const Byte, const Int>(*j, static_cast<Int>(j - alphabet.begin()))); ++j; - pairs.insert(pair<const Byte, const Int>(*j, j - alphabet.begin())); + pairs.insert(pair<const Byte, const Int>(*j, static_cast<Int>(j - alphabet.begin()))); p = find_first_of(m.begin(), m.end(), pairs.begin(), pairs.end()); test(p != m.end()); diff --git a/cpp/test/IcePack/deployer/run.py b/cpp/test/IcePack/deployer/run.py index 528f191eea0..9329c80661f 100755 --- a/cpp/test/IcePack/deployer/run.py +++ b/cpp/test/IcePack/deployer/run.py @@ -33,6 +33,7 @@ if TestUtil.isWin32(): os.environ["PATH"] = testdir + ";" + os.getenv("PATH", "") else: os.environ["LD_LIBRARY_PATH"] = testdir + ":" + os.getenv("LD_LIBRARY_PATH", "") + os.environ["LD_LIBRARY_PATH_64"] = testdir + ":" + os.getenv("LD_LIBRARY_PATH_64", "") # # Start the client. |