loplugin:ostr in binaryurp

Change-Id: I8fbb3a64cd101f219408103a771e1197e1e69776
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167203
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2024-05-06 15:15:34 +02:00
parent 171f984c90
commit 14cca2c88f
8 changed files with 77 additions and 77 deletions

View File

@@ -178,28 +178,28 @@ Bridge::Bridge(
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),
binaryUno_(u"" UNO_LB_UNO ""_ustr),
cppToBinaryMapping_(CPPU_CURRENT_LANGUAGE_BINDING_NAME, u"" UNO_LB_UNO ""_ustr),
binaryToCppMapping_(u"" UNO_LB_UNO ""_ustr, CPPU_CURRENT_LANGUAGE_BINDING_NAME),
protPropTid_(
reinterpret_cast< sal_Int8 const * >(".UrpProtocolPropertiesTid"),
RTL_CONSTASCII_LENGTH(".UrpProtocolPropertiesTid")),
protPropOid_("UrpProtocolProperties"),
protPropOid_(u"UrpProtocolProperties"_ustr),
protPropType_(
cppu::UnoType<
css::uno::Reference< css::bridge::XProtocolProperties > >::get()),
protPropRequest_("com.sun.star.bridge.XProtocolProperties::requestChange"),
protPropCommit_("com.sun.star.bridge.XProtocolProperties::commitChange"),
protPropRequest_(u"com.sun.star.bridge.XProtocolProperties::requestChange"_ustr),
protPropCommit_(u"com.sun.star.bridge.XProtocolProperties::commitChange"_ustr),
state_(STATE_INITIAL), threadPool_(nullptr), currentContextMode_(false),
proxies_(0), calls_(0), normalCall_(false), activeCalls_(0),
mode_(MODE_REQUESTED)
{
assert(factory.is() && connection.is());
if (!binaryUno_.is()) {
throw css::uno::RuntimeException("URP: no binary UNO environment");
throw css::uno::RuntimeException(u"URP: no binary UNO environment"_ustr);
}
if (!(cppToBinaryMapping_.is() && binaryToCppMapping_.is())) {
throw css::uno::RuntimeException("URP: no C++ UNO mapping");
throw css::uno::RuntimeException(u"URP: no C++ UNO mapping"_ustr);
}
passive_.set();
// coverity[uninit_member] - random_ is set in due course by the reader_ thread's state machine
@@ -448,7 +448,7 @@ OUString Bridge::registerOutgoingInterface(
assert(stub != &newStub);
if (j->second.references == SAL_MAX_UINT32) {
throw css::uno::RuntimeException(
"URP: stub reference count overflow");
u"URP: stub reference count overflow"_ustr);
}
++j->second.references;
}
@@ -489,11 +489,11 @@ void Bridge::releaseStub(
std::lock_guard g(mutex_);
Stubs::iterator i(stubs_.find(oid));
if (i == stubs_.end()) {
throw css::uno::RuntimeException("URP: release unknown stub");
throw css::uno::RuntimeException(u"URP: release unknown stub"_ustr);
}
Stub::iterator j(i->second.find(type));
if (j == i->second.end()) {
throw css::uno::RuntimeException("URP: release unknown stub");
throw css::uno::RuntimeException(u"URP: release unknown stub"_ustr);
}
assert(j->second.references > 0);
--j->second.references;
@@ -611,7 +611,7 @@ bool Bridge::makeCall(
if (resp == nullptr)
{
throw css::lang::DisposedException(
"Binary URP bridge disposed during call",
u"Binary URP bridge disposed during call"_ustr,
getXWeak());
}
*returnValue = resp->returnValue;
@@ -674,7 +674,7 @@ void Bridge::handleRequestChangeReply(
}
if (n != exp) {
throw css::uno::RuntimeException(
"URP: requestChange reply with unexpected return value received",
u"URP: requestChange reply with unexpected return value received"_ustr,
getXWeak());
}
decrementCalls();
@@ -757,7 +757,7 @@ void Bridge::handleRequestChangeRequest(
}
default:
throw css::uno::RuntimeException(
"URP: unexpected requestChange request received",
u"URP: unexpected requestChange request received"_ustr,
getXWeak());
}
}
@@ -781,7 +781,7 @@ void Bridge::handleCommitChangeRequest(
ret = mapCppToBinaryAny(
css::uno::Any(
css::bridge::InvalidProtocolChangeException(
"InvalidProtocolChangeException",
u"InvalidProtocolChangeException"_ustr,
css::uno::Reference< css::uno::XInterface >(), pp,
1)));
break;
@@ -808,7 +808,7 @@ void Bridge::handleCommitChangeRequest(
break;
default:
throw css::uno::RuntimeException(
"URP: unexpected commitChange request received",
u"URP: unexpected commitChange request received"_ustr,
getXWeak());
}
}
@@ -853,14 +853,14 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance(
{
if (sInstanceName.isEmpty()) {
throw css::uno::RuntimeException(
"XBridge::getInstance sInstanceName must be non-empty",
u"XBridge::getInstance sInstanceName must be non-empty"_ustr,
getXWeak());
}
for (sal_Int32 i = 0; i != sInstanceName.getLength(); ++i) {
if (sInstanceName[i] > 0x7F) {
throw css::uno::RuntimeException(
"XBridge::getInstance sInstanceName contains non-ASCII"
" character");
u"XBridge::getInstance sInstanceName contains non-ASCII"
" character"_ustr);
}
}
css::uno::TypeDescription ifc(cppu::UnoType<css::uno::XInterface>::get());
@@ -874,7 +874,7 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance(
bool bExc = makeCall(
sInstanceName,
css::uno::TypeDescription(
"com.sun.star.uno.XInterface::queryInterface"),
u"com.sun.star.uno.XInterface::queryInterface"_ustr),
false, std::move(inArgs), &ret, &outArgs);
throwException(bExc, ret);
auto const t = ret.getType();
@@ -997,7 +997,7 @@ void Bridge::makeReleaseCall(
}();
sendRequest(
tid, oid, type,
css::uno::TypeDescription("com.sun.star.uno.XInterface::release"),
css::uno::TypeDescription(u"com.sun.star.uno.XInterface::release"_ustr),
std::vector< BinaryAny >());
}
@@ -1044,7 +1044,7 @@ void Bridge::checkDisposed() {
assert(state_ != STATE_INITIAL);
if (state_ != STATE_STARTED) {
throw css::lang::DisposedException(
"Binary URP bridge already disposed",
u"Binary URP bridge already disposed"_ustr,
getXWeak());
}
}

