Просмотр исходного кода

clang-cl: Enable yet another warning with the very long name

ref:878ef48a386627a1eb0325b0ccff820b1d627900
thegeorg 3 лет назад
Родитель
Сommit
dc607d4bde
4 измененных файлов с 13 добавлено и 5 удалено
  1. 0 1
      build/ymake_conf.py
  2. 3 0
      util/CMakeLists.txt
  3. 6 4
      util/network/interface.cpp
  4. 4 0
      util/ya.make

+ 0 - 1
build/ymake_conf.py

@@ -2469,7 +2469,6 @@ class MSVCCompiler(MSVC, Compiler):
                 '-Wno-macro-redefined',
                 '-Wno-macro-redefined',
                 '-Wno-parentheses',
                 '-Wno-parentheses',
                 '-Wno-pragma-pack',
                 '-Wno-pragma-pack',
-                '-Wno-tautological-constant-out-of-range-compare',
                 '-Wno-unknown-argument',
                 '-Wno-unknown-argument',
                 '-Wno-unknown-warning-option',
                 '-Wno-unknown-warning-option',
             ))
             ))

+ 3 - 0
util/CMakeLists.txt

@@ -1,4 +1,7 @@
 add_library(yutil)
 add_library(yutil)
+target_compile_options(yutil PRIVATE
+  -Wnarrowing
+)
 target_link_libraries(yutil PUBLIC
 target_link_libraries(yutil PUBLIC
   contrib-libs-cxxsupp
   contrib-libs-cxxsupp
   util-charset
   util-charset

+ 6 - 4
util/network/interface.cpp

@@ -1,5 +1,7 @@
 #include "interface.h"
 #include "interface.h"
 
 
+#include <util/string/ascii.h>
+
 #if defined(_unix_)
 #if defined(_unix_)
     #include <ifaddrs.h>
     #include <ifaddrs.h>
 #endif
 #endif
@@ -44,10 +46,10 @@ namespace NAddr {
                         TNetworkInterface networkInterface;
                         TNetworkInterface networkInterface;
 
 
                         // Not very efficient but straightforward
                         // Not very efficient but straightforward
-                        for (size_t i = 0; ptr->FriendlyName[i] != 0; i++) {
-                            CHAR w = ptr->FriendlyName[i];
-                            char c = (w < 0x80) ? char(w) : '?';
-                            networkInterface.Name.append(1, c);
+                        wchar_t* it = ptr->FriendlyName;
+                        while (*it != '\0') {
+                            networkInterface.Name += IsAscii(*it) ? static_cast<char>(*it) : '?';
+                            ++it;
                         }
                         }
 
 
                         networkInterface.Address = new TOpaqueAddr(a);
                         networkInterface.Address = new TOpaqueAddr(a);

+ 4 - 0
util/ya.make

@@ -238,6 +238,10 @@ JOIN_SRCS(
     string/vector.cpp
     string/vector.cpp
 )
 )
 
 
+IF (GCC OR CLANG OR CLANG_CL)
+    CFLAGS(-Wnarrowing)
+ENDIF()
+
 IF (ARCH_ARM)
 IF (ARCH_ARM)
     CFLAGS(-D_FORTIFY_SOURCE=0)
     CFLAGS(-D_FORTIFY_SOURCE=0)
 ENDIF()
 ENDIF()