浏览代码

Fix clang warnings on bitwise precedence

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 年之前
父节点
当前提交
b87d56644f
共有 5 个文件被更改,包括 26 次插入26 次删除
  1. 1 1
      cmake_modules/commonSetup.cmake
  2. 2 2
      system/jlib/jencrypt.cpp
  3. 1 1
      system/jlib/jmisc.hpp
  4. 20 20
      system/jlib/jstring.cpp
  5. 2 2
      system/security/zcrypt/aes.cpp

+ 1 - 1
cmake_modules/commonSetup.cmake

@@ -123,7 +123,7 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
       SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-default-inline -fno-inline-functions")
     endif ()
     if (CMAKE_COMPILER_IS_CLANGXX)
-      SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=logical-op-parentheses -Werror=bool-conversions -Werror=return-type -Werror=comment")
+      SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=logical-op-parentheses -Werror=bool-conversions -Werror=return-type -Werror=comment -Werror=bitwise-op-parentheses")
     endif()
     # All of these are defined in platform.h too, but need to be defned before any system header is included
     ADD_DEFINITIONS (-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1)

+ 2 - 2
system/jlib/jencrypt.cpp

@@ -1243,7 +1243,7 @@ int Rijndael::blockEncrypt(const UINT8 *input,int inputLen,UINT8 *outBuffer)
                     iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
                     iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
                     iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
-                    iv[3][3] = (iv[3][3] << 1) | (outBuffer[k/8] >> (7-(k&7))) & 1;
+                    iv[3][3] = (iv[3][3] << 1) | ((outBuffer[k/8] >> (7-(k&7))) & 1);
                 }
             }
         break;
@@ -1397,7 +1397,7 @@ int Rijndael::blockDecrypt(const UINT8 *input, int inputLen, UINT8 *outBuffer)
                     iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
                     iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
                     iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
-                    iv[3][3] = (iv[3][3] << 1) | (input[k/8] >> (7-(k&7))) & 1;
+                    iv[3][3] = (iv[3][3] << 1) | ((input[k/8] >> (7-(k&7))) & 1);
                     outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
                 }
             }

+ 1 - 1
system/jlib/jmisc.hpp

@@ -231,7 +231,7 @@ public:
 
 template<typename T1,typename T2> inline __int64 makeint64(T1 high, T2 low)
 {
-    return (__int64)high<<32 | (__int64)low & (__int64)0xffffffff;
+    return (__int64)high<<32 | ((__int64)low & (__int64)0xffffffff);
 }
 
 inline __int32 high(__int64 n)

+ 20 - 20
system/jlib/jstring.cpp

@@ -1566,38 +1566,38 @@ static void writeUtf8(unsigned c, StringBuffer &out)
         out.append((char)c);
     else if (c < 0x800)
     {
-        out.append((char)(0xC0 | c>>6));
-        out.append((char)(0x80 | c & 0x3F));
+        out.append((char)(0xC0 | (c>>6)));
+        out.append((char)(0x80 | (c & 0x3F)));
     }
     else if (c < 0x10000)
     {
-        out.append((char) (0xE0 | c>>12));
-        out.append((char) (0x80 | c>>6 & 0x3F));
-        out.append((char) (0x80 | c & 0x3F));
+        out.append((char) (0xE0 | (c>>12)));
+        out.append((char) (0x80 | (c>>6 & 0x3F)));
+        out.append((char) (0x80 | (c & 0x3F)));
     }
     else if (c < 0x200000)
     {
-        out.append((char) (0xF0 | c>>18));
-        out.append((char) (0x80 | c>>12 & 0x3F));
-        out.append((char) (0x80 | c>>6 & 0x3F));
-        out.append((char) (0x80 | c & 0x3F));
+        out.append((char) (0xF0 | (c>>18)));
+        out.append((char) (0x80 | (c>>12 & 0x3F)));
+        out.append((char) (0x80 | (c>>6 & 0x3F)));
+        out.append((char) (0x80 | (c & 0x3F)));
     }
     else if (c < 0x4000000)
     {
-        out.append((char) (0xF8 | c>>24));
-        out.append((char) (0x80 | c>>18 & 0x3F));
-        out.append((char) (0x80 | c>>12 & 0x3F));
-        out.append((char) (0x80 | c>>6 & 0x3F));
-        out.append((char) (0x80 | c & 0x3F));
+        out.append((char) (0xF8 | (c>>24)));
+        out.append((char) (0x80 | (c>>18 & 0x3F)));
+        out.append((char) (0x80 | (c>>12 & 0x3F)));
+        out.append((char) (0x80 | (c>>6 & 0x3F)));
+        out.append((char) (0x80 | (c & 0x3F)));
     }
     else if (c < 0x80000000)
     {
-        out.append((char) (0xFC | c>>30));
-        out.append((char) (0x80 | c>>24 & 0x3F));
-        out.append((char) (0x80 | c>>18 & 0x3F));
-        out.append((char) (0x80 | c>>12 & 0x3F));
-        out.append((char) (0x80 | c>>6 & 0x3F));
-        out.append((char) (0x80 | c & 0x3F));
+        out.append((char) (0xFC | (c>>30)));
+        out.append((char) (0x80 | (c>>24 & 0x3F)));
+        out.append((char) (0x80 | (c>>18 & 0x3F)));
+        out.append((char) (0x80 | (c>>12 & 0x3F)));
+        out.append((char) (0x80 | (c>>6 & 0x3F)));
+        out.append((char) (0x80 | (c & 0x3F)));
     }
     else
         assertex(false);

+ 2 - 2
system/security/zcrypt/aes.cpp

@@ -1243,7 +1243,7 @@ int Rijndael::blockEncrypt(const UINT8 *input,int inputLen,UINT8 *outBuffer)
                     iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
                     iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
                     iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
-                    iv[3][3] = (iv[3][3] << 1) | (outBuffer[k/8] >> (7-(k&7))) & 1;
+                    iv[3][3] = (iv[3][3] << 1) | ((outBuffer[k/8] >> (7-(k&7))) & 1);
                 }
             }
         break;
@@ -1397,7 +1397,7 @@ int Rijndael::blockDecrypt(const UINT8 *input, int inputLen, UINT8 *outBuffer)
                     iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
                     iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
                     iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
-                    iv[3][3] = (iv[3][3] << 1) | (input[k/8] >> (7-(k&7))) & 1;
+                    iv[3][3] = (iv[3][3] << 1) | ((input[k/8] >> (7-(k&7))) & 1);
                     outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
                 }
             }