Browse Source

Merge pull request #1238 from botanegg/cppcheck

Corrections from running cppcheck.
adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
ab89edb589
  1. 8
      src/qtlibtorrent/qbtsession.cpp
  2. 2
      src/qtlibtorrent/qtorrenthandle.cpp
  3. 2
      src/rss/rssdownloadrule.cpp
  4. 2
      src/rss/rssdownloadrule.h
  5. 3
      src/smtp.cpp

8
src/qtlibtorrent/qbtsession.cpp

@ -964,7 +964,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool f
// Adding torrent to Bittorrent session // Adding torrent to Bittorrent session
try { try {
h = QTorrentHandle(s->add_torrent(p)); h = QTorrentHandle(s->add_torrent(p));
}catch(std::exception e) { }catch(std::exception &e) {
qDebug("Error: %s", e.what()); qDebug("Error: %s", e.what());
} }
// Check if it worked // Check if it worked
@ -1153,7 +1153,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Adding torrent to Bittorrent session // Adding torrent to Bittorrent session
try { try {
h = QTorrentHandle(s->add_torrent(p)); h = QTorrentHandle(s->add_torrent(p));
}catch(std::exception e) { }catch(std::exception &e) {
qDebug("Error: %s", e.what()); qDebug("Error: %s", e.what());
} }
// Check if it worked // Check if it worked
@ -1539,7 +1539,7 @@ bool QBtSession::enableDHT(bool b) {
s->add_dht_router(std::make_pair(std::string("dht.aelitis.com"), 6881)); // Vuze s->add_dht_router(std::make_pair(std::string("dht.aelitis.com"), 6881)); // Vuze
DHTEnabled = true; DHTEnabled = true;
qDebug("DHT enabled"); qDebug("DHT enabled");
}catch(std::exception e) { }catch(std::exception &e) {
qDebug("Could not enable DHT, reason: %s", e.what()); qDebug("Could not enable DHT, reason: %s", e.what());
return false; return false;
} }
@ -1594,7 +1594,7 @@ void QBtSession::saveTempFastResumeData() {
if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking || h.has_error()) continue; if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking || h.has_error()) continue;
qDebug("Saving fastresume data for %s", qPrintable(h.name())); qDebug("Saving fastresume data for %s", qPrintable(h.name()));
h.save_resume_data(); h.save_resume_data();
}catch(std::exception e) {} }catch(std::exception &e) {}
} }
} }

2
src/qtlibtorrent/qtorrenthandle.cpp

@ -257,7 +257,7 @@ QStringList QTorrentHandle::url_seeds() const {
qDebug("URL Seed: %s", it->c_str()); qDebug("URL Seed: %s", it->c_str());
res << misc::toQString(*it); res << misc::toQString(*it);
} }
} catch(std::exception e) { } catch(std::exception &e) {
std::cout << "ERROR: Failed to convert the URL seed" << std::endl; std::cout << "ERROR: Failed to convert the URL seed" << std::endl;
} }
return res; return res;

2
src/rss/rssdownloadrule.cpp

@ -106,7 +106,7 @@ QVariantHash RssDownloadRule::toVariantHash() const
return hash; return hash;
} }
bool RssDownloadRule::operator==(const RssDownloadRule &other) { bool RssDownloadRule::operator==(const RssDownloadRule &other) const {
return m_name == other.name(); return m_name == other.name();
} }

2
src/rss/rssdownloadrule.h

@ -67,7 +67,7 @@ public:
inline void setUseRegex(bool enabled) { m_useRegex = enabled; } inline void setUseRegex(bool enabled) { m_useRegex = enabled; }
QStringList findMatchingArticles(const RssFeedPtr& feed) const; QStringList findMatchingArticles(const RssFeedPtr& feed) const;
// Operators // Operators
bool operator==(const RssDownloadRule &other); bool operator==(const RssDownloadRule &other) const;
private: private:
QString m_name; QString m_name;

3
src/smtp.cpp

@ -272,10 +272,9 @@ QByteArray Smtp::encode_mime_header(const QString& key, const QString& value, QT
// The text cannot be losslessly encoded as Latin-1. Therefore, we // The text cannot be losslessly encoded as Latin-1. Therefore, we
// must use base64 encoding. // must use base64 encoding.
QByteArray utf8 = value.toUtf8(); QByteArray utf8 = value.toUtf8();
int ct = utf8.length();
// Use base64 encoding // Use base64 encoding
QByteArray base64 = utf8.toBase64(); QByteArray base64 = utf8.toBase64();
ct = base64.length(); int ct = base64.length();
line += "=?utf-8?b?"; line += "=?utf-8?b?";
for (int i = 0; i < ct; i += 4) { for (int i = 0; i < ct; i += 4) {
/*if (line.length() > 72) { /*if (line.length() > 72) {

Loading…
Cancel
Save