aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2006-11-21 08:35:58 +0000
committerWayne Davison <wayned@samba.org>2006-11-21 08:35:58 +0000
commit264042760bd909eeca281dc8c937357e98bf6bf8 (patch)
treeb4c302f4453df23aa47d35d340fbabfe4e537e45
parent1e999f9f1b6940a4b355054b5f15435c3030996c (diff)
downloadandroid_external_rsync-264042760bd909eeca281dc8c937357e98bf6bf8.tar.gz
android_external_rsync-264042760bd909eeca281dc8c937357e98bf6bf8.tar.bz2
android_external_rsync-264042760bd909eeca281dc8c937357e98bf6bf8.zip
Use an explicit cast when a value gets stored in a smaller var.
-rw-r--r--checksum.c11
-rw-r--r--fileio.c4
-rw-r--r--flist.c8
-rw-r--r--generator.c4
-rw-r--r--match.c10
-rw-r--r--options.c2
-rw-r--r--util.c2
7 files changed, 21 insertions, 20 deletions
diff --git a/checksum.c b/checksum.c
index c8b6cdf6..9b620230 100644
--- a/checksum.c
+++ b/checksum.c
@@ -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);
diff --git a/fileio.c b/fileio.c
index 5a3bf352..a1b68d1c 100644
--- 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 8b24b0a1..5b80f3e1 100644
--- 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;
}
diff --git a/generator.c b/generator.c
index 453cff56..ffd8ab71 100644
--- a/generator.c
+++ b/generator.c
@@ -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 72947d0a..cbc856c2 100644
--- 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);
diff --git a/options.c b/options.c
index dd47894d..fc8d6056 100644
--- 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 40f00d27..cdf68bcb 100644
--- 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;