Use an explicit cast when a value gets stored in a smaller var.
authorWayne Davison <wayned@samba.org>
Tue, 21 Nov 2006 08:35:58 +0000 (08:35 +0000)
committerWayne Davison <wayned@samba.org>
Tue, 21 Nov 2006 08:35:58 +0000 (08:35 +0000)
checksum.c
fileio.c
flist.c
generator.c
match.c
options.c
util.c

index c8b6cdf..9b62023 100644 (file)
@@ -95,11 +95,11 @@ void get_checksum2(char *buf, int32 len, char *sum)
 
 void file_checksum(char *fname,char *sum,OFF_T size)
 {
-       OFF_T i;
        struct map_struct *buf;
-       int fd;
-       OFF_T len = size;
+       OFF_T i, len = size;
        struct mdfour m;
+       int32 remainder;
+       int fd;
 
        memset(sum,0,MD4_SUM_LENGTH);
 
@@ -120,8 +120,9 @@ void file_checksum(char *fname,char *sum,OFF_T size)
         * by failing to call mdfour_tail() for block sizes that
         * are multiples of 64.  This is fixed by calling mdfour_update()
         * even when there are no more bytes. */
-       if (len - i > 0 || protocol_version >= 27)
-               mdfour_update(&m, (uchar *)map_ptr(buf, i, len-i), len-i);
+       remainder = (int32)(len - i);
+       if (remainder > 0 || protocol_version >= 27)
+               mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
 
        mdfour_result(&m, (uchar *)sum);
 
index 5a3bf35..a1b68d1 100644 (file)
--- a/fileio.c
+++ b/fileio.c
@@ -190,7 +190,7 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
        window_start = offset;
        window_size = map->def_window_size;
        if (window_start + window_size > map->file_size)
-               window_size = map->file_size - window_start;
+               window_size = (int32)(map->file_size - window_start);
        if (len > window_size)
                window_size = len;
 
@@ -208,7 +208,7 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
            window_start < map->p_offset + map->p_len &&
            window_start + window_size >= map->p_offset + map->p_len) {
                read_start = map->p_offset + map->p_len;
-               read_offset = read_start - window_start;
+               read_offset = (int32)(read_start - window_start);
                read_size = window_size - read_offset;
                memmove(map->p, map->p + (map->p_len - read_offset), read_offset);
        } else {
diff --git a/flist.c b/flist.c
index 8b24b0a..5b80f3e 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -455,8 +455,8 @@ static void send_file_entry(struct file_struct *file, int f)
        if (file->link_u.idev) {
                if (protocol_version < 26) {
                        /* 32-bit dev_t and ino_t */
-                       write_int(f, dev);
-                       write_int(f, file->F_INODE);
+                       write_int(f, (int32)dev);
+                       write_int(f, (int32)file->F_INODE);
                } else {
                        /* 64-bit dev_t and ino_t */
                        if (!(flags & XMIT_SAME_DEV))
@@ -1450,10 +1450,10 @@ int flist_find(struct file_list *flist, struct file_struct *f)
                        if (mid_up > high) {
                                /* If there's nothing left above us, set high to
                                 * a non-empty entry below us and continue. */
-                               high = mid - flist->files[mid]->length;
+                               high = mid - (int)flist->files[mid]->length;
                                if (!flist->files[high]->basename) {
                                        do {
-                                           high -= flist->files[high]->length;
+                                           high -= (int)flist->files[high]->length;
                                        } while (!flist->files[high]->basename);
                                        flist->files[mid]->length = mid - high;
                                }
index 453cff5..ffd8ab7 100644 (file)
@@ -526,8 +526,8 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len)
        sum->flength    = len;
        sum->blength    = blength;
        sum->s2length   = s2length;
-       sum->remainder  = len % blength;
-       sum->count      = len / blength + (sum->remainder != 0);
+       sum->remainder  = (int32)(len % blength);
+       sum->count      = (int32)(len / blength) + (sum->remainder != 0);
 
        if (sum->count && verbose > 2) {
                rprintf(FINFO,
diff --git a/match.c b/match.c
index 72947d0..cbc856c 100644 (file)
--- a/match.c
+++ b/match.c
@@ -85,7 +85,7 @@ static OFF_T last_match;
 static void matched(int f, struct sum_struct *s, struct map_struct *buf,
                    OFF_T offset, int32 i)
 {
-       int32 n = offset - last_match; /* max value: block_size (int32) */
+       int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */
        int32 j;
 
        if (verbose > 2 && i >= 0) {
@@ -121,8 +121,8 @@ static void matched(int f, struct sum_struct *s, struct map_struct *buf,
 static void hash_search(int f,struct sum_struct *s,
                        struct map_struct *buf, OFF_T len)
 {
-       OFF_T offset, end, backup;
-       int32 k, want_i;
+       OFF_T offset, end;
+       int32 k, want_i, backup;
        char sum2[SUM_LENGTH];
        uint32 s1, s2, sum;
        int more;
@@ -254,7 +254,7 @@ static void hash_search(int f,struct sum_struct *s,
                } while ((i = s->sums[i].chain) >= 0);
 
          null_hash:
-               backup = offset - last_match;
+               backup = (int32)(offset - last_match);
                /* We sometimes read 1 byte prior to last_match... */
                if (backup < 0)
                        backup = 0;
@@ -324,7 +324,7 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
                        last_match = j;
                }
                if (last_match < s->flength) {
-                       int32 len = s->flength - last_match;
+                       int32 len = (int32)(s->flength - last_match);
                        if (buf && do_progress)
                                show_progress(last_match, buf->file_size);
                        sum_update(map_ptr(buf, last_match, len), len);
index dd47894..fc8d605 100644 (file)
--- a/options.c
+++ b/options.c
@@ -756,7 +756,7 @@ static OFF_T parse_size_arg(char **size_arg, char def_suf)
                OFF_T num = size;
                *s = '\0';
                while (num) {
-                       *--s = (num % 10) + '0';
+                       *--s = (char)(num % 10) + '0';
                        num /= 10;
                }
                if (!(*size_arg = strdup(s)))
diff --git a/util.c b/util.c
index 40f00d2..cdf68bc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1128,7 +1128,7 @@ char *human_num(int64 num)
        if (!num)
                *--s = '0';
        while (num) {
-               *--s = (num % 10) + '0';
+               *--s = (char)(num % 10) + '0';
                num /= 10;
        }
        return s;