Branko Čibej wrote:
>Greg Hudson wrote:
>
>
>>But you're right; the size and expanded_size fields of a
>>representation_t should be svn_filesize_t's, because of what they
>>represent. I will fix, but I can't find a gcc 3.2.3 option to warn
>>about implicit type narrowing, so I can't guarantee that I've fixed all
>>the warnings.
>>
>>
>That's fine. MSVC will warn about it, so I can fix the remaining ones
>once the types are changed. I didn't want to meddle with the FSFS
>structures myself.
>
>
Here's a patch that removes the last warnings from fs_fs.c:
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c (revision 9944)
+++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
@@ -846,11 +846,11 @@
str = apr_strtok (NULL, " ", &last_str);
if (! str) goto err;
- rep_args->base_offset = apr_atoi64 (str);
+ rep_args->base_offset = (apr_off_t) apr_atoi64 (str);
str = apr_strtok (NULL, " ", &last_str);
if (! str) goto err;
- rep_args->base_length = apr_atoi64 (str);
+ rep_args->base_length = (apr_size_t) apr_atoi64 (str);
*rep_args_p = rep_args;
return SVN_NO_ERROR;
@@ -1281,7 +1281,7 @@
copy_len = remaining;
rs = rb->src_state;
if (((apr_off_t) copy_len) > rs->end - rs->off)
- copy_len = rs->end - rs->off;
+ copy_len = (apr_size_t) (rs->end - rs->off);
SVN_ERR (svn_io_file_read_full (rs->file, cur, copy_len, NULL,
rb->pool));
rs->off += copy_len;
I /think/ all three casts are safe. The last one obviously is, because
the number gets checked safely just before the assignment. The first one
doesn't actually trigger a warning on Win32, where apr_off_t has 64
bits, but could do on platforms without largefile support. The second
one is a case of reading what you wrote before, so it should be safe, too..
Of course, ideally we'd always check the value against the bounds of the
narrower type before a narrowing cast, but hey, this isn't flight
control software (yet :-).
--
Brane Čibej <brane_at_xbc.nu> http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jun 10 08:40:44 2004