binaryurp/source/writer.cxx |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

New commits:
commit c480677f5f654ada532dfba21e3d34718c977131
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Fri Sep 16 10:52:25 2016 +0200

    In binaryurp, fix change from rtl_copyMemory to memcpy
    
    ...done in 36a2db3722b79ed3df075d7f3fa77fb761bcf5a4 "Replace usage of
    rtl_*Memory with equivalent from string.h"
    
    Change-Id: I068feab3140cdcb34ea8c80e273ea2761f0efb7f
    Reviewed-on: https://gerrit.libreoffice.org/28941
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>
    Tested-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx
index 7558f82..54373d1 100644
--- a/binaryurp/source/writer.cxx
+++ b/binaryurp/source/writer.cxx
@@ -19,9 +19,12 @@
 
 #include "sal/config.h"
 
+#include <cassert>
+#include <cstddef>
+#include <cstring>
 #include <exception>
+#include <limits>
 #include <vector>
-#include <string.h>
 
 #include "com/sun/star/connection/XConnection.hpp"
 #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
@@ -411,18 +414,17 @@ void Writer::sendMessage(std::vector< unsigned char > 
const & buffer) {
     OSL_ASSERT(!buffer.empty());
     unsigned char const * p = &buffer[0];
     std::vector< unsigned char >::size_type n = buffer.size();
-    OSL_ASSERT(header.size() <= SAL_MAX_INT32 && SAL_MAX_INT32 <= 
SAL_MAX_SIZE);
-    sal_Size k = SAL_MAX_INT32 - header.size();
+    OSL_ASSERT(header.size() <= SAL_MAX_INT32);
+    /*static_*/assert(SAL_MAX_INT32 <= 
std::numeric_limits<std::size_t>::max());
+    std::size_t k = SAL_MAX_INT32 - header.size();
     if (n < k) {
-        k = static_cast< sal_Size >(n);
+        k = n;
     }
-    css::uno::Sequence< sal_Int8 > s(
-        static_cast< sal_Int32 >(header.size() + k));
+    css::uno::Sequence<sal_Int8> s(header.size() + k);
     OSL_ASSERT(!header.empty());
-    memcpy(
-        s.getArray(), &header[0], static_cast< sal_Size >(header.size()));
+    std::memcpy(s.getArray(), &header[0], header.size());
     for (;;) {
-        memcpy(s.getArray() + s.getLength() - k, p, k);
+        std::memcpy(s.getArray() + s.getLength() - k, p, k);
         try {
             bridge_->getConnection()->write(s);
         } catch (const css::io::IOException & e) {
@@ -431,14 +433,14 @@ void Writer::sendMessage(std::vector< unsigned char > 
const & buffer) {
                 "Binary URP write raised IO exception: " + e.Message,
                 css::uno::Reference< css::uno::XInterface >(), exc);
         }
-        n = static_cast< std::vector< unsigned char >::size_type >(n - k);
+        n -= k;
         if (n == 0) {
             break;
         }
         p += k;
         k = SAL_MAX_INT32;
         if (n < k) {
-            k = static_cast< sal_Size >(n);
+            k = n;
         }
         s.realloc(k);
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to