summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qlibrary.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-13 22:10:05 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-09-24 20:16:36 -0700
commitf000d5672a1c99365c05ec2db0a6220c85646290 (patch)
treef5fc274906e46b40f4f798e7b62f7d9b1a387c5f /src/corelib/plugin/qlibrary.cpp
parent57960ab075b9e7a471c42ddea6a2abbc2994ec83 (diff)
QPlugin: reorganize findPatternUnloaded and remove two bool variables
The compiler ought to figure them out, but we can just help it. Change-Id: I42eb903a916645db9900fffd16a4981ac966f982 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/plugin/qlibrary.cpp')
-rw-r--r--src/corelib/plugin/qlibrary.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index cfc7479d37..d8736c9edb 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -283,10 +283,6 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
/*
ELF and Mach-O binaries with GCC have .qtmetadata sections. Find them.
*/
- bool hasMetaData = false;
- char pattern[] = "qTMETADATA ";
- pattern[0] = 'Q'; // Ensure the pattern "QTMETADATA" is not found in this library should QPluginLoader ever encounter it.
- const ulong plen = ulong(qstrlen(pattern));
#if defined (Q_OF_ELF)
r = QElfParser().parse(filedata, r.length, library, lib);
if (r.length == 0) {
@@ -307,16 +303,13 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
}
}
#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+
+ char pattern[] = "qTMETADATA ";
+ pattern[0] = 'Q'; // Ensure the pattern "QTMETADATA" is not found in this library should QPluginLoader ever encounter it.
+ const ulong plen = ulong(qstrlen(pattern));
if (qsizetype rel = qt_find_pattern(filedata + r.pos, r.length, pattern, plen);
rel >= 0) {
- r.pos += rel;
- hasMetaData = true;
- }
-
- bool ret = false;
-
- if (r.pos >= 0 && hasMetaData) {
- const char *data = filedata + r.pos;
+ const char *data = filedata + r.pos + rel;
QString errMsg;
QJsonDocument doc = qJsonFromRawLibraryMetaData(data, r.length, &errMsg);
if (doc.isNull()) {
@@ -327,14 +320,14 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
if (qt_debug_component())
qWarning("Found metadata in lib %s, metadata=\n%s\n",
library.toLocal8Bit().constData(), doc.toJson().constData());
- ret = !doc.isNull();
+ if (!doc.isNull())
+ return true;
}
}
- if (!ret && lib)
+ if (lib)
lib->errorString = QLibrary::tr("Failed to extract plugin meta data from '%1'").arg(library);
- file.close();
- return ret;
+ return false;
}
static void installCoverageTool(QLibraryPrivate *libPrivate)