Fix compile warnings with MSVC
authorShane Kearns <ext-shane.2.kearns@nokia.com>
Tue, 22 May 2012 11:31:23 +0000 (12:31 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 23 May 2012 12:18:34 +0000 (14:18 +0200)
Calling a static function non statically causes an unused variable
warning for the optimised away d pointer.
sscanf causes an insecure functions warning. (Even though it was used
safely in this case)

Change-Id: I07700e2155284ef3ebbe7d604ed59b2e61ee7f95
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/network/access/qnetworkrequest.cpp
src/network/socket/qabstractsocket.cpp

index 9df0632..cb4614b 100644 (file)
@@ -1043,7 +1043,14 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)
         if (pos == 3) {
             char month_name[4];
             int day, year, hour, minute, second;
+#ifdef Q_CC_MSVC
+            // Use secure version to avoid compiler warning
+            if (sscanf_s(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, 4, &year, &hour, &minute, &second) == 6)
+#else
+            // The POSIX secure mode is %ms (which allocates memory), too bleeding edge for now
+            // In any case this is already safe as field width is specified.
             if (sscanf(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, &year, &hour, &minute, &second) == 6)
+#endif
                 dt = QDateTime(QDate(year, name_to_month(month_name), day), QTime(hour, minute, second));
         } else {
             QLocale c = QLocale::c();
index 7abcb24..8d1c134 100644 (file)
@@ -1378,8 +1378,7 @@ QAbstractSocket::~QAbstractSocket()
 */
 void QAbstractSocket::resume()
 {
-    Q_D(QAbstractSocket);
-    d->resumeSocketNotifiers(this);
+    QAbstractSocketPrivate::resumeSocketNotifiers(this);
 }
 
 /*!