Browse Source

Enable -Wshorten-64-to-32 on Clang and GCC and fix warnings in our code

Also disable this warning for external libs like qhttp and HIDRemote
since we don't control them and don't want to maintain fixes just for
warnings.
Tobias Hieta 8 years ago
parent
commit
2825f1acd9

+ 6 - 0
CMakeModules/CompilerFlags.cmake

@@ -3,10 +3,16 @@ if(NOT MSVC)
   enable_if_supported(COMPILER_FLAGS "-Wall")
 endif()
 
+enable_if_supported(COMPILER_FLAGS "-Wshorten-64-to-32")
 enable_if_supported(COMPILER_FLAGS "-fno-omit-frame-pointer")
 enable_if_supported(COMPILER_FLAGS "-mmacosx-version-min=10.9")
 enable_if_supported(COMPILER_FLAGS "/Oy-")
 
+# Flags only for external libs
+enable_if_supported(COMPILER_FLAGS_THIRD_PARTY "-Wno-shorten-64-to-32")
+enable_if_supported(COMPILER_FLAGS_THIRD_PARTY "/wd4244")
+enable_if_supported(COMPILER_FLAGS_THIRD_PARTY "/wd4267")
+
 enable_if_links(LINK_FLAGS "-flto")
 enable_if_links(LINK_FLAGS "-fuse-ld=gold")
 

+ 3 - 0
external/CMakeLists.txt

@@ -1,3 +1,6 @@
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS_THIRD_PARTY}")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS_THIRD_PARTY}")
+
 add_subdirectory(qslog)
 add_subdirectory(qhttp)
 

+ 3 - 3
src/display/osx/DisplayManagerOSX.cpp

@@ -61,9 +61,9 @@ bool DisplayManagerOSX::initialize()
       CGDisplayModeRef displayMode =
       (CGDisplayModeRef)CFArrayGetValueAtIndex(m_osxDisplayModes[displayid], modeid);
 
-      mode->m_height = CGDisplayModeGetHeight(displayMode);
-      mode->m_width = CGDisplayModeGetWidth(displayMode);
-      mode->m_refreshRate = CGDisplayModeGetRefreshRate(displayMode);
+      mode->m_height = (int)CGDisplayModeGetHeight(displayMode);
+      mode->m_width = (int)CGDisplayModeGetWidth(displayMode);
+      mode->m_refreshRate = (float)CGDisplayModeGetRefreshRate(displayMode);
 
       CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(displayMode);
 

+ 1 - 1
src/player/PlayerComponent.cpp

@@ -456,7 +456,7 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
       size_t len = strlen(msg->text);
       if (len > 0 && msg->text[len - 1] == '\n')
         len -= 1;
-      QString logline = QString::fromUtf8(msg->prefix) + ": " + QString::fromUtf8(msg->text, len);
+      QString logline = QString::fromUtf8(msg->prefix) + ": " + QString::fromUtf8(msg->text, (int)len);
       if (msg->log_level >= MPV_LOG_LEVEL_V)
         QLOG_DEBUG() << qPrintable(logline);
       else if (msg->log_level >= MPV_LOG_LEVEL_INFO)

+ 1 - 1
src/remote/GDMManager.cpp

@@ -41,7 +41,7 @@ void GDMManager::readData()
   while (m_socket.hasPendingDatagrams())
   {
     QByteArray datagram;
-    datagram.resize(m_socket.pendingDatagramSize());
+    datagram.resize((int)m_socket.pendingDatagramSize());
 
     QHostAddress sender;
     quint16 senderPort;

+ 5 - 3
src/remote/RemoteComponent.cpp

@@ -291,17 +291,19 @@ void RemoteComponent::responseDone()
   {
     QMutexLocker lk(&m_responseLock);
 
-    int foundId = -1;
-    for(int responseId : m_responseMap.keys())
+    bool found = false;
+    quint64 foundId = 0;
+    for(auto responseId : m_responseMap.keys())
     {
       if (m_responseMap[responseId] == response)
       {
         foundId = responseId;
+        found = true;
         break;
       }
     }
 
-    if (foundId != -1)
+    if (found)
       m_responseMap.remove(foundId);
   }
 }

+ 2 - 2
src/utils/PlatformUtils.cpp

@@ -11,9 +11,9 @@
 bool PlatformUtils::isProcessAlive(Q_PID pid)
 {
 #ifdef Q_OS_UNIX
-  int ret = kill(pid, 0);
+  int ret = kill((pid_t)pid, 0);
   return ret == 0;
 #endif
 
   return false;
-}
+}