Skip to content

Commit

Permalink
Suppress more false-positive clang analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 25, 2024
1 parent e32b60d commit 9d5e8d2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/facebookdemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationDomain("mysoft.com");
QCoreApplication::setApplicationName("facebookdemo");
Helper helper;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(0, &helper, &Helper::processArgs);
#endif
return a.exec();
}

Expand Down
3 changes: 3 additions & 0 deletions examples/msgraphdemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationName("O2");
QCoreApplication::setApplicationName("Msgraph Example");
Helper helper;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(0, &helper, &Helper::run);
#endif
return a.exec();
}

Expand Down
3 changes: 3 additions & 0 deletions examples/msgraphexternalinterceptordemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationName("O2");
QCoreApplication::setApplicationName("Msgraph Example");
Helper helper;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(0, &helper, &Helper::run);
#endif
return a.exec();
}

Expand Down
3 changes: 3 additions & 0 deletions examples/msgraphexternalinterceptordemo/webwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ void WebWindow::closeEvent(QCloseEvent *)
void WebWindow::onCallbackCatched(const QString &inURLString)
{
mCatchedOAuthURL = inURLString;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(100, this, &WebWindow::onCallbackCatchedSafe);
#endif
}

void WebWindow::onCallbackCatchedSafe()
Expand Down
4 changes: 3 additions & 1 deletion examples/twitterdemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationDomain("mysoft.com");
QCoreApplication::setApplicationName("tweeter");
Helper helper;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(0, &helper, &Helper::processArgs);

#endif
return a.exec();
}

Expand Down
3 changes: 3 additions & 0 deletions examples/vimeodemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationName("O2");
QCoreApplication::setApplicationName("Vimeo Test");
Helper helper;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(0, &helper, &Helper::run);
#endif
return a.exec();
}

Expand Down
3 changes: 3 additions & 0 deletions examples/youtubedemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ int main(int argc, char *argv[]) {
QCoreApplication::setOrganizationName("O2");
QCoreApplication::setApplicationName("YouTube Test");
Helper helper;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(0, &helper, &Helper::run);
#endif
return a.exec();
}

Expand Down
6 changes: 6 additions & 0 deletions src/o2requestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,12 @@ void O2Requestor::onRequestFinished() {
if (reply_ != qobject_cast<QNetworkReply *>(sender())) {
return;
}
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
if (reply_->error() == QNetworkReply::NoError) {
QTimer::singleShot(10, this, &O2Requestor::finish);
}
#endif
}

void O2Requestor::onRequestError(QNetworkReply::NetworkError error) {
Expand All @@ -292,7 +295,10 @@ void O2Requestor::onRequestError(QNetworkReply::NetworkError error) {
O0BaseAuth::log( QStringLiteral( "O2Requestor::onRequestError: Invoking remote refresh failed" ), O0BaseAuth::LogLevel::Critical );
}
error_ = error;
// Suppress warning: Potential leak of memory in qtimer.h [clang-analyzer-cplusplus.NewDeleteLeaks]
#ifndef __clang_analyzer__
QTimer::singleShot(10, this, &O2Requestor::finish);
#endif
}

void O2Requestor::onUploadProgress(qint64 uploaded, qint64 total) {
Expand Down

0 comments on commit 9d5e8d2

Please sign in to comment.