Merge pull request #3180 from ngosang/cppcheck_fixes_32x

Cppcheck: scope reduction & unused variables (v3_2_x)
This commit is contained in:
sledgehammer999 2015-06-13 20:19:40 +03:00
commit 718983a4d6
4 changed files with 12 additions and 17 deletions

View file

@ -79,9 +79,8 @@ RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray& data,
} }
// Parse HTTP request message // Parse HTTP request message
int content_length = 0;
if (m_request.headers.contains("content-length")) { if (m_request.headers.contains("content-length")) {
content_length = m_request.headers["content-length"].toInt(); int content_length = m_request.headers["content-length"].toInt();
if (content_length > static_cast<int>(m_maxContentLength)) { if (content_length > static_cast<int>(m_maxContentLength)) {
qWarning() << Q_FUNC_INFO << "bad request: message too long"; qWarning() << Q_FUNC_INFO << "bad request: message too long";
return BadRequest; return BadRequest;

View file

@ -183,9 +183,7 @@ void misc::shutdownComputer(shutDownAction action)
AppleEvent eventReply = {typeNull, NULL}; AppleEvent eventReply = {typeNull, NULL};
AppleEvent appleEventToSend = {typeNull, NULL}; AppleEvent appleEventToSend = {typeNull, NULL};
OSStatus error = noErr; OSStatus error = AECreateDesc(typeProcessSerialNumber, &kPSNOfSystemProcess,
error = AECreateDesc(typeProcessSerialNumber, &kPSNOfSystemProcess,
sizeof(kPSNOfSystemProcess), &targetDesc); sizeof(kPSNOfSystemProcess), &targetDesc);
if (error != noErr) if (error != noErr)

View file

@ -1253,9 +1253,9 @@ void QBtSession::loadTorrentTempData(QTorrentHandle &h, QString savePath, bool m
// Update file names // Update file names
const QStringList files_path = TorrentTempData::getFilesPath(hash); const QStringList files_path = TorrentTempData::getFilesPath(hash);
bool force_recheck = false;
QDir base_dir(h.save_path()); QDir base_dir(h.save_path());
if (files_path.size() == h.num_files()) { if (files_path.size() == h.num_files()) {
bool force_recheck = false;
for (int i=0; i<h.num_files(); ++i) { for (int i=0; i<h.num_files(); ++i) {
const QString &path = files_path.at(i); const QString &path = files_path.at(i);
if (!force_recheck && base_dir.exists(path)) if (!force_recheck && base_dir.exists(path))
@ -2209,15 +2209,7 @@ void QBtSession::handleTorrentFinishedAlert(libtorrent::torrent_finished_alert*
qDebug("Emitting finishedTorrent() signal"); qDebug("Emitting finishedTorrent() signal");
emit finishedTorrent(h); emit finishedTorrent(h);
qDebug("Received finished alert for %s", qPrintable(h.name())); qDebug("Received finished alert for %s", qPrintable(h.name()));
#ifndef DISABLE_GUI
bool will_shutdown = (pref->shutdownWhenDownloadsComplete() ||
pref->shutdownqBTWhenDownloadsComplete() ||
pref->suspendWhenDownloadsComplete() ||
pref->hibernateWhenDownloadsComplete())
&& !hasDownloadingTorrents();
#else
bool will_shutdown = false;
#endif
// AutoRun program // AutoRun program
if (pref->isAutoRunEnabled()) if (pref->isAutoRunEnabled())
autoRunExternalProgram(h); autoRunExternalProgram(h);
@ -2227,8 +2219,15 @@ void QBtSession::handleTorrentFinishedAlert(libtorrent::torrent_finished_alert*
// Mail notification // Mail notification
if (pref->isMailNotificationEnabled()) if (pref->isMailNotificationEnabled())
sendNotificationEmail(h); sendNotificationEmail(h);
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
// Auto-Shutdown // Auto-Shutdown
bool will_shutdown = (pref->shutdownWhenDownloadsComplete() ||
pref->shutdownqBTWhenDownloadsComplete() ||
pref->suspendWhenDownloadsComplete() ||
pref->hibernateWhenDownloadsComplete())
&& !hasDownloadingTorrents();
if (will_shutdown) { if (will_shutdown) {
bool suspend = pref->suspendWhenDownloadsComplete(); bool suspend = pref->suspendWhenDownloadsComplete();
bool hibernate = pref->hibernateWhenDownloadsComplete(); bool hibernate = pref->hibernateWhenDownloadsComplete();

View file

@ -117,7 +117,6 @@ void RssFeed::loadItemsFromDisk()
} }
void RssFeed::addArticle(const RssArticlePtr& article) { void RssFeed::addArticle(const RssArticlePtr& article) {
int lbIndex = -1;
int max_articles = Preferences::instance()->getRSSMaxArticlesPerFeed(); int max_articles = Preferences::instance()->getRSSMaxArticlesPerFeed();
if (!m_articles.contains(article->guid())) { if (!m_articles.contains(article->guid())) {
@ -131,7 +130,7 @@ void RssFeed::addArticle(const RssArticlePtr& article) {
// Insertion sort // Insertion sort
RssArticleList::Iterator lowerBound = qLowerBound(m_articlesByDate.begin(), m_articlesByDate.end(), article, rssArticleDateRecentThan); RssArticleList::Iterator lowerBound = qLowerBound(m_articlesByDate.begin(), m_articlesByDate.end(), article, rssArticleDateRecentThan);
m_articlesByDate.insert(lowerBound, article); m_articlesByDate.insert(lowerBound, article);
lbIndex = m_articlesByDate.indexOf(article); int lbIndex = m_articlesByDate.indexOf(article);
if (m_articlesByDate.size() > max_articles) { if (m_articlesByDate.size() > max_articles) {
RssArticlePtr oldestArticle = m_articlesByDate.takeLast(); RssArticlePtr oldestArticle = m_articlesByDate.takeLast();
m_articles.remove(oldestArticle->guid()); m_articles.remove(oldestArticle->guid());