From de9d7b0b25245b73d4da63552e5fa24e7fb8578a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Sep 2021 20:14:13 -0700 Subject: [PATCH] QElfParser: remove one more unnecesary variable from the ELF parser There's no need to keep this variable in the class. Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a35775d56d3e45 Reviewed-by: Oswald Buddenhagen --- src/corelib/plugin/qelfparser_p.cpp | 4 ++-- src/corelib/plugin/qelfparser_p.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp index 46df38debc7..07f9a5323b3 100644 --- a/src/corelib/plugin/qelfparser_p.cpp +++ b/src/corelib/plugin/qelfparser_p.cpp @@ -87,12 +87,12 @@ auto QElfParser::parse(const char *dataStart, ulong fdlen, const QString &librar lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library, QLibrary::tr("odd cpu architecture")); return Corrupt; } - m_bits = (data[4] << 5); /* If you remove this check, to read ELF objects of a different arch, please make sure you modify the typedefs to match the _plugin_ architecture. */ - if ((sizeof(void*) == 4 && m_bits != 32) || (sizeof(void*) == 8 && m_bits != 64)) { + constexpr int ExpectedClass = (sizeof(void *) == 4) ? 1 : 2; + if (data[4] != ExpectedClass) { if (lib) lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library, QLibrary::tr("wrong cpu architecture")); return Corrupt; diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h index 0a3470dab72..bd967e53aea 100644 --- a/src/corelib/plugin/qelfparser_p.h +++ b/src/corelib/plugin/qelfparser_p.h @@ -82,7 +82,6 @@ public: qelfoff_t size; }; - int m_bits; qelfoff_t m_stringTableFileOffset; const char *parseSectionHeader(const char* s, ElfSectionHeader *sh);