View File

@@ -68,7 +68,7 @@ BridgeFactory::~BridgeFactory() {}
OUString BridgeFactory::getImplementationName()
{
return "com.sun.star.comp.bridge.BridgeFactory";
return u"com.sun.star.comp.bridge.BridgeFactory"_ustr;
}
sal_Bool BridgeFactory::supportsService(OUString const & ServiceName)
@@ -78,7 +78,7 @@ sal_Bool BridgeFactory::supportsService(OUString const & ServiceName)
css::uno::Sequence< OUString > BridgeFactory::getSupportedServiceNames()
{
return { "com.sun.star.bridge.BridgeFactory" };
return { u"com.sun.star.bridge.BridgeFactory"_ustr };
}
css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge(
@@ -92,7 +92,7 @@ css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge(
osl::MutexGuard g(m_aMutex);
if (rBHelper.bDisposed) {
throw css::lang::DisposedException(
"BridgeFactory disposed",
u"BridgeFactory disposed"_ustr,
getXWeak());
}
if (named_.find(sName) != named_.end()) {
@@ -101,8 +101,8 @@ css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge(
}
if (sProtocol != "urp" || !aConnection.is()) {
throw css::lang::IllegalArgumentException(
("BridgeFactory::createBridge: sProtocol != urp ||"
" aConnection == null"),
(u"BridgeFactory::createBridge: sProtocol != urp ||"
" aConnection == null"_ustr),
getXWeak(), -1);
}
b.set(new Bridge(this, sName, aConnection, anInstanceProvider));
@@ -130,13 +130,13 @@ BridgeFactory::getExistingBridges() {
osl::MutexGuard g(m_aMutex);
if (unnamed_.size() > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
"BridgeFactory::getExistingBridges: too many",
u"BridgeFactory::getExistingBridges: too many"_ustr,
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",
u"BridgeFactory::getExistingBridges: too many"_ustr,
getXWeak());
}
n = static_cast< sal_Int32 >(n + named_.size());

View File

@@ -33,9 +33,9 @@ css::uno::UnoInterfaceReference get() {
css::uno::UnoInterfaceReference cc;
if (!uno_getCurrentContext(
reinterpret_cast< void ** >(&cc.m_pUnoI),
OUString(UNO_LB_UNO).pData, nullptr))
u"" UNO_LB_UNO ""_ustr.pData, nullptr))
{
throw css::uno::RuntimeException("uno_getCurrentContext failed");
throw css::uno::RuntimeException(u"uno_getCurrentContext failed"_ustr);
}
return cc;
}
@@ -44,9 +44,9 @@ void set(css::uno::UnoInterfaceReference const & value) {
css::uno::UnoInterfaceReference cc(value);
if (!uno_setCurrentContext(
cc.m_pUnoI,
OUString(UNO_LB_UNO).pData, nullptr))
u"" UNO_LB_UNO ""_ustr.pData, nullptr))
{
throw css::uno::RuntimeException("uno_setCurrentContext failed");
throw css::uno::RuntimeException(u"uno_setCurrentContext failed"_ustr);
}
}

