Skip to content

Commit

Permalink
Fix bogus duration_cast usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Sep 26, 2024
1 parent 727e052 commit b5fa866
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cpp/src/Ice/ReferenceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ IceInternal::ReferenceFactory::create(
{
int locatorCacheTimeoutValue = properties->getPropertyAsIntWithDefault(
property,
chrono::duration_cast<chrono::duration<int>>(locatorCacheTimeout).count());
static_cast<int32_t>(locatorCacheTimeout.count()));
if (locatorCacheTimeoutValue < -1)
{
locatorCacheTimeoutValue = -1;
Expand All @@ -874,7 +874,7 @@ IceInternal::ReferenceFactory::create(
{
int invocationTimeoutValue = properties->getPropertyAsIntWithDefault(
property,
chrono::duration_cast<chrono::duration<int>>(invocationTimeout).count());
static_cast<int32_t>(invocationTimeout.count()));
if (invocationTimeoutValue < 1 && invocationTimeoutValue != -1)
{
invocationTimeoutValue = -1;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/IceGrid/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ IceGrid::getMMVersion(const string& o)
int
IceGrid::secondsToInt(const std::chrono::seconds& sec)
{
return chrono::duration_cast<chrono::duration<int>>(sec).count();
return static_cast<int>(sec.count());
}

void
Expand Down
4 changes: 2 additions & 2 deletions matlab/src/ObjectPrx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ extern "C"
mxArray* Ice_ObjectPrx_ice_getLocatorCacheTimeout(void* self)
{
chrono::seconds timeout = restoreProxy(self)->ice_getLocatorCacheTimeout();
return createResultValue(createInt(chrono::duration_cast<chrono::duration<int32_t>>(timeout).count()));
return createResultValue(createInt(static_cast<int32_t>(timeout.count())));
}

mxArray* Ice_ObjectPrx_ice_locatorCacheTimeout(void* self, void** r, int t)
Expand All @@ -564,7 +564,7 @@ extern "C"
mxArray* Ice_ObjectPrx_ice_getInvocationTimeout(void* self)
{
chrono::milliseconds timeout = restoreProxy(self)->ice_getInvocationTimeout();
return createResultValue(createInt(chrono::duration_cast<chrono::duration<int32_t>>(timeout).count()));
return createResultValue(createInt(static_cast<int32_t>>(timeout.count())));
}

mxArray* Ice_ObjectPrx_ice_invocationTimeout(void* self, void** r, int t)
Expand Down
4 changes: 2 additions & 2 deletions php/src/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ ZEND_METHOD(Ice_ObjectPrx, ice_getLocatorCacheTimeout)
try
{
chrono::seconds timeout = _this->proxy->ice_getLocatorCacheTimeout();
ZVAL_LONG(return_value, chrono::duration_cast<chrono::duration<long>>(timeout).count());
ZVAL_LONG(return_value, static_cast<long>(timeout.count()));
}
catch (...)
{
Expand Down Expand Up @@ -1254,7 +1254,7 @@ ZEND_METHOD(Ice_ObjectPrx, ice_getInvocationTimeout)
try
{
chrono::milliseconds timeout = _this->proxy->ice_getInvocationTimeout();
ZVAL_LONG(return_value, chrono::duration_cast<chrono::duration<long>>(timeout).count());
ZVAL_LONG(return_value, static_cast<long>(timeout.count()));
}
catch (...)
{
Expand Down
4 changes: 2 additions & 2 deletions python/modules/IcePy/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ proxyIceGetLocatorCacheTimeout(ProxyObject* self, PyObject* /*args*/)
try
{
chrono::seconds timeout = (*self->proxy)->ice_getLocatorCacheTimeout();
return PyLong_FromLong(chrono::duration_cast<chrono::duration<int32_t>>(timeout).count());
return PyLong_FromLong(static_cast<int32_t>(timeout.count()));
}
catch (...)
{
Expand All @@ -629,7 +629,7 @@ proxyIceGetInvocationTimeout(ProxyObject* self, PyObject* /*args*/)
try
{
chrono::milliseconds timeout = (*self->proxy)->ice_getInvocationTimeout();
return PyLong_FromLong(chrono::duration_cast<chrono::duration<int32_t>>(timeout).count());
return PyLong_FromLong(static_cast<int32_t>(timeout.count()));
}
catch (...)
{
Expand Down
4 changes: 2 additions & 2 deletions ruby/src/IceRuby/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ IceRuby_ObjectPrx_ice_getLocatorCacheTimeout(VALUE self)
{
Ice::ObjectPrx p = getProxy(self);
chrono::seconds timeout = p->ice_getLocatorCacheTimeout();
return INT2FIX(chrono::duration_cast<chrono::duration<int32_t>>(timeout).count());
return INT2FIX(static_cast<int32_t>(timeout.count()));
}
ICE_RUBY_CATCH
return Qnil;
Expand All @@ -380,7 +380,7 @@ IceRuby_ObjectPrx_ice_getInvocationTimeout(VALUE self)
{
Ice::ObjectPrx p = getProxy(self);
chrono::milliseconds timeout = p->ice_getInvocationTimeout();
return INT2FIX(chrono::duration_cast<chrono::duration<int32_t>>(timeout).count());
return INT2FIX(static_cast<int32_t>(timeout.count()));
}
ICE_RUBY_CATCH
return Qnil;
Expand Down
4 changes: 2 additions & 2 deletions swift/src/IceImpl/ObjectPrx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ - (instancetype)ice_endpoints:(NSArray<ICEEndpoint*>*)endpoints error:(NSError**

- (int32_t)ice_getLocatorCacheTimeout
{
return std::chrono::duration_cast<std::chrono::duration<int32_t>>(_prx->ice_getLocatorCacheTimeout()).count();
return static_cast<int32_t>(_prx->ice_getLocatorCacheTimeout().count());
}

- (instancetype)ice_locatorCacheTimeout:(int32_t)timeout error:(NSError**)error
Expand All @@ -144,7 +144,7 @@ - (instancetype)ice_locatorCacheTimeout:(int32_t)timeout error:(NSError**)error

- (int32_t)ice_getInvocationTimeout
{
return std::chrono::duration_cast<std::chrono::duration<int32_t>>(_prx->ice_getInvocationTimeout()).count();
return static_cast<int32_t>(_prx->ice_getInvocationTimeout().count());
}

- (instancetype)ice_invocationTimeout:(int32_t)timeout error:(NSError**)error
Expand Down

0 comments on commit b5fa866

Please sign in to comment.