Skip to content

Commit

Permalink
Fix coverity scan warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 25, 2024
1 parent 761d51f commit b3a0f2a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/twitterdemo/tweeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private slots:
void tweetReplyDone();

private:
O1Twitter* o1Twitter_;
OXTwitter* oxTwitter_;
O1Twitter* o1Twitter_{nullptr};
OXTwitter* oxTwitter_{nullptr};
};

#endif // TWEETER_H
2 changes: 1 addition & 1 deletion src/o0baseauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ O2PollServer *O0BaseAuth::pollServer() const

void O0BaseAuth::setLoggingFunction( std::function<void (const QString&, LogLevel)> function)
{
sLoggingFunction = function;
sLoggingFunction = std::move( function );
}

void O0BaseAuth::log(const QString& message, LogLevel level)
Expand Down
8 changes: 4 additions & 4 deletions src/o0simplecrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class O0_EXPORT O0SimpleCrypt
a cyphertext the result. The result is a base64 encoded version of the binary array that is the
actual result of the encryption, so it can be stored easily in a text format.
*/
QString encryptToString(QByteArray plaintext) ;
QString encryptToString(const QByteArray& plaintext) ;
/**
Encrypts the @arg plaintext string with the key the class was initialized with, and returns
a binary cyphertext in a QByteArray the result.
Expand All @@ -171,7 +171,7 @@ class O0_EXPORT O0SimpleCrypt
This method returns a byte array, that is useable for storing a binary format. If you need
a string you can store in a text file, use encryptToString() instead.
*/
QByteArray encryptToByteArray(QByteArray plaintext) ;
QByteArray encryptToByteArray(const QByteArray& plaintext) ;

/**
Decrypts a cyphertext string encrypted with this class with the set key back to the
Expand All @@ -196,15 +196,15 @@ class O0_EXPORT O0SimpleCrypt
If an error occured, such as non-matching keys between encryption and decryption,
an empty string or a string containing nonsense may be returned.
*/
QString decryptToString(QByteArray cypher) ;
QString decryptToString(const QByteArray& cypher) ;
/**
Decrypts a cyphertext binary encrypted with this class with the set key back to the
plain text version.
If an error occured, such as non-matching keys between encryption and decryption,
an empty string or a string containing nonsense may be returned.
*/
QByteArray decryptToByteArray(QByteArray cypher) ;
QByteArray decryptToByteArray(const QByteArray& cypher) ;

//enum to describe options that have been used for the encryption. Currently only one, but
//that only leaves room for future extensions like adding a cryptographic hash...
Expand Down
2 changes: 1 addition & 1 deletion src/o2requestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void O2Requestor::onUploadProgress(qint64 uploaded, qint64 total) {
}

int O2Requestor::setup(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &verb) {
static int currentId;
static int currentId = 1;

if (status_ != Idle) {
O0BaseAuth::log( QStringLiteral("O2Requestor::setup: Another request pending"), O0BaseAuth::LogLevel::Warning );
Expand Down
12 changes: 6 additions & 6 deletions src/o2requestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ protected Q_SLOTS:
Idle, Requesting, ReRequesting
};

QNetworkAccessManager *manager_;
O2 *authenticator_;
QNetworkAccessManager *manager_{nullptr};
O2 *authenticator_{nullptr};
QNetworkRequest request_;
QByteArray data_;
QHttpMultiPart* multipartData_;
QHttpMultiPart* multipartData_{nullptr};
QNetworkReply *reply_{nullptr};
Status status_{Idle};
int id_;
QNetworkAccessManager::Operation operation_;
int id_{1};
QNetworkAccessManager::Operation operation_{QNetworkAccessManager::GetOperation};
QUrl url_;
O2ReplyList timedReplies_;
QNetworkReply::NetworkError error_;
QNetworkReply::NetworkError error_{QNetworkReply::NoError};
bool addAccessTokenInQuery_{true};
QString accessTokenInAuthenticationHTTPHeaderFormat_;
bool rawData_{false};
Expand Down
8 changes: 4 additions & 4 deletions src/o2simplecrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ QByteArray O0SimpleCrypt::encryptToByteArray(const QString& plaintext)
return encryptToByteArray(plaintextArray);
}

QByteArray O0SimpleCrypt::encryptToByteArray(QByteArray plaintext)
QByteArray O0SimpleCrypt::encryptToByteArray(const QByteArray& plaintext)
{
if (m_keyParts.isEmpty()) {
O0BaseAuth::log( QStringLiteral("No key set."), O0BaseAuth::LogLevel::Warning );
Expand Down Expand Up @@ -161,7 +161,7 @@ QString O0SimpleCrypt::encryptToString(const QString& plaintext)
return cypherString;
}

QString O0SimpleCrypt::encryptToString(QByteArray plaintext)
QString O0SimpleCrypt::encryptToString(const QByteArray& plaintext)
{
QByteArray cypher = encryptToByteArray(plaintext);
QString cypherString = QString::fromLatin1(cypher.toBase64());
Expand All @@ -177,7 +177,7 @@ QString O0SimpleCrypt::decryptToString(const QString &cyphertext)
return plaintext;
}

QString O0SimpleCrypt::decryptToString(QByteArray cypher)
QString O0SimpleCrypt::decryptToString(const QByteArray &cypher)
{
QByteArray ba = decryptToByteArray(cypher);
QString plaintext = QString::fromUtf8(ba, ba.size());
Expand All @@ -193,7 +193,7 @@ QByteArray O0SimpleCrypt::decryptToByteArray(const QString& cyphertext)
return ba;
}

QByteArray O0SimpleCrypt::decryptToByteArray(QByteArray cypher)
QByteArray O0SimpleCrypt::decryptToByteArray(const QByteArray& cypher)
{
if (m_keyParts.isEmpty()) {
O0BaseAuth::log( QStringLiteral("No key set."), O0BaseAuth::LogLevel::Warning );
Expand Down

0 comments on commit b3a0f2a

Please sign in to comment.