svn commit: r1934523 - subversion/trunk/subversion/libsvn_diff

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <177948774438.2265215.16300281068376170330@svn03-he-fi>
Author: ivan
Date: Fri May 22 22:09:04 2026
New Revision: 1934523

Log:
Remove several type casts by using more appropriate type.

* subversion/libsvn_diff/diff_file.c
  (offset_in_chunk): Return apr_size_t instead of apr_off_t -- offset in chunk
   cannot be larger than 128 KB.
  (read_chunk): Use apr_size_t instead of apr_off_t for LENGTH argument.
   Remove typecast.
  (increment_chunk): Use apr_size_t instead of apr_off_t for LENGTH local
   variable. 
  (find_identical_suffix): Use apr_size_t[4] instead of apr_off_t[4] for
   LENGTH local variable.
  (datasources_open): Use apr_size_t[4] instead of apr_off_t[4] for
   LENGTH local variable. Remove now redundant type cast.

Modified:
   subversion/trunk/subversion/libsvn_diff/diff_file.c

Modified: subversion/trunk/subversion/libsvn_diff/diff_file.c
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/diff_file.c	Fri May 22 21:42:24 2026	(r1934522)
+++ subversion/trunk/subversion/libsvn_diff/diff_file.c	Fri May 22 22:09:04 2026	(r1934523)
@@ -142,7 +142,7 @@ offset_to_chunk(apr_off_t offset)
   return offset >> CHUNK_SHIFT;
 }
 
-static APR_INLINE apr_off_t
+static APR_INLINE apr_size_t
 offset_in_chunk(apr_off_t offset)
 {
   return offset & (CHUNK_SIZE - 1);
@@ -153,14 +153,14 @@ offset_in_chunk(apr_off_t offset)
  */
 static APR_INLINE svn_error_t *
 read_chunk(apr_file_t *file,
-           char *buffer, apr_off_t length,
+           char *buffer, apr_size_t length,
            apr_off_t offset, apr_pool_t *scratch_pool)
 {
   /* XXX: The final offset may not be the one we asked for.
    * XXX: Check.
    */
   SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, scratch_pool));
-  return svn_io_file_read_full2(file, buffer, (apr_size_t) length,
+  return svn_io_file_read_full2(file, buffer, length,
                                 NULL, NULL, scratch_pool);
 }
 
@@ -281,7 +281,7 @@ map_or_read_file(apr_file_t **file,
 static svn_error_t *
 increment_chunk(struct file_info *file, apr_pool_t *pool)
 {
-  apr_off_t length;
+  apr_size_t length;
   apr_off_t last_chunk = offset_to_chunk(file->size);
 
   if (file->chunk == -1)
@@ -482,7 +482,7 @@ find_identical_suffix(apr_off_t *suffix_
                       apr_size_t file_len, apr_pool_t *pool)
 {
   struct file_info file_for_suffix[4] = { { 0 }  };
-  apr_off_t length[4];
+  apr_size_t length[4];
   apr_off_t suffix_min_chunk0;
   apr_off_t suffix_min_offset0;
   apr_off_t min_file_size;
@@ -663,7 +663,7 @@ datasources_open(void *baton,
 {
   svn_diff__file_baton_t *file_baton = baton;
   struct file_info files[4];
-  apr_off_t length[4];
+  apr_size_t length[4];
 #ifndef SVN_DISABLE_PREFIX_SUFFIX_SCANNING
   svn_boolean_t reached_one_eof;
 #endif
@@ -685,7 +685,7 @@ datasources_open(void *baton,
       SVN_ERR(svn_io_file_size_get(&filesize, file->file, file_baton->pool));
       file->size = filesize;
       length[i] = filesize > CHUNK_SIZE ? CHUNK_SIZE : filesize;
-      file->buffer = apr_palloc(file_baton->pool, (apr_size_t) length[i]);
+      file->buffer = apr_palloc(file_baton->pool, length[i]);
       SVN_ERR(read_chunk(file->file, file->buffer,
                          length[i], 0, file_baton->pool));
       file->endp = file->buffer + length[i];
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.