View File

@@ -78,7 +78,7 @@ void writeString(
RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
{
throw css::uno::RuntimeException(
"UNO string contains invalid UTF-16 sequence");
u"UNO string contains invalid UTF-16 sequence"_ustr);
}
writeCompressed(buffer, static_cast< sal_uInt32 >(v.getLength()));
buffer->insert(buffer->end(), v.getStr(), v.getStr() + v.getLength());

View File

@@ -46,7 +46,7 @@ OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) {
Map::iterator i(map_.find(tid));
if (i == map_.end()) {
throw css::uno::RuntimeException(
"URP: reply for unknown TID");
u"URP: reply for unknown TID"_ustr);
}
assert(!i->second.empty());
return i->second.back();

View File

@@ -64,7 +64,7 @@ css::uno::Sequence< sal_Int8 > read(
assert(connection.is());
if (size > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
"binaryurp::Reader: block size too large");
u"binaryurp::Reader: block size too large"_ustr);
}
css::uno::Sequence< sal_Int8 > buf;
sal_Int32 n = connection->read(buf, static_cast< sal_Int32 >(size));
@@ -73,7 +73,7 @@ css::uno::Sequence< sal_Int8 > read(
}
if (o3tl::make_unsigned(n) != size) {
throw css::io::IOException(
"binaryurp::Reader: premature end of input");
u"binaryurp::Reader: premature end of input"_ustr);
}
assert(o3tl::make_unsigned(buf.getLength()) == size);
return buf;
@@ -112,7 +112,7 @@ void Reader::execute() {
header.done();
if (count == 0) {
throw css::io::IOException(
"binaryurp::Reader: block with zero message count received");
u"binaryurp::Reader: block with zero message count received"_ustr);
}
Unmarshal block(bridge_, state_, read(con, size, false));
for (sal_uInt32 i = 0; i != count; ++i) {
@@ -150,8 +150,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
if (((flags2 & 0x40) != 0) != forceSynchronous) {
// bit 6: SYNCHRONOUS
throw css::uno::RuntimeException(
"URP: request message with MUSTREPLY != SYNCHRONOUS"
" received");
u"URP: request message with MUSTREPLY != SYNCHRONOUS"
" received"_ustr);
}
} else {
forceSynchronous = false;
@@ -173,8 +173,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
} else {
if (!lastType_.is()) {
throw css::uno::RuntimeException(
"URP: request message with NEWTYPE received when last"
" interface type has not yet been set");
u"URP: request message with NEWTYPE received when last"
" interface type has not yet been set"_ustr);
}
type = lastType_;
}
@@ -183,14 +183,14 @@ void Reader::readMessage(Unmarshal & unmarshal) {
oid = unmarshal.readOid();
if (oid.isEmpty()) {
throw css::io::IOException(
"binaryurp::Unmarshal: empty OID");
u"binaryurp::Unmarshal: empty OID"_ustr);
}
lastOid_ = oid;
} else {
if (lastOid_.isEmpty()) {
throw css::uno::RuntimeException(
"URP: request message with NEWOID received when last OID has"
" not yet been set");
u"URP: request message with NEWOID received when last OID has"
" not yet been set"_ustr);
}
oid = lastOid_;
}
@@ -199,13 +199,13 @@ void Reader::readMessage(Unmarshal & unmarshal) {
type.makeComplete();
if (type.get()->eTypeClass != typelib_TypeClass_INTERFACE) {
throw css::uno::RuntimeException(
"URP: request message with non-interface interface type received");
u"URP: request message with non-interface interface type received"_ustr);
}
typelib_InterfaceTypeDescription * itd =
reinterpret_cast< typelib_InterfaceTypeDescription * >(type.get());
if (functionId >= itd->nMapFunctionIndexToMemberIndex) {
throw css::uno::RuntimeException(
"URP: request message with unknown function ID received");
u"URP: request message with unknown function ID received"_ustr);
}
sal_Int32 memberId = itd->pMapFunctionIndexToMemberIndex[functionId];
css::uno::TypeDescription memberTd(itd->ppAllMembers[memberId]);
@@ -280,8 +280,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
break;
default:
throw css::uno::RuntimeException(
"URP: request message with UrpProtocolProperties OID and"
" unknown function ID received");
u"URP: request message with UrpProtocolProperties OID and"
" unknown function ID received"_ustr);
}
} else {
css::uno::UnoInterfaceReference obj;
@@ -317,14 +317,14 @@ void Reader::readMessage(Unmarshal & unmarshal) {
break;
case SPECIAL_FUNCTION_ID_RESERVED:
throw css::uno::RuntimeException(
"URP: request message with unknown function ID 1 received");
u"URP: request message with unknown function ID 1 received"_ustr);
case SPECIAL_FUNCTION_ID_RELEASE:
break;
default:
obj = bridge_->findStub(oid, type);
if (!obj.is()) {
throw css::uno::RuntimeException(
"URP: request message with unknown OID received");
u"URP: request message with unknown OID received"_ustr);
}
break;
}
@@ -401,7 +401,7 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) {
}
if (!bOk) {
throw css::uno::RuntimeException(
"URP: reply message with bad exception type received");
u"URP: reply message with bad exception type received"_ustr);
}
}
} else {
@@ -471,8 +471,8 @@ rtl::ByteSequence Reader::getTid(Unmarshal & unmarshal, bool newTid) const {
}
if (lastTid_.getLength() == 0) {
throw css::uno::RuntimeException(
"URP: message with NEWTID received when last TID has not yet been"
" set");
u"URP: message with NEWTID received when last TID has not yet been"
" set"_ustr);
}
return lastTid_;
}

