summaryrefslogtreecommitdiff
path: root/binaryurp
diff options
context:
space:
mode:
Diffstat (limited to 'binaryurp')
-rw-r--r--binaryurp/CppunitTest_binaryurp_test-cache.mk2
-rw-r--r--binaryurp/CppunitTest_binaryurp_test-unmarshal.mk2
-rw-r--r--binaryurp/Library_binaryurp.mk2
-rw-r--r--binaryurp/qa/test-cache.cxx20
-rw-r--r--binaryurp/source/binaryany.cxx2
-rw-r--r--binaryurp/source/binaryurp.component2
-rw-r--r--binaryurp/source/bridge.cxx82
-rw-r--r--binaryurp/source/bridge.hxx7
-rw-r--r--binaryurp/source/bridgefactory.cxx12
-rw-r--r--binaryurp/source/incomingreply.hxx5
-rw-r--r--binaryurp/source/incomingrequest.cxx13
-rw-r--r--binaryurp/source/incomingrequest.hxx10
-rw-r--r--binaryurp/source/outgoingrequest.hxx5
-rw-r--r--binaryurp/source/proxy.cxx7
-rw-r--r--binaryurp/source/proxy.hxx4
-rw-r--r--binaryurp/source/reader.cxx7
-rw-r--r--binaryurp/source/unmarshal.cxx5
-rw-r--r--binaryurp/source/unmarshal.hxx2
-rw-r--r--binaryurp/source/writer.cxx32
-rw-r--r--binaryurp/source/writer.hxx19
20 files changed, 124 insertions, 116 deletions
diff --git a/binaryurp/CppunitTest_binaryurp_test-cache.mk b/binaryurp/CppunitTest_binaryurp_test-cache.mk
index 97f5b78f081d..50f3d1b4c02d 100644
--- a/binaryurp/CppunitTest_binaryurp_test-cache.mk
+++ b/binaryurp/CppunitTest_binaryurp_test-cache.mk
@@ -9,8 +9,6 @@
$(eval $(call gb_CppunitTest_CppunitTest,binaryurp_test-cache))
-$(eval $(call gb_CppunitTest_use_external,binaryurp_test-cache,boost_headers))
-
$(eval $(call gb_CppunitTest_use_libraries,binaryurp_test-cache,\
sal \
))
diff --git a/binaryurp/CppunitTest_binaryurp_test-unmarshal.mk b/binaryurp/CppunitTest_binaryurp_test-unmarshal.mk
index 11c70f5b9db0..03823614e99e 100644
--- a/binaryurp/CppunitTest_binaryurp_test-unmarshal.mk
+++ b/binaryurp/CppunitTest_binaryurp_test-unmarshal.mk
@@ -9,8 +9,6 @@
$(eval $(call gb_CppunitTest_CppunitTest,binaryurp_test-unmarshal))
-$(eval $(call gb_CppunitTest_use_external,binaryurp_test-unmarshal,boost_headers))
-
$(eval $(call gb_CppunitTest_use_libraries,binaryurp_test-unmarshal,\
cppu \
cppuhelper \
diff --git a/binaryurp/Library_binaryurp.mk b/binaryurp/Library_binaryurp.mk
index 439f1f7d41aa..74205c9e66a2 100644
--- a/binaryurp/Library_binaryurp.mk
+++ b/binaryurp/Library_binaryurp.mk
@@ -13,8 +13,6 @@ $(eval $(call gb_Library_set_componentfile,binaryurp,binaryurp/source/binaryurp,
$(eval $(call gb_Library_use_udk_api,binaryurp))
-$(eval $(call gb_Library_use_external,binaryurp,boost_headers))
-
$(eval $(call gb_Library_use_libraries,binaryurp,\
cppu \
cppuhelper \
diff --git a/binaryurp/qa/test-cache.cxx b/binaryurp/qa/test-cache.cxx
index 989b103e2e90..c4696f78395f 100644
--- a/binaryurp/qa/test-cache.cxx
+++ b/binaryurp/qa/test-cache.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include <sal/types.h>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
@@ -39,13 +43,13 @@ private:
// cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java:
void Test::testNothingLostFromLruList() {
int a[8];
- for (int i = 0; i != int(SAL_N_ELEMENTS(a)); ++i) {
- for (int j = 0; j != i; ++j) {
+ for (std::size_t i = 0; i != std::size(a); ++i) {
+ for (std::size_t j = 0; j != i; ++j) {
a[j] = 0;
}
for (;;) {
binaryurp::Cache< int > c(4);
- for (int k = 0; k != i; ++k) {
+ for (std::size_t k = 0; k != i; ++k) {
bool f;
c.add(a[k], &f);
}
@@ -53,15 +57,15 @@ void Test::testNothingLostFromLruList() {
CPPUNIT_ASSERT_EQUAL(
6,
c.add(-1, &f) + c.add(-2, &f) + c.add(-3, &f) + c.add(-4, &f));
- int j = i - 1;
- while (j >= 0 && a[j] == 3) {
+ std::size_t j = i;
+ while (j != 0 && a[j - 1] == 3) {
--j;
}
- if (j < 0) {
+ if (j == 0) {
break;
}
- ++a[j];
- for (int k = j + 1; k != i; ++k) {
+ ++a[j - 1];
+ for (std::size_t k = j; k != i; ++k) {
a[k] = 0;
}
}
diff --git a/binaryurp/source/binaryany.cxx b/binaryurp/source/binaryany.cxx
index 17db2f3775ef..7f6e14a6fb35 100644
--- a/binaryurp/source/binaryany.cxx
+++ b/binaryurp/source/binaryany.cxx
@@ -32,7 +32,7 @@ namespace binaryurp {
namespace {
-// Cf. com::sun::star::uno::detail::moveAnyInternals in
+// Cf. com::sun::star::uno::Any move ctor in
// include/com/sun/star/uno/Any.hxx:
void moveInternals(uno_Any & from, uno_Any & to) {
uno_any_construct(&to, nullptr, nullptr, nullptr);
diff --git a/binaryurp/source/binaryurp.component b/binaryurp/source/binaryurp.component
index e2581c76411e..b5b0f4da102f 100644
--- a/binaryurp/source/binaryurp.component
+++ b/binaryurp/source/binaryurp.component
@@ -20,7 +20,7 @@
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.bridge.BridgeFactory"
- constructor="com_sun_star_comp_bridge_BridgeFactory_get_implementation">
+ constructor="com_sun_star_comp_bridge_BridgeFactory_get_implementation" single-instance="true">
<service name="com.sun.star.bridge.BridgeFactory"/>
</implementation>
</component>
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 3299cd0ed519..068649cc3b4b 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -24,6 +24,7 @@
#include <cstddef>
#include <limits>
#include <memory>
+#include <utility>
#include <vector>
#include <com/sun/star/bridge/InvalidProtocolChangeException.hpp>
@@ -74,7 +75,7 @@ namespace {
sal_Int32 random() {
sal_Int32 n;
rtlRandomPool pool = rtl_random_createPool();
- rtl_random_getBytes(pool, &n, sizeof n);
+ (void)rtl_random_getBytes(pool, &n, sizeof n);
rtl_random_destroyPool(pool);
return n;
}
@@ -129,7 +130,7 @@ AttachThread::~AttachThread() {
class PopOutgoingRequest {
public:
PopOutgoingRequest(
- OutgoingRequests & requests, rtl::ByteSequence const & tid,
+ OutgoingRequests & requests, rtl::ByteSequence tid,
OutgoingRequest const & request);
~PopOutgoingRequest();
@@ -146,9 +147,9 @@ private:
};
PopOutgoingRequest::PopOutgoingRequest(
- OutgoingRequests & requests, rtl::ByteSequence const & tid,
+ OutgoingRequests & requests, rtl::ByteSequence tid,
OutgoingRequest const & request):
- requests_(requests), tid_(tid), cleared_(false)
+ requests_(requests), tid_(std::move(tid)), cleared_(false)
{
requests_.push(tid_, request);
}
@@ -172,11 +173,11 @@ struct Bridge::SubStub {
};
Bridge::Bridge(
- rtl::Reference< BridgeFactory > const & factory, OUString const & name,
+ rtl::Reference< BridgeFactory > const & factory, OUString name,
css::uno::Reference< css::connection::XConnection > const & connection,
- css::uno::Reference< css::bridge::XInstanceProvider > const & provider):
- factory_(factory), name_(name), connection_(connection),
- provider_(provider),
+ css::uno::Reference< css::bridge::XInstanceProvider > provider):
+ factory_(factory), name_(std::move(name)), connection_(connection),
+ provider_(std::move(provider)),
binaryUno_(UNO_LB_UNO),
cppToBinaryMapping_(CPPU_CURRENT_LANGUAGE_BINDING_NAME, UNO_LB_UNO),
binaryToCppMapping_(UNO_LB_UNO, CPPU_CURRENT_LANGUAGE_BINDING_NAME),
@@ -201,13 +202,14 @@ Bridge::Bridge(
throw css::uno::RuntimeException("URP: no C++ UNO mapping");
}
passive_.set();
+ // coverity[uninit_member] - random_ is set in due course by the reader_ thread's state machine
}
void Bridge::start() {
rtl::Reference r(new Reader(this));
rtl::Reference w(new Writer(this));
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(
state_ == STATE_INITIAL && threadPool_ == nullptr && !writer_.is() &&
!reader_.is());
@@ -237,7 +239,7 @@ void Bridge::terminate(bool final) {
bool joinW;
Listeners ls;
{
- osl::ClearableMutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
switch (state_) {
case STATE_INITIAL: // via ~Bridge -> dispose -> terminate
case STATE_FINAL:
@@ -246,10 +248,10 @@ void Bridge::terminate(bool final) {
break;
case STATE_TERMINATED:
if (final) {
- g.clear();
+ g.unlock();
terminated_.wait();
{
- osl::MutexGuard g2(mutex_);
+ std::lock_guard g2(mutex_);
tp = threadPool_;
threadPool_ = nullptr;
if (reader_.is()) {
@@ -309,7 +311,7 @@ void Bridge::terminate(bool final) {
uno_threadpool_dispose(tp);
Stubs s;
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
s.swap(stubs_);
}
for (auto & stub : s)
@@ -330,7 +332,7 @@ void Bridge::terminate(bool final) {
try {
listener->disposing(
css::lang::EventObject(
- static_cast< cppu::OWeakObject * >(this)));
+ getXWeak()));
} catch (const css::uno::RuntimeException & e) {
SAL_WARN("binaryurp", "caught " << e);
}
@@ -340,7 +342,7 @@ void Bridge::terminate(bool final) {
uno_threadpool_destroy(tp);
}
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
if (final) {
threadPool_ = nullptr;
}
@@ -361,14 +363,14 @@ BinaryAny Bridge::mapCppToBinaryAny(css::uno::Any const & cppAny) {
}
uno_ThreadPool Bridge::getThreadPool() {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
checkDisposed();
assert(threadPool_ != nullptr);
return threadPool_;
}
rtl::Reference< Writer > Bridge::getWriter() {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
checkDisposed();
assert(writer_.is());
return writer_;
@@ -392,7 +394,7 @@ css::uno::UnoInterfaceReference Bridge::registerIncomingInterface(
} else {
obj.set(new Proxy(this, oid, type), SAL_NO_ACQUIRE);
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(proxies_ < std::numeric_limits< std::size_t >::max());
++proxies_;
}
@@ -419,7 +421,7 @@ OUString Bridge::registerOutgoingInterface(
if (!Proxy::isProxy(this, object, &oid)) {
binaryUno_.get()->pExtEnv->getObjectIdentifier(
binaryUno_.get()->pExtEnv, &oid.pData, object.get());
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
Stubs::iterator i(stubs_.find(oid));
Stub newStub;
Stub * stub = i == stubs_.end() ? &newStub : &i->second;
@@ -458,7 +460,7 @@ css::uno::UnoInterfaceReference Bridge::findStub(
OUString const & oid, css::uno::TypeDescription const & type)
{
assert(!oid.isEmpty() && type.is());
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
Stubs::iterator i(stubs_.find(oid));
if (i != stubs_.end()) {
Stub::iterator j(i->second.find(type));
@@ -484,7 +486,7 @@ void Bridge::releaseStub(
css::uno::UnoInterfaceReference obj;
bool unused;
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
Stubs::iterator i(stubs_.find(oid));
if (i == stubs_.end()) {
throw css::uno::RuntimeException("URP: release unknown stub");
@@ -538,7 +540,7 @@ void Bridge::freeProxy(Proxy & proxy) {
}
bool unused;
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(proxies_ > 0);
--proxies_;
unused = becameUnused();
@@ -547,7 +549,7 @@ void Bridge::freeProxy(Proxy & proxy) {
}
void Bridge::incrementCalls(bool normalCall) noexcept {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(calls_ < std::numeric_limits< std::size_t >::max());
++calls_;
normalCall_ |= normalCall;
@@ -556,7 +558,7 @@ void Bridge::incrementCalls(bool normalCall) noexcept {
void Bridge::decrementCalls() {
bool unused;
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(calls_ > 0);
--calls_;
unused = becameUnused();
@@ -565,7 +567,7 @@ void Bridge::decrementCalls() {
}
void Bridge::incrementActiveCalls() noexcept {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(
activeCalls_ <= calls_ &&
activeCalls_ < std::numeric_limits< std::size_t >::max());
@@ -574,7 +576,7 @@ void Bridge::incrementActiveCalls() noexcept {
}
void Bridge::decrementActiveCalls() noexcept {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(activeCalls_ <= calls_ && activeCalls_ > 0);
--activeCalls_;
if (activeCalls_ == 0) {
@@ -610,7 +612,7 @@ bool Bridge::makeCall(
{
throw css::lang::DisposedException(
"Binary URP bridge disposed during call",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
*returnValue = resp->returnValue;
if (!resp->exception) {
@@ -673,7 +675,7 @@ void Bridge::handleRequestChangeReply(
if (n != exp) {
throw css::uno::RuntimeException(
"URP: requestChange reply with unexpected return value received",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
decrementCalls();
switch (exp) {
@@ -756,7 +758,7 @@ void Bridge::handleRequestChangeRequest(
default:
throw css::uno::RuntimeException(
"URP: unexpected requestChange request received",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
}
@@ -770,7 +772,7 @@ void Bridge::handleCommitChangeRequest(
css::uno::Sequence< css::bridge::ProtocolProperty > s;
[[maybe_unused]] bool ok = (mapBinaryToCppAny(inArguments[0]) >>= s);
assert(ok);
- for (const auto & pp : std::as_const(s)) {
+ for (const auto & pp : s) {
if (pp.Name == "CurrentContext") {
bCcMode = true;
} else {
@@ -807,7 +809,7 @@ void Bridge::handleCommitChangeRequest(
default:
throw css::uno::RuntimeException(
"URP: unexpected commitChange request received",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
}
@@ -824,19 +826,19 @@ bool Bridge::isProtocolPropertiesRequest(
}
void Bridge::setCurrentContextMode() {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
currentContextMode_ = true;
}
bool Bridge::isCurrentContextMode() {
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
return currentContextMode_;
}
Bridge::~Bridge() {
#if OSL_DEBUG_LEVEL > 0
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
SAL_WARN_IF(
state_ == STATE_STARTED || state_ == STATE_TERMINATED, "binaryurp",
"undisposed bridge \"" << name_ <<"\" in state " << state_
@@ -852,7 +854,7 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance(
if (sInstanceName.isEmpty()) {
throw css::uno::RuntimeException(
"XBridge::getInstance sInstanceName must be non-empty",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
for (sal_Int32 i = 0; i != sInstanceName.getLength(); ++i) {
if (sInstanceName[i] > 0x7F) {
@@ -925,7 +927,7 @@ void Bridge::addEventListener(
{
assert(xListener.is());
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
assert(state_ != STATE_INITIAL);
if (state_ == STATE_STARTED) {
listeners_.push_back(xListener);
@@ -933,13 +935,13 @@ void Bridge::addEventListener(
}
}
xListener->disposing(
- css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
+ css::lang::EventObject(getXWeak()));
}
void Bridge::removeEventListener(
css::uno::Reference< css::lang::XEventListener > const & aListener)
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
Listeners::iterator i(
std::find(listeners_.begin(), listeners_.end(), aListener));
if (i != listeners_.end()) {
@@ -991,7 +993,7 @@ void Bridge::makeReleaseCall(
// its own:
static auto const tid = [] {
static sal_Int8 const id[] = {'r', 'e', 'l', 'e', 'a', 's', 'e', 'h', 'a', 'c', 'k'};
- return rtl::ByteSequence(id, SAL_N_ELEMENTS(id));
+ return rtl::ByteSequence(id, std::size(id));
}();
sendRequest(
tid, oid, type,
@@ -1043,7 +1045,7 @@ void Bridge::checkDisposed() {
if (state_ != STATE_STARTED) {
throw css::lang::DisposedException(
"Binary URP bridge already disposed",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
}
diff --git a/binaryurp/source/bridge.hxx b/binaryurp/source/bridge.hxx
index fa9c2c5abdc3..9da6640fa126 100644
--- a/binaryurp/source/bridge.hxx
+++ b/binaryurp/source/bridge.hxx
@@ -23,6 +23,7 @@
#include <cstddef>
#include <map>
+#include <mutex>
#include <vector>
#include <com/sun/star/bridge/XBridge.hpp>
@@ -70,11 +71,11 @@ class Bridge:
public:
Bridge(
rtl::Reference< BridgeFactory > const & factory,
- OUString const & name,
+ OUString name,
com::sun::star::uno::Reference<
com::sun::star::connection::XConnection > const & connection,
com::sun::star::uno::Reference<
- com::sun::star::bridge::XInstanceProvider > const & provider);
+ com::sun::star::bridge::XInstanceProvider > provider);
void start();
@@ -257,7 +258,7 @@ private:
// decrementActiveCalls, without an intervening exception
osl::Condition terminated_;
- osl::Mutex mutex_;
+ std::mutex mutex_;
State state_;
Listeners listeners_;
uno_ThreadPool threadPool_;
diff --git a/binaryurp/source/bridgefactory.cxx b/binaryurp/source/bridgefactory.cxx
index a2dd1fa97fba..cd43fe592b0e 100644
--- a/binaryurp/source/bridgefactory.cxx
+++ b/binaryurp/source/bridgefactory.cxx
@@ -49,7 +49,7 @@ void BridgeFactory::removeBridge(
osl::MutexGuard g(m_aMutex);
if (n.isEmpty())
{
- unnamed_.erase(std::remove(unnamed_.begin(), unnamed_.end(), bridge), unnamed_.end());
+ std::erase(unnamed_, bridge);
}
else
{
@@ -93,17 +93,17 @@ css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge(
if (rBHelper.bDisposed) {
throw css::lang::DisposedException(
"BridgeFactory disposed",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
if (named_.find(sName) != named_.end()) {
throw css::bridge::BridgeExistsException(
- sName, static_cast< cppu::OWeakObject * >(this));
+ sName, getXWeak());
}
if (sProtocol != "urp" || !aConnection.is()) {
throw css::lang::IllegalArgumentException(
("BridgeFactory::createBridge: sProtocol != urp ||"
" aConnection == null"),
- static_cast< cppu::OWeakObject * >(this), -1);
+ getXWeak(), -1);
}
b.set(new Bridge(this, sName, aConnection, anInstanceProvider));
if (sName.isEmpty()) {
@@ -131,13 +131,13 @@ BridgeFactory::getExistingBridges() {
if (unnamed_.size() > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
"BridgeFactory::getExistingBridges: too many",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
sal_Int32 n = static_cast< sal_Int32 >(unnamed_.size());
if (named_.size() > o3tl::make_unsigned(SAL_MAX_INT32 - n)) {
throw css::uno::RuntimeException(
"BridgeFactory::getExistingBridges: too many",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
n = static_cast< sal_Int32 >(n + named_.size());
css::uno::Sequence< css::uno::Reference< css::bridge::XBridge > > s(n);
diff --git a/binaryurp/source/incomingreply.hxx b/binaryurp/source/incomingreply.hxx
index 420c5169adde..c2f5353fff4c 100644
--- a/binaryurp/source/incomingreply.hxx
+++ b/binaryurp/source/incomingreply.hxx
@@ -21,6 +21,7 @@
#include <sal/config.h>
+#include <utility>
#include <vector>
#include "binaryany.hxx"
@@ -33,9 +34,9 @@ private:
IncomingReply& operator=(const IncomingReply&) = delete;
public:
IncomingReply(
- bool theException, BinaryAny const & theReturnValue,
+ bool theException, BinaryAny theReturnValue,
std::vector< BinaryAny >&& theOutArguments):
- exception(theException), returnValue(theReturnValue),
+ exception(theException), returnValue(std::move(theReturnValue)),
outArguments(std::move(theOutArguments))
{}
diff --git a/binaryurp/source/incomingrequest.cxx b/binaryurp/source/incomingrequest.cxx
index d75a61e46245..6f4107693b73 100644
--- a/binaryurp/source/incomingrequest.cxx
+++ b/binaryurp/source/incomingrequest.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <cassert>
+#include <utility>
#include <vector>
#include <com/sun/star/bridge/XInstanceProvider.hpp>
@@ -43,14 +44,14 @@
namespace binaryurp {
IncomingRequest::IncomingRequest(
- rtl::Reference< Bridge > const & bridge, rtl::ByteSequence const & tid,
- OUString const & oid, css::uno::UnoInterfaceReference const & object,
- css::uno::TypeDescription const & type, sal_uInt16 functionId,
+ rtl::Reference< Bridge > const & bridge, rtl::ByteSequence tid,
+ OUString oid, css::uno::UnoInterfaceReference object,
+ css::uno::TypeDescription type, sal_uInt16 functionId,
bool synchronous, css::uno::TypeDescription const & member, bool setter,
std::vector< BinaryAny >&& inArguments, bool currentContextMode,
- css::uno::UnoInterfaceReference const & currentContext):
- bridge_(bridge), tid_(tid), oid_(oid), object_(object), type_(type),
- member_(member), currentContext_(currentContext),
+ css::uno::UnoInterfaceReference currentContext):
+ bridge_(bridge), tid_(std::move(tid)), oid_(std::move(oid)), object_(std::move(object)), type_(std::move(type)),
+ member_(member), currentContext_(std::move(currentContext)),
inArguments_(std::move(inArguments)), functionId_(functionId),
synchronous_(synchronous), setter_(setter), currentContextMode_(currentContextMode)
{
diff --git a/binaryurp/source/incomingrequest.hxx b/binaryurp/source/incomingrequest.hxx
index 0423a04b6728..faff4f5a5c0c 100644
--- a/binaryurp/source/incomingrequest.hxx
+++ b/binaryurp/source/incomingrequest.hxx
@@ -43,14 +43,14 @@ private:
IncomingRequest& operator=(const IncomingRequest&) = delete;
public:
IncomingRequest(
- rtl::Reference< Bridge > const & bridge, rtl::ByteSequence const & tid,
- OUString const & oid,
- com::sun::star::uno::UnoInterfaceReference const & object,
- com::sun::star::uno::TypeDescription const & type,
+ rtl::Reference< Bridge > const & bridge, rtl::ByteSequence tid,
+ OUString oid,
+ com::sun::star::uno::UnoInterfaceReference object,
+ com::sun::star::uno::TypeDescription type,
sal_uInt16 functionId, bool synchronous,
com::sun::star::uno::TypeDescription const & member, bool setter,
std::vector< BinaryAny >&& inArguments, bool currentContextMode,
- com::sun::star::uno::UnoInterfaceReference const & currentContext);
+ com::sun::star::uno::UnoInterfaceReference currentContext);
~IncomingRequest();
diff --git a/binaryurp/source/outgoingrequest.hxx b/binaryurp/source/outgoingrequest.hxx
index eb2c8a7e5212..efa673eac781 100644
--- a/binaryurp/source/outgoingrequest.hxx
+++ b/binaryurp/source/outgoingrequest.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
#include <typelib/typedescription.hxx>
+#include <utility>
namespace binaryurp {
@@ -29,9 +30,9 @@ struct OutgoingRequest {
enum Kind { KIND_NORMAL, KIND_REQUEST_CHANGE, KIND_COMMIT_CHANGE };
OutgoingRequest(
- Kind theKind, com::sun::star::uno::TypeDescription const & theMember,
+ Kind theKind, com::sun::star::uno::TypeDescription theMember,
bool theSetter):
- member(theMember), kind(theKind), setter(theSetter)
+ member(std::move(theMember)), kind(theKind), setter(theSetter)
{}
com::sun::star::uno::TypeDescription member;
diff --git a/binaryurp/source/proxy.cxx b/binaryurp/source/proxy.cxx
index 7602800cb34e..49705e06aa89 100644
--- a/binaryurp/source/proxy.cxx
+++ b/binaryurp/source/proxy.cxx
@@ -21,6 +21,7 @@
#include <cassert>
#include <exception>
+#include <utility>
#include <vector>
#include <cppuhelper/exc_hlp.hxx>
@@ -64,9 +65,9 @@ extern "C" void proxy_dispatchInterface(
}
Proxy::Proxy(
- rtl::Reference< Bridge > const & bridge, OUString const & oid,
- css::uno::TypeDescription const & type):
- bridge_(bridge), oid_(oid), type_(type), references_(1)
+ rtl::Reference< Bridge > const & bridge, OUString oid,
+ css::uno::TypeDescription type):
+ bridge_(bridge), oid_(std::move(oid)), type_(std::move(type)), references_(1)
{
assert(bridge.is());
acquire = &proxy_acquireInterface;
diff --git a/binaryurp/source/proxy.hxx b/binaryurp/source/proxy.hxx
index cf9e1262a8c3..4e1fa3656ecc 100644
--- a/binaryurp/source/proxy.hxx
+++ b/binaryurp/source/proxy.hxx
@@ -39,8 +39,8 @@ namespace binaryurp {
class Proxy: public uno_Interface {
public:
Proxy(
- rtl::Reference< Bridge > const & bridge, OUString const & oid,
- com::sun::star::uno::TypeDescription const & type);
+ rtl::Reference< Bridge > const & bridge, OUString oid,
+ com::sun::star::uno::TypeDescription type);
const OUString& getOid() const { return oid_;}
diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx
index 91f2e51a0f25..393d8312e43a 100644
--- a/binaryurp/source/reader.cxx
+++ b/binaryurp/source/reader.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/uno/XCurrentContext.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <cppu/unotype.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/byteseq.h>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -70,11 +71,11 @@ css::uno::Sequence< sal_Int8 > read(
if (n == 0 && eofOk) {
return css::uno::Sequence< sal_Int8 >();
}
- if (n != static_cast< sal_Int32 >(size)) {
+ if (o3tl::make_unsigned(n) != size) {
throw css::io::IOException(
"binaryurp::Reader: premature end of input");
}
- assert(buf.getLength() == static_cast< sal_Int32 >(size));
+ assert(o3tl::make_unsigned(buf.getLength()) == size);
return buf;
}
@@ -337,6 +338,7 @@ void Reader::readMessage(Unmarshal & unmarshal) {
uno_threadpool_putJob(
bridge_->getThreadPool(), tid.getHandle(), req.get(), &request,
!synchronous);
+ // coverity[leaked_storage] - "request" destroys req when executed
req.release();
}
}
@@ -445,6 +447,7 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) {
uno_threadpool_putJob(
bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr,
false);
+ // coverity[leaked_storage] - "Bridge::makeCall" destroys resp when received
resp.release();
break;
}
diff --git a/binaryurp/source/unmarshal.cxx b/binaryurp/source/unmarshal.cxx
index 4263edf8c91c..7d943d37b704 100644
--- a/binaryurp/source/unmarshal.cxx
+++ b/binaryurp/source/unmarshal.cxx
@@ -22,6 +22,7 @@
#include <cassert>
#include <cstdlib>
#include <new>
+#include <utility>
#include <vector>
#include <com/sun/star/io/IOException.hpp>
@@ -90,9 +91,9 @@ std::vector< BinaryAny >::iterator copyMemberValues(
}
Unmarshal::Unmarshal(
- rtl::Reference< Bridge > const & bridge, ReaderState & state,
+ rtl::Reference< Bridge > bridge, ReaderState & state,
css::uno::Sequence< sal_Int8 > const & buffer):
- bridge_(bridge), state_(state), buffer_(buffer)
+ bridge_(std::move(bridge)), state_(state), buffer_(buffer)
{
data_ = reinterpret_cast< sal_uInt8 const * >(buffer_.getConstArray());
end_ = data_ + buffer_.getLength();
diff --git a/binaryurp/source/unmarshal.hxx b/binaryurp/source/unmarshal.hxx
index c5b91eebb07a..1972c30d0e74 100644
--- a/binaryurp/source/unmarshal.hxx
+++ b/binaryurp/source/unmarshal.hxx
@@ -40,7 +40,7 @@ namespace binaryurp {
class Unmarshal {
public:
Unmarshal(
- rtl::Reference< Bridge > const & bridge, ReaderState & state,
+ rtl::Reference< Bridge > bridge, ReaderState & state,
com::sun::star::uno::Sequence< sal_Int8 > const & buffer);
~Unmarshal();
diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx
index 250e251e8296..539d8a2c532f 100644
--- a/binaryurp/source/writer.cxx
+++ b/binaryurp/source/writer.cxx
@@ -24,6 +24,7 @@
#include <cstring>
#include <exception>
#include <limits>
+#include <utility>
#include <vector>
#include <com/sun/star/connection/XConnection.hpp>
@@ -31,7 +32,6 @@
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/uno/XCurrentContext.hpp>
#include <cppuhelper/exc_hlp.hxx>
-#include <osl/mutex.hxx>
#include <sal/log.hxx>
#include <uno/dispatcher.hxx>
@@ -51,24 +51,24 @@ Writer::Item::Item()
{}
Writer::Item::Item(
- rtl::ByteSequence const & theTid, OUString const & theOid,
- css::uno::TypeDescription const & theType,
- css::uno::TypeDescription const & theMember,
+ rtl::ByteSequence theTid, OUString theOid,
+ css::uno::TypeDescription theType,
+ css::uno::TypeDescription theMember,
std::vector< BinaryAny >&& inArguments,
- css::uno::UnoInterfaceReference const & theCurrentContext):
- tid(theTid), oid(theOid), type(theType), member(theMember),
- currentContext(theCurrentContext), arguments(std::move(inArguments)),
+ css::uno::UnoInterfaceReference theCurrentContext):
+ tid(std::move(theTid)), oid(std::move(theOid)), type(std::move(theType)), member(std::move(theMember)),
+ currentContext(std::move(theCurrentContext)), arguments(std::move(inArguments)),
request(true), setter(false), exception(false), setCurrentContextMode(false)
{}
Writer::Item::Item(
- rtl::ByteSequence const & theTid,
- css::uno::TypeDescription const & theMember, bool theSetter,
- bool theException, BinaryAny const & theReturnValue,
+ rtl::ByteSequence theTid,
+ css::uno::TypeDescription theMember, bool theSetter,
+ bool theException, BinaryAny theReturnValue,
std::vector< BinaryAny >&& outArguments,
bool theSetCurrentContextMode):
- tid(theTid), member(theMember),
- returnValue(theReturnValue), arguments(std::move(outArguments)),
+ tid(std::move(theTid)), member(std::move(theMember)),
+ returnValue(std::move(theReturnValue)), arguments(std::move(outArguments)),
request(false), setter(theSetter),
exception(theException), setCurrentContextMode(theSetCurrentContextMode)
{}
@@ -108,7 +108,7 @@ void Writer::queueRequest(
std::vector< BinaryAny >&& inArguments)
{
css::uno::UnoInterfaceReference cc(current_context::get());
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
queue_.emplace_back(tid, oid, type, member, std::move(inArguments), cc);
items_.set();
}
@@ -119,7 +119,7 @@ void Writer::queueReply(
bool exception, BinaryAny const & returnValue,
std::vector< BinaryAny >&& outArguments, bool setCurrentContextMode)
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
queue_.emplace_back(
tid, member, setter, exception, returnValue, std::move(outArguments),
setCurrentContextMode);
@@ -135,7 +135,7 @@ void Writer::unblock() {
void Writer::stop() {
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
stop_ = true;
}
unblocked_.set();
@@ -151,7 +151,7 @@ void Writer::execute() {
items_.wait();
Item item;
{
- osl::MutexGuard g(mutex_);
+ std::lock_guard g(mutex_);
if (stop_) {
return;
}
diff --git a/binaryurp/source/writer.hxx b/binaryurp/source/writer.hxx
index 42656000d0e3..e2061502a015 100644
--- a/binaryurp/source/writer.hxx
+++ b/binaryurp/source/writer.hxx
@@ -22,10 +22,10 @@
#include <sal/config.h>
#include <deque>
+#include <mutex>
#include <vector>
#include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
#include <rtl/byteseq.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
@@ -104,18 +104,17 @@ private:
// Request:
Item(
- rtl::ByteSequence const & theTid, OUString const & theOid,
- com::sun::star::uno::TypeDescription const & theType,
- com::sun::star::uno::TypeDescription const & theMember,
+ rtl::ByteSequence theTid, OUString theOid,
+ com::sun::star::uno::TypeDescription theType,
+ com::sun::star::uno::TypeDescription theMember,
std::vector< BinaryAny >&& inArguments,
- com::sun::star::uno::UnoInterfaceReference const &
- theCurrentContext);
+ com::sun::star::uno::UnoInterfaceReference theCurrentContext);
// Reply:
Item(
- rtl::ByteSequence const & theTid,
- com::sun::star::uno::TypeDescription const & theMember,
- bool theSetter, bool theException, BinaryAny const & theReturnValue,
+ rtl::ByteSequence theTid,
+ com::sun::star::uno::TypeDescription theMember,
+ bool theSetter, bool theException, BinaryAny theReturnValue,
std::vector< BinaryAny >&& outArguments,
bool theSetCurrentContextMode);
@@ -141,7 +140,7 @@ private:
osl::Condition unblocked_;
osl::Condition items_;
- osl::Mutex mutex_;
+ std::mutex mutex_;
std::deque< Item > queue_;
bool stop_;
};