diff options
author | Jose <jose@zeroc.com> | 2012-12-27 23:20:00 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-12-27 23:20:00 +0100 |
commit | 05fe914f6f78c8f7bb3f4530d68b2926bf2cea51 (patch) | |
tree | f171ab75496f6dc5e5b2cec5e92f8a46049e9a1d /cpp/src | |
parent | Fixed (ICE-5161) - Strange xxx ruby library names (diff) | |
download | ice-05fe914f6f78c8f7bb3f4530d68b2926bf2cea51.tar.bz2 ice-05fe914f6f78c8f7bb3f4530d68b2926bf2cea51.tar.xz ice-05fe914f6f78c8f7bb3f4530d68b2926bf2cea51.zip |
Fixed warnings related to ICE-5157
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/MapI.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Freeze/SharedDbEnv.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Service.cpp | 18 | ||||
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 33 | ||||
-rw-r--r-- | cpp/src/IceUtil/Cond.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceUtil/CountDownLatch.cpp | 5 | ||||
-rw-r--r-- | cpp/src/IceUtil/CtrlCHandler.cpp | 18 | ||||
-rw-r--r-- | cpp/src/IceUtil/RecMutex.cpp | 11 |
8 files changed, 90 insertions, 13 deletions
diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp index 1e4138e9e9c..ae21ce3302f 100644 --- a/cpp/src/Freeze/MapI.cpp +++ b/cpp/src/Freeze/MapI.cpp @@ -759,9 +759,13 @@ Freeze::IteratorHelperI::set(const Value& value) try { +#ifndef NDEBUG int err; err = _dbc->put(&dbKey, &dbValue, DB_CURRENT); assert(err == 0); +#else + _dbc->put(&dbKey, &dbValue, DB_CURRENT); +#endif } catch(const ::DbDeadlockException& dx) { @@ -1381,9 +1385,13 @@ Freeze::MapHelperI::clear() try { u_int32_t count; +#ifndef NDEBUG int err; err = _db->truncate(txn, &count, txn != 0 ? 0 : DB_AUTO_COMMIT); assert(err == 0); +#else + _db->truncate(txn, &count, txn != 0 ? 0 : DB_AUTO_COMMIT); +#endif break; } catch(const ::DbDeadlockException& dx) diff --git a/cpp/src/Freeze/SharedDbEnv.cpp b/cpp/src/Freeze/SharedDbEnv.cpp index 42c7ed4baf3..c85bc6e29a3 100644 --- a/cpp/src/Freeze/SharedDbEnv.cpp +++ b/cpp/src/Freeze/SharedDbEnv.cpp @@ -330,11 +330,13 @@ void Freeze::SharedDbEnv::__decRef() // // Remove from map // - +#ifndef NDEBUG size_t one; one = sharedDbEnvMap->erase(key); assert(one == 1); - +#else + sharedDbEnvMap->erase(key); +#endif if(sharedDbEnvMap->size() == 0) { delete sharedDbEnvMap; diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index df2681fb02b..d5f77ada648 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -1709,15 +1709,33 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa int fd; fd = open("/dev/null", O_RDWR); assert(fd == 0); + if(fd != 0) + { + SyscallException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSystemErrno(); + throw ex; + } if(stdOut.empty()) { fd = dup2(0, 1); assert(fd == 1); + if(fd != 1) + { + SyscallException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSystemErrno(); + throw ex; + } } if(stdErr.empty()) { fd = dup2(1, 2); assert(fd == 2); + if(fd != 2) + { + SyscallException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSystemErrno(); + throw ex; + } } } diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index ea4e7e3e502..fb524781864 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -73,7 +73,7 @@ private: // Helper function for async-signal safe error reporting // void -reportChildError(int err, int fd, const char* cannot, const char* name) +reportChildError(int err, int fd, const char* cannot, const char* name, const TraceLevelsPtr& traceLevels) { // // Send any errors to the parent process, using the write @@ -89,7 +89,12 @@ reportChildError(int err, int fd, const char* cannot, const char* name) strcat(msg, ": "); strcat(msg, strerror(err)); } - write(fd, msg, strlen(msg)); + ssize_t sz = write(fd, msg, strlen(msg)); + if(sz == -1) + { + Ice::Warning out(traceLevels->logger); + out << "error rerporting child error msg: `" << msg << "'"; + } close(fd); // @@ -651,14 +656,16 @@ Activator::activate(const string& name, { ostringstream os; os << gid; - reportChildError(getSystemErrno(), errorFds[1], "cannot set process group id", os.str().c_str()); + reportChildError(getSystemErrno(), errorFds[1], "cannot set process group id", os.str().c_str(), + _traceLevels); } if(setuid(uid) == -1) { ostringstream os; os << uid; - reportChildError(getSystemErrno(), errorFds[1], "cannot set process user id", os.str().c_str()); + reportChildError(getSystemErrno(), errorFds[1], "cannot set process user id", os.str().c_str(), + _traceLevels); } // @@ -687,7 +694,8 @@ Activator::activate(const string& name, // if(putenv(strdup(env.argv[i])) != 0) { - reportChildError(errno, errorFds[1], "cannot set environment variable", env.argv[i]); + reportChildError(errno, errorFds[1], "cannot set environment variable", env.argv[i], + _traceLevels); } } @@ -698,7 +706,8 @@ Activator::activate(const string& name, { if(chdir(pwdCStr) == -1) { - reportChildError(errno, errorFds[1], "cannot change working directory to", pwdCStr); + reportChildError(errno, errorFds[1], "cannot change working directory to", pwdCStr, + _traceLevels); } } @@ -717,11 +726,11 @@ Activator::activate(const string& name, { if(errorFds[1] != -1) { - reportChildError(errno, errorFds[1], "cannot execute", av.argv[0]); + reportChildError(errno, errorFds[1], "cannot execute", av.argv[0], _traceLevels); } else { - reportChildError(errno, fds[1], "cannot execute", av.argv[0]); + reportChildError(errno, fds[1], "cannot execute", av.argv[0], _traceLevels); } } } @@ -1354,7 +1363,13 @@ Activator::setInterrupt() SetEvent(_hIntr); #else char c = 0; - write(_fdIntrWrite, &c, 1); + ssize_t sz = write(_fdIntrWrite, &c, 1); + if(sz == -1) + { + SyscallException ex(__FILE__, __LINE__); + ex.error = IceInternal::getSystemErrno(); + throw ex; + } #endif } diff --git a/cpp/src/IceUtil/Cond.cpp b/cpp/src/IceUtil/Cond.cpp index e63405e7184..c515e36f53b 100644 --- a/cpp/src/IceUtil/Cond.cpp +++ b/cpp/src/IceUtil/Cond.cpp @@ -357,9 +357,13 @@ IceUtil::Cond::Cond() IceUtil::Cond::~Cond() { +#ifndef NDEBUG int rc = 0; rc = pthread_cond_destroy(&_cond); assert(rc == 0); +#else + pthread_cond_destroy(&_cond); +#endif } void diff --git a/cpp/src/IceUtil/CountDownLatch.cpp b/cpp/src/IceUtil/CountDownLatch.cpp index 66c0a39c1e6..6102df82663 100644 --- a/cpp/src/IceUtil/CountDownLatch.cpp +++ b/cpp/src/IceUtil/CountDownLatch.cpp @@ -48,11 +48,16 @@ IceUtilInternal::CountDownLatch::~CountDownLatch() #ifdef _WIN32 CloseHandle(_event); #else +# ifndef NDEBUG int rc = 0; rc = pthread_mutex_destroy(&_mutex); assert(rc == 0); rc = pthread_cond_destroy(&_cond); assert(rc == 0); +# else + pthread_mutex_destroy(&_mutex); + pthread_cond_destroy(&_cond); +# endif #endif } diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp index a6f2c6e9329..196fe499240 100644 --- a/cpp/src/IceUtil/CtrlCHandler.cpp +++ b/cpp/src/IceUtil/CtrlCHandler.cpp @@ -224,19 +224,31 @@ CtrlCHandler::CtrlCHandler(CtrlCHandlerCallback callback) sigaddset(&ctrlCLikeSignals, SIGHUP); sigaddset(&ctrlCLikeSignals, SIGINT); sigaddset(&ctrlCLikeSignals, SIGTERM); + +#ifndef NDEBUG int rc = pthread_sigmask(SIG_BLOCK, &ctrlCLikeSignals, 0); assert(rc == 0); // Joinable thread rc = pthread_create(&_tid, 0, sigwaitThread, 0); assert(rc == 0); +#else + pthread_sigmask(SIG_BLOCK, &ctrlCLikeSignals, 0); + + // Joinable thread + pthread_create(&_tid, 0, sigwaitThread, 0); +#endif } } CtrlCHandler::~CtrlCHandler() { +#ifndef NDEBUG int rc = pthread_cancel(_tid); assert(rc == 0); +#else + pthread_cancel(_tid); +#endif #if defined(__APPLE__) // // WORKAROUND: sigwait isn't a cancellation point on OS X, see @@ -246,8 +258,14 @@ CtrlCHandler::~CtrlCHandler() //assert(rc == 0); For some reaosns, this assert is sometime triggered #endif void* status = 0; + +#ifndef NDEBUG rc = pthread_join(_tid, &status); assert(rc == 0); +#else + pthread_join(_tid, &status); +#endif + #if !defined(__APPLE__) assert(status == PTHREAD_CANCELED); #endif diff --git a/cpp/src/IceUtil/RecMutex.cpp b/cpp/src/IceUtil/RecMutex.cpp index 46209f55bc6..6a3f54a55eb 100644 --- a/cpp/src/IceUtil/RecMutex.cpp +++ b/cpp/src/IceUtil/RecMutex.cpp @@ -168,9 +168,13 @@ IceUtil::RecMutex::init(const MutexProtocol protocol) IceUtil::RecMutex::~RecMutex() { assert(_count == 0); +#ifndef NDEBUG int rc = 0; rc = pthread_mutex_destroy(&_mutex); assert(rc == 0); +#else + pthread_mutex_destroy(&_mutex); +#endif } void @@ -216,9 +220,12 @@ IceUtil::RecMutex::unlock() const { if(--_count == 0) { - int rc = 0; // Prevent warnings when NDEBUG is defined. - rc = pthread_mutex_unlock(&_mutex); +#ifndef NDEBUG + int rc = pthread_mutex_unlock(&_mutex); assert(rc == 0); +#else + pthread_mutex_unlock(&_mutex); +#endif } } |