diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-10 11:08:29 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-20 20:48:59 +0200 |
commit | 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 (patch) | |
tree | d85afa295e882b84aa11c8861d6b85799c2f7e71 /src/dbus | |
parent | 84e89c1e9e00d4fab576b876cfa80e92b5602982 (diff) |
Port from QAtomic::load() to loadRelaxed()
Semi-automated, just needed ~20 manual fixes:
$ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} +
$ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} +
It can be easily improved (e.g. for store check that there are no commas
after the opening parens). The most common offender is QLibrary::load,
and some code using std::atomic directly.
Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusargument.cpp | 4 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 8 | ||||
-rw-r--r-- | src/dbus/qdbusmetatype.cpp | 4 | ||||
-rw-r--r-- | src/dbus/qdbuspendingcall.cpp | 2 | ||||
-rw-r--r-- | src/dbus/qdbusserver.cpp | 2 | ||||
-rw-r--r-- | src/dbus/qdbusunixfiledescriptor.cpp | 10 |
6 files changed, 15 insertions, 15 deletions
diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 2d1373006d..764bc24165 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -111,7 +111,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d) if (!d->marshaller()->ok) return false; - if (d->message && d->ref.load() != 1) { + if (d->message && d->ref.loadRelaxed() != 1) { QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities); dd->message = q_dbus_message_copy(d->message); q_dbus_message_iter_init_append(dd->message, &dd->iterator); @@ -152,7 +152,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d) if (!checkRead(d)) return false; // don't bother - if (d->ref.load() == 1) + if (d->ref.loadRelaxed() == 1) return true; // no need to detach QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 640acc2425..af16940d4f 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -534,7 +534,7 @@ qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data) bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg) { - if (!ref.load()) + if (!ref.loadRelaxed()) return false; // local message are always delivered, regardless of filtering @@ -1077,7 +1077,7 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() if (lastMode == ClientMode || lastMode == PeerMode) { // the bus service object holds a reference back to us; // we need to destroy it before we finish destroying ourselves - Q_ASSERT(ref.load() == 0); + Q_ASSERT(ref.loadRelaxed() == 0); QObject *obj = (QObject *)busService; if (obj) { disconnect(obj, nullptr, this, nullptr); @@ -2126,11 +2126,11 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM if ((receiver && returnMethod) || errorMethod) { // no one waiting, will delete pcall in processFinishedCall() - pcall->ref.store(1); + pcall->ref.storeRelaxed(1); } else { // set double ref to prevent race between processFinishedCall() and ref counting // by QDBusPendingCall::QExplicitlySharedDataPointer<QDBusPendingCallPrivate> - pcall->ref.store(2); + pcall->ref.storeRelaxed(2); } if (isLoopback) { diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp index 0729a3cbbb..58ce4f8930 100644 --- a/src/dbus/qdbusmetatype.cpp +++ b/src/dbus/qdbusmetatype.cpp @@ -93,7 +93,7 @@ void QDBusMetaTypeId::init() // reentrancy is not a problem since everything else is locked on their own // set the guard variable at the end - if (!initialized.load()) { + if (!initialized.loadRelaxed()) { // register our types with Qt Core (calling qMetaTypeId<T>() does this implicitly) (void)message(); (void)argument(); @@ -145,7 +145,7 @@ void QDBusMetaTypeId::init() qDBusRegisterMetaType<QVector<QDBusUnixFileDescriptor> >(); #endif - initialized.store(true); + initialized.storeRelaxed(true); } } diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 4d0131afff..b51fae9b65 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -473,7 +473,7 @@ QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg) msg.type() == QDBusMessage::ReplyMessage) { d = new QDBusPendingCallPrivate(QDBusMessage(), 0); d->replyMessage = msg; - d->ref.store(1); + d->ref.storeRelaxed(1); } return QDBusPendingCall(d); diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index a2dfb86164..2899fb7bea 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -117,7 +117,7 @@ QDBusServer::~QDBusServer() d->serverConnectionNames.clear(); } d->serverObject = nullptr; - d->ref.store(0); + d->ref.storeRelaxed(0); d->deleteLater(); } diff --git a/src/dbus/qdbusunixfiledescriptor.cpp b/src/dbus/qdbusunixfiledescriptor.cpp index 459cfc6c66..73d1db2680 100644 --- a/src/dbus/qdbusunixfiledescriptor.cpp +++ b/src/dbus/qdbusunixfiledescriptor.cpp @@ -208,7 +208,7 @@ QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor() */ bool QDBusUnixFileDescriptor::isValid() const { - return d ? d->fd.load() != -1 : false; + return d ? d->fd.loadRelaxed() != -1 : false; } /*! @@ -226,7 +226,7 @@ bool QDBusUnixFileDescriptor::isValid() const */ int QDBusUnixFileDescriptor::fileDescriptor() const { - return d ? d->fd.load() : -1; + return d ? d->fd.loadRelaxed() : -1; } // actual implementation @@ -283,12 +283,12 @@ void QDBusUnixFileDescriptor::giveFileDescriptor(int fileDescriptor) else d = new QDBusUnixFileDescriptorPrivate; - const int fdl = d->fd.load(); + const int fdl = d->fd.loadRelaxed(); if (fdl != -1) qt_safe_close(fdl); if (fileDescriptor != -1) - d->fd.store(fileDescriptor); + d->fd.storeRelaxed(fileDescriptor); } /*! @@ -309,7 +309,7 @@ int QDBusUnixFileDescriptor::takeFileDescriptor() QDBusUnixFileDescriptorPrivate::~QDBusUnixFileDescriptorPrivate() { - const int fdl = fd.load(); + const int fdl = fd.loadRelaxed(); if (fdl != -1) qt_safe_close(fdl); } |