void file_checksum(char *fname,char *sum,off_t size)
{
- int i;
+ off_t i;
MDstruct MD;
struct map_struct *buf;
int fd;
- int len = size;
+ off_t len = size;
char tmpchunk[CSUM_CHUNK];
bzero(sum,csum_length);
if (!file) return;
if (file->basename) free(file->basename);
if (file->link) free(file->link);
+ if (file->sum) free(file->sum);
bzero((char *)file, sizeof(*file));
free(file);
}
static void matched(int f,struct sum_struct *s,struct map_struct *buf,
- int offset,int i)
+ off_t offset,int i)
{
- int n = offset - last_match;
+ off_t n = offset - last_match;
int j;
if (verbose > 2 && i != -1)
fprintf(FERROR,"match at %d last_match=%d j=%d len=%d n=%d\n",
- (int)offset,(int)last_match,i,(int)s->sums[i].len,n);
+ (int)offset,(int)last_match,i,(int)s->sums[i].len,(int)n);
send_token(f,i,buf,last_match,n,i==-1?0:s->sums[i].len);
data_transfer += n;
static void hash_search(int f,struct sum_struct *s,
struct map_struct *buf,off_t len)
{
- int offset,j,k;
+ off_t offset;
+ int j,k;
int end;
char sum2[SUM_LENGTH];
uint32 s1, s2, sum;
j = tag_table[t];
if (verbose > 4)
- fprintf(FERROR,"offset=%d sum=%08x\n",
- offset,sum);
+ fprintf(FERROR,"offset=%d sum=%08x\n",(int)offset,sum);
if (j == NULL_TAG) {
goto null_tag;
if (verbose > 3)
fprintf(FERROR,"potential match at %d target=%d %d sum=%08x\n",
- offset,j,i,sum);
+ (int)offset,j,i,sum);
if (!done_csum2) {
int l = MIN(s->n,len-offset);
if (fd == -1) {
fprintf(FERROR,"send_files failed to open %s: %s\n",
fname,strerror(errno));
+ free_sums(s);
continue;
}
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
+ free_sums(s);
close(fd);
return -1;
}
};
struct map_struct {
- char *map,*p;
- int fd,size,p_size,p_offset,p_len;
+ char *map,*p;
+ int fd,p_size,p_len;
+ off_t size, p_offset;
};
/* we need this function because of the silly way in which duplicate
return ret;
}
+
char *map_ptr(struct map_struct *map,off_t offset,int len)
{
int nread = -2;
if (len == 0)
return NULL;
- len = MIN(len,map->size-offset);
+ if (len > (map->size-offset))
+ len = map->size-offset;
if (offset >= map->p_offset &&
offset+len <= map->p_offset+map->p_len) {
}
len = MAX(len,CHUNK_SIZE);
- len = MIN(len,map->size - offset);
+ if (len > (map->size-offset))
+ len = map->size-offset;
if (len > map->p_size) {
if (map->p) free(map->p);