Cast pointer math results.

All instances are not expected to overflow and would not result in
tragedy in the extremely unlikely event that overflow does happen.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/4792d3e8
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4792d3e8
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4792d3e8

Branch: refs/heads/master
Commit: 4792d3e842920c2b101ec160164f256ac23ba498
Parents: a94f500
Author: Marvin Humphrey <[email protected]>
Authored: Thu May 26 19:00:53 2016 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Thu May 26 19:02:37 2016 -0700

----------------------------------------------------------------------
 core/Lucy/Index/DocVector.c          | 2 +-
 core/Lucy/Search/PhraseMatcher.c     | 2 +-
 core/Lucy/Store/InStream.c           | 2 +-
 core/Lucy/Util/SortExternal.c        | 4 ++--
 core/LucyX/Search/ProximityMatcher.c | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4792d3e8/core/Lucy/Index/DocVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c
index 2bc8192..8c29540 100644
--- a/core/Lucy/Index/DocVector.c
+++ b/core/Lucy/Index/DocVector.c
@@ -144,7 +144,7 @@ S_extract_tv_cache(Blob *field_buf) {
             NumUtil_skip_cint(&tv_string);
             NumUtil_skip_cint(&tv_string);
         }
-        len = tv_string - bookmark_ptr;
+        len = (size_t)(tv_string - bookmark_ptr);
 
         // Store the $text => $posdata pair in the output hash.
         String *text = BB_Trusted_Utf8_To_String(text_buf);

http://git-wip-us.apache.org/repos/asf/lucy/blob/4792d3e8/core/Lucy/Search/PhraseMatcher.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/PhraseMatcher.c b/core/Lucy/Search/PhraseMatcher.c
index f0ffa5c..740ed50 100644
--- a/core/Lucy/Search/PhraseMatcher.c
+++ b/core/Lucy/Search/PhraseMatcher.c
@@ -240,7 +240,7 @@ MATCH:
 
 DONE:
     // Return number of anchors remaining.
-    return anchors_found - anchors_start;
+    return (uint32_t)(anchors_found - anchors_start);
 }
 
 float

http://git-wip-us.apache.org/repos/asf/lucy/blob/4792d3e8/core/Lucy/Store/InStream.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.c b/core/Lucy/Store/InStream.c
index 1a758ca..1317aa9 100644
--- a/core/Lucy/Store/InStream.c
+++ b/core/Lucy/Store/InStream.c
@@ -530,7 +530,7 @@ InStream_Read_Raw_C64_IMP(InStream *self, char *buf) {
     do {
         *dest = SI_read_u8(self, ivars);
     } while ((*dest++ & 0x80) != 0);
-    return dest - (uint8_t*)buf;
+    return (int)(dest - (uint8_t*)buf);
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4792d3e8/core/Lucy/Util/SortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c
index ee520a6..9e2a8ec 100644
--- a/core/Lucy/Util/SortExternal.c
+++ b/core/Lucy/Util/SortExternal.c
@@ -365,7 +365,7 @@ S_merge(SortExternal *self,
         if (compare(self, left_ptr, right_ptr) <= 0) {
             *dest++ = *left_ptr++;
             if (left_ptr >= left_limit) {
-                right_size = right_limit - right_ptr;
+                right_size = (size_t)(right_limit - right_ptr);
                 memcpy(dest, right_ptr, right_size * sizeof(Obj*));
                 break;
             }
@@ -373,7 +373,7 @@ S_merge(SortExternal *self,
         else {
             *dest++ = *right_ptr++;
             if (right_ptr >= right_limit) {
-                left_size = left_limit - left_ptr;
+                left_size = (size_t)(left_limit - left_ptr);
                 memcpy(dest, left_ptr, left_size * sizeof(Obj*));
                 break;
             }

http://git-wip-us.apache.org/repos/asf/lucy/blob/4792d3e8/core/LucyX/Search/ProximityMatcher.c
----------------------------------------------------------------------
diff --git a/core/LucyX/Search/ProximityMatcher.c 
b/core/LucyX/Search/ProximityMatcher.c
index e72b61c..e72bdc2 100644
--- a/core/LucyX/Search/ProximityMatcher.c
+++ b/core/LucyX/Search/ProximityMatcher.c
@@ -245,7 +245,7 @@ MATCH:
 
 DONE:
     // Return number of anchors remaining.
-    return anchors_found - anchors_start;
+    return (uint32_t)(anchors_found - anchors_start);
 }
 
 float

Reply via email to