Repository: mesos
Updated Branches:
  refs/heads/master 071e8cfbe -> 3eaab8a2e


Windows: Patched protobuf to fix warnings.

The patch was generated by diffing the following commit against tag
v3.5.0, this was merged upstream in
https://github.com/google/protobuf/pull/4000:

commit 80809271a
Author: Rodrigo Hernandez <[email protected]>
Date:   Mon Dec 4 19:04:42 2017 -0600

    Using binary one's complement to negate an unsigned int

    This removes a Visual Studio warning:

    warning C4146: unary minus operator applied to unsigned type, result
    still unsigned.

And the addition of three static casts to make the return of
`std::distance` match the LHS type.

With the patch applied, we can stop disabling all warnings for protobuf
code (which didn't entirely work anyway, because these warnings were in
public headers included everywhere in Mesos).


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3eaab8a2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3eaab8a2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3eaab8a2

Branch: refs/heads/master
Commit: 3eaab8a2e37e6d9c3a7e74123611637d20aa9729
Parents: bd7b1f3
Author: Andrew Schwartzmeyer <[email protected]>
Authored: Wed Dec 13 16:01:52 2017 -0800
Committer: Andrew Schwartzmeyer <[email protected]>
Committed: Fri Dec 15 15:57:56 2017 -0800

----------------------------------------------------------------------
 3rdparty/CMakeLists.txt       |  3 +++
 3rdparty/protobuf-3.5.0.patch | 46 ++++++++++++++++++++++++++++++++++++++
 src/CMakeLists.txt            |  5 -----
 3 files changed, 49 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3eaab8a2/3rdparty/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index dbbe75a..d9f52e2 100755
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -783,6 +783,8 @@ if (WIN32)
     IMPORTED_LOCATION_DEBUG 
${PROTOBUF_ROOT}-build/Debug/libprotobufd${LIBRARY_SUFFIX}
     IMPORTED_LOCATION_RELEASE 
${PROTOBUF_ROOT}-build/Release/libprotobuf${LIBRARY_SUFFIX})
 
+  PATCH_CMD(PROTOBUF_PATCH_CMD protobuf-${PROTOBUF_VERSION}.patch)
+
   set_target_properties(
     protoc PROPERTIES
     IMPORTED_LOCATION_DEBUG ${PROTOBUF_ROOT}-build/Debug/protoc.exe
@@ -808,6 +810,7 @@ GET_BYPRODUCTS(protobuf)
 ExternalProject_Add(
   ${PROTOBUF_TARGET}
   PREFIX            ${PROTOBUF_CMAKE_ROOT}
+  PATCH_COMMAND     ${PROTOBUF_PATCH_CMD}
   BUILD_BYPRODUCTS  ${PROTOBUF_BYPRODUCTS}
   SOURCE_SUBDIR     cmake
   CMAKE_ARGS        ${CMAKE_FORWARD_ARGS};-Dprotobuf_BUILD_TESTS=OFF

http://git-wip-us.apache.org/repos/asf/mesos/blob/3eaab8a2/3rdparty/protobuf-3.5.0.patch
----------------------------------------------------------------------
diff --git a/3rdparty/protobuf-3.5.0.patch b/3rdparty/protobuf-3.5.0.patch
new file mode 100644
index 0000000..19da2c7
--- /dev/null
+++ b/3rdparty/protobuf-3.5.0.patch
@@ -0,0 +1,46 @@
+diff --git c/src/google/protobuf/repeated_field.h 
w/src/google/protobuf/repeated_field.h
+index 8eb6c795b..faa930523 100644
+--- c/src/google/protobuf/repeated_field.h
++++ w/src/google/protobuf/repeated_field.h
+@@ -86,7 +86,7 @@ void LogIndexOutOfBounds(int index, int size);
+ 
+ template <typename Iter>
+ inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) {
+-  return std::distance(begin, end);
++  return static_cast<int>(std::distance(begin, end));
+ }
+ 
+ template <typename Iter>
+@@ -2123,8 +2123,8 @@ RepeatedPtrField<Element>::erase(const_iterator 
position) {
+ template <typename Element>
+ inline typename RepeatedPtrField<Element>::iterator
+ RepeatedPtrField<Element>::erase(const_iterator first, const_iterator last) {
+-  size_type pos_offset = std::distance(cbegin(), first);
+-  size_type last_offset = std::distance(cbegin(), last);
++  size_type pos_offset = static_cast<size_type>(std::distance(cbegin(), 
first));
++  size_type last_offset = static_cast<size_type>(std::distance(cbegin(), 
last));
+   DeleteSubrange(pos_offset, last_offset - pos_offset);
+   return begin() + pos_offset;
+ }
+diff --git c/src/google/protobuf/wire_format_lite.h 
w/src/google/protobuf/wire_format_lite.h
+index cf614c02a..361920b8e 100644
+--- c/src/google/protobuf/wire_format_lite.h
++++ w/src/google/protobuf/wire_format_lite.h
+@@ -860,7 +860,7 @@ inline uint32 WireFormatLite::ZigZagEncode32(int32 n) {
+ 
+ inline int32 WireFormatLite::ZigZagDecode32(uint32 n) {
+   // Note:  Using unsigned types prevent undefined behavior
+-  return static_cast<int32>((n >> 1) ^ -(n & 1));
++  return static_cast<int32>((n >> 1) ^ (~(n & 1) + 1));
+ }
+ 
+ inline uint64 WireFormatLite::ZigZagEncode64(int64 n) {
+@@ -871,7 +871,7 @@ inline uint64 WireFormatLite::ZigZagEncode64(int64 n) {
+ 
+ inline int64 WireFormatLite::ZigZagDecode64(uint64 n) {
+   // Note:  Using unsigned types prevent undefined behavior
+-  return static_cast<int64>((n >> 1) ^ -(n & 1));
++  return static_cast<int64>((n >> 1) ^ (~(n & 1) + 1));
+ }
+ 
+ // String is for UTF-8 text only, but, even so, ReadString() can simply

http://git-wip-us.apache.org/repos/asf/mesos/blob/3eaab8a2/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4062be0..5b54153 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -96,11 +96,6 @@ target_link_libraries(mesos-protobufs PUBLIC protobuf)
 target_include_directories(
   mesos-protobufs PUBLIC ${MESOS_PROTOBUF_HEADER_INCLUDE_DIRS})
 
-if (WIN32)
-  # Disable all compiler warnings on Protocol Buffers source.
-  target_compile_options(mesos-protobufs PRIVATE "/w")
-endif ()
-
 
 # BUILD JAVA ARTIFACTS.
 #######################

Reply via email to