View File

@@ -141,7 +141,7 @@ css::uno::TypeDescription Unmarshal::readType() {
case typelib_TypeClass_ANY:
if ((flags & 0x80) != 0) {
throw css::io::IOException(
"binaryurp::Unmarshal: cache flag of simple type is set");
u"binaryurp::Unmarshal: cache flag of simple type is set"_ustr);
}
return css::uno::TypeDescription(
*typelib_static_type_getByTypeClass(tc));
@@ -155,7 +155,7 @@ css::uno::TypeDescription Unmarshal::readType() {
if ((flags & 0x80) == 0) {
if (idx == cache::ignore || !state_.typeCache[idx].is()) {
throw css::io::IOException(
"binaryurp::Unmarshal: unknown type cache index");
u"binaryurp::Unmarshal: unknown type cache index"_ustr);
}
return state_.typeCache[idx];
} else {
@@ -175,15 +175,15 @@ css::uno::TypeDescription Unmarshal::readType() {
t2.get())->pType);
if (!t2.is()) {
throw css::io::IOException(
"binaryurp::Unmarshal: sequence type with unknown"
" component type");
u"binaryurp::Unmarshal: sequence type with unknown"
" component type"_ustr);
}
switch (t2.get()->eTypeClass) {
case typelib_TypeClass_VOID:
case typelib_TypeClass_EXCEPTION:
throw css::io::IOException(
"binaryurp::Unmarshal: sequence type with bad"
" component type");
u"binaryurp::Unmarshal: sequence type with bad"
" component type"_ustr);
default:
break;
}
@@ -196,7 +196,7 @@ css::uno::TypeDescription Unmarshal::readType() {
}
default:
throw css::io::IOException(
"binaryurp::Unmarshal: type of unknown type class");
u"binaryurp::Unmarshal: type of unknown type class"_ustr);
}
}
@@ -205,14 +205,14 @@ OUString Unmarshal::readOid() {
for (sal_Int32 i = 0; i != oid.getLength(); ++i) {
if (oid[i] > 0x7F) {
throw css::io::IOException(
"binaryurp::Unmarshal: OID contains non-ASCII character");
u"binaryurp::Unmarshal: OID contains non-ASCII character"_ustr);
}
}
sal_uInt16 idx = readCacheIndex();
if (oid.isEmpty() && idx != cache::ignore) {
if (state_.oidCache[idx].isEmpty()) {
throw css::io::IOException(
"binaryurp::Unmarshal: unknown OID cache index");
u"binaryurp::Unmarshal: unknown OID cache index"_ustr);
}
return state_.oidCache[idx];
}
@@ -235,7 +235,7 @@ rtl::ByteSequence Unmarshal::readTid() {
if (tid.getLength() == 0) {
if (idx == cache::ignore || state_.tidCache[idx].getLength() == 0) {
throw css::io::IOException(
"binaryurp::Unmarshal: unknown TID cache index");
u"binaryurp::Unmarshal: unknown TID cache index"_ustr);
}
return state_.tidCache[idx];
}
@@ -258,7 +258,7 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) {
sal_uInt8 v = read8();
if (v > 1) {
throw css::io::IOException(
"binaryurp::Unmarshal: boolean of unknown value");
u"binaryurp::Unmarshal: boolean of unknown value"_ustr);
}
return BinaryAny(type, &v);
}
@@ -304,7 +304,7 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) {
css::uno::TypeDescription t(readType());
if (t.get()->eTypeClass == typelib_TypeClass_ANY) {
throw css::io::IOException(
"binaryurp::Unmarshal: any of type ANY");
u"binaryurp::Unmarshal: any of type ANY"_ustr);
}
return readValue(t);
}
@@ -326,7 +326,7 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) {
}
if (!bFound) {
throw css::io::IOException(
"binaryurp::Unmarshal: unknown enum value");
u"binaryurp::Unmarshal: unknown enum value"_ustr);
}
return BinaryAny(type, &v);
}
@@ -356,14 +356,14 @@ BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) {
void Unmarshal::done() const {
if (data_ != end_) {
throw css::io::IOException(
"binaryurp::Unmarshal: block contains excess data");
u"binaryurp::Unmarshal: block contains excess data"_ustr);
}
}
void Unmarshal::check(sal_Int32 size) const {
if (end_ - data_ < size) {
throw css::io::IOException(
"binaryurp::Unmarshal: trying to read past end of block");
u"binaryurp::Unmarshal: trying to read past end of block"_ustr);
}
}
@@ -376,7 +376,7 @@ sal_uInt16 Unmarshal::readCacheIndex() {
sal_uInt16 idx = read16();
if (idx >= cache::size && idx != cache::ignore) {
throw css::io::IOException(
"binaryurp::Unmarshal: cache index out of range");
u"binaryurp::Unmarshal: cache index out of range"_ustr);
}
return idx;
}
@@ -397,7 +397,7 @@ OUString Unmarshal::readString() {
sal_uInt32 n = readCompressed();
if (n > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
"binaryurp::Unmarshal: string size too large");
u"binaryurp::Unmarshal: string size too large"_ustr);
}
check(static_cast< sal_Int32 >(n));
OUString s;
@@ -409,7 +409,7 @@ OUString Unmarshal::readString() {
RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
{
throw css::io::IOException(
"binaryurp::Unmarshal: string does not contain UTF-8");
u"binaryurp::Unmarshal: string does not contain UTF-8"_ustr);
}
data_ += n;
return s;
@@ -420,7 +420,7 @@ BinaryAny Unmarshal::readSequence(css::uno::TypeDescription const & type) {
sal_uInt32 n = readCompressed();
if (n > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
"binaryurp::Unmarshal: sequence size too large");
u"binaryurp::Unmarshal: sequence size too large"_ustr);
}
if (n == 0) {
return BinaryAny(type, nullptr);
@@ -448,7 +448,7 @@ BinaryAny Unmarshal::readSequence(css::uno::TypeDescription const & type) {
// sal_uInt32 * sal_Int32 -> sal_uInt64 cannot overflow
if (size > SAL_MAX_SIZE - SAL_SEQUENCE_HEADER_SIZE) {
throw css::uno::RuntimeException(
"binaryurp::Unmarshal: sequence size too large");
u"binaryurp::Unmarshal: sequence size too large"_ustr);
}
void * buf = allocate(
SAL_SEQUENCE_HEADER_SIZE + static_cast< sal_Size >(size));

View File

@@ -168,7 +168,7 @@ void Writer::execute() {
(item.oid != "UrpProtocolProperties" &&
!item.member.equals(
css::uno::TypeDescription(
"com.sun.star.uno.XInterface::release")) &&
u"com.sun.star.uno.XInterface::release"_ustr)) &&
bridge_->isCurrentContextMode()),
item.currentContext);
} else {
@@ -243,7 +243,7 @@ void Writer::sendRequest(
}
assert(functionId >= 0);
if (functionId > SAL_MAX_UINT16) {
throw css::uno::RuntimeException("function ID too large for URP");
throw css::uno::RuntimeException(u"function ID too large for URP"_ustr);
}
std::vector< unsigned char > buf;
bool newType = !(lastType_.is() && t.equals(lastType_));
@@ -411,7 +411,7 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) {
std::vector< unsigned char > header;
if (buffer.size() > SAL_MAX_UINT32) {
throw css::uno::RuntimeException(
"message too large for URP");
u"message too large for URP"_ustr);
}
Marshal::write32(&header, static_cast< sal_uInt32 >(buffer.size()));
Marshal::write32(&header, 1);