QtNetwork: use printf-style qWarning/qDebug where possible (I)

The printf-style version of QDebug expands to a lot less code than the
std::ostream-style version. Of course, you pay in type safety (but
compilers warn about it these days), you cannot stream complex Qt
types and streaming QStrings is awkward, but in many cases you
actually improve on readability.

But the main reason is that something that's not supposed to be
executed under normal operation has no business bloating executable
code size.

This is not an attempt at converting all qWarnings() to printf-style,
only the low-hanging fruit.

In this first part, replace
   qWarning() << ""
with
   qWarning("...").

Saves ~850b in text size on optimized GCC 5.3 AMD64 builds.

Change-Id: Ib1a087795a03b2a6b432e2c499968df779aaea37
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
bb10
Marc Mutz 2015-10-17 17:48:34 +02:00
parent 600529e07a
commit 5cd455dca3
7 changed files with 14 additions and 14 deletions

View File

@ -234,7 +234,7 @@ bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *sock
emitError = false;
}
if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown)
qWarning() << "We got a connection error when networkLayerState is Unknown";
qWarning("We got a connection error when networkLayerState is Unknown");
}
}
return emitError;
@ -1190,7 +1190,7 @@ void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(const QHostInfo &info)
#endif // QT_NO_SSL
else {
// Should not happen
qWarning() << "QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeu request";
qWarning("QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeu request");
networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
}
}

View File

@ -418,7 +418,7 @@ void QHttpNetworkConnectionChannel::allDone()
Q_ASSERT(reply);
if (!reply) {
qWarning() << "QHttpNetworkConnectionChannel::allDone() called without reply. Please report at http://bugreports.qt.io/";
qWarning("QHttpNetworkConnectionChannel::allDone() called without reply. Please report at http://bugreports.qt.io/");
return;
}

View File

@ -260,7 +260,7 @@ bool QHttpProtocolHandler::sendRequest()
if (!m_reply) {
// heh, how should that happen!
qWarning() << "QAbstractProtocolHandler::sendRequest() called without QHttpNetworkReply";
qWarning("QAbstractProtocolHandler::sendRequest() called without QHttpNetworkReply");
return false;
}

View File

@ -160,7 +160,7 @@ void QNetworkDiskCache::setCacheDirectory(const QString &cacheDir)
qint64 QNetworkDiskCache::cacheSize() const
{
#if defined(QNETWORKDISKCACHE_DEBUG)
qDebug() << "QNetworkDiskCache::cacheSize()";
qDebug("QNetworkDiskCache::cacheSize()");
#endif
Q_D(const QNetworkDiskCache);
if (d->cacheDirectory.isEmpty())
@ -185,7 +185,7 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
return 0;
if (d->cacheDirectory.isEmpty()) {
qWarning() << "QNetworkDiskCache::prepare() The cache directory is not set";
qWarning("QNetworkDiskCache::prepare() The cache directory is not set");
return 0;
}
@ -212,7 +212,7 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
cacheItem->file = 0;
}
if (!cacheItem->file || !cacheItem->file->open()) {
qWarning() << "QNetworkDiskCache::prepare() unable to open temporary file";
qWarning("QNetworkDiskCache::prepare() unable to open temporary file");
cacheItem.reset();
return 0;
}
@ -448,7 +448,7 @@ void QNetworkDiskCache::updateMetaData(const QNetworkCacheMetaData &metaData)
QIODevice *oldDevice = data(url);
if (!oldDevice) {
#if defined(QNETWORKDISKCACHE_DEBUG)
qDebug() << "QNetworkDiskCache::updateMetaData(), no device!";
qDebug("QNetworkDiskCache::updateMetaData(), no device!");
#endif
return;
}
@ -521,7 +521,7 @@ qint64 QNetworkDiskCache::expire()
return d->currentCacheSize;
if (cacheDirectory().isEmpty()) {
qWarning() << "QNetworkDiskCache::expire() The cache directory is not set";
qWarning("QNetworkDiskCache::expire() The cache directory is not set");
return 0;
}
@ -584,7 +584,7 @@ qint64 QNetworkDiskCache::expire()
void QNetworkDiskCache::clear()
{
#if defined(QNETWORKDISKCACHE_DEBUG)
qDebug() << "QNetworkDiskCache::clear()";
qDebug("QNetworkDiskCache::clear()");
#endif
Q_D(QNetworkDiskCache);
qint64 size = d->maximumCacheSize;

View File

@ -65,7 +65,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
{
// TODO: Add nameserver support for winRT
if (!nameserver.isNull())
qWarning() << "Ignoring nameserver as its currently not supported on WinRT";
qWarning("Ignoring nameserver as its currently not supported on WinRT");
// TODO: is there any way to do "proper" dns lookup?
if (requestType != QDnsLookup::A && requestType != QDnsLookup::AAAA

View File

@ -510,7 +510,7 @@ void QHttpSocketEngine::slotSocketConnected()
data += "\r\n";
// qDebug() << ">>>>>>>> sending request" << this;
// qDebug() << data;
// qDebug() << ">>>>>>>";
// qDebug(">>>>>>>");
d->socket->write(data);
d->state = ConnectSent;
}

View File

@ -352,7 +352,7 @@ void QSocks5BindStore::add(qintptr socketDescriptor, QSocks5BindData *bindData)
{
QMutexLocker lock(&mutex);
if (store.contains(socketDescriptor)) {
// qDebug() << "delete it";
// qDebug("delete it");
}
bindData->timeStamp.start();
store.insert(socketDescriptor, bindData);
@ -1191,7 +1191,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketReadNotification()
case Connected: {
QByteArray buf;
if (!data->authenticator->unSeal(data->controlSocket, &buf)) {
// qDebug() << "unseal error maybe need to wait for more data";
// qDebug("unseal error maybe need to wait for more data");
}
if (buf.size()) {
QSOCKS5_DEBUG << dump(buf);