A few general bugfixes:

- Use internal xmalloc instead of malloc.
- Include missing header after warnings.
- Fix unneeded printouts.
- Fix a bug when checking the CO_NORSYNC flag.
This commit is contained in:
lulf 2008-11-19 14:57:00 +00:00
parent 49d71b6584
commit b389e1bc70
4 changed files with 12 additions and 13 deletions

View File

@ -39,6 +39,7 @@
#include "config.h"
#include "detailer.h"
#include "fixups.h"
#include "globtree.h"
#include "misc.h"
#include "mux.h"
#include "proto.h"
@ -398,22 +399,21 @@ detailer_dofile_rsync(struct detailer *d, char *name, char *path)
struct stream *wr;
struct rsyncfile *rf;
wr = d->wr;
rf = rsync_open(path, 0, 1);
if (rf == NULL) {
/* Fallback if we fail in opening it. */
proto_printf(wr, "A %s\n", name);
return (0);
}
wr = d->wr;
proto_printf(wr, "r %s %z %z\n", name, rsync_filesize(rf),
rsync_blocksize(rf));
/* Detail the blocks. */
while (rsync_nextblock(rf) != 0) {
while (rsync_nextblock(rf) != 0)
proto_printf(wr, "%s %s\n", rsync_rsum(rf), rsync_blockmd5(rf));
lprintf(-1, "%s %s\n", rsync_rsum(rf), rsync_blockmd5(rf));
}
proto_printf(wr, ".\n");
rsync_close(rf);
return (0);
}
/*
@ -599,7 +599,7 @@ detailer_send_details(struct detailer *d, struct coll *coll, char *name,
} else if (fattr_type(fa) == FT_FILE) {
if (isrcs(name, &len) && !(coll->co_options & CO_NORCS)) {
detailer_dofile_rcs(d, coll, name, path);
} else if (!(coll->co_options & CO_NORSYNC) ||
} else if (!(coll->co_options & CO_NORSYNC) &&
!globtree_test(coll->co_norsync, name)) {
detailer_dofile_rsync(d, name, path);
} else {

View File

@ -708,7 +708,6 @@ rcsfile_print(struct rcsfile *rf)
line = stream_getln(in, NULL);
}
stream_close(in);
printf("branches: ");
printf("\n");
}
@ -761,6 +760,7 @@ rcsfile_free(struct rcsfile *rf)
/* Free all deltas in global list */
while (!LIST_EMPTY(&rf->deltatable)) {
d = LIST_FIRST(&rf->deltatable);
LIST_REMOVE(d, delta_next);
LIST_REMOVE(d, table_next);
rcsfile_freedelta(d);
}

View File

@ -77,9 +77,7 @@ rsync_open(char *path, size_t blocksize, int read)
struct stat st;
int error;
rf = malloc(sizeof(*rf));
if (rf == NULL)
return (NULL);
rf = xmalloc(sizeof(*rf));
error = stat(path, &st);
if (error) {
free(rf);

View File

@ -615,12 +615,12 @@ updater_docoll(struct updater *up, struct file_update *fup, int isfixups)
error = fup_prepare(fup, name, 0);
if (error)
return (UPDATER_ERR_PROTO);
sr->sr_type = SR_FILELIVE;
fup->wantmd5 = xstrdup(wantmd5);
fup->temppath = tempname(fup->destpath);
sr = &fup->srbuf;
sr->sr_file = xstrdup(name);
sr->sr_serverattr = fattr_decode(attr);
sr->sr_type = SR_FILELIVE;
if (sr->sr_serverattr == NULL)
return (UPDATER_ERR_PROTO);
error = updater_rsync(up, fup, strtol(blocksize, NULL,
@ -1841,8 +1841,10 @@ updater_addelta(struct rcsfile *rf, struct stream *rd, char *cmdline)
/* First add the delta so we have it. */
d = rcsfile_addelta(rf, revnum, revdate, author, diffbase);
if (d == NULL)
err(1, "Error adding delta %s\n", revnum);
if (d == NULL) {
lprintf(-1, "Error adding delta %s\n", revnum);
return (UPDATER_ERR_READ);
}
while ((line = stream_getln(rd, NULL)) != NULL) {
if (strcmp(line, ".") == 0)
break;
@ -2077,7 +2079,6 @@ updater_rsync(struct updater *up, struct file_update *fup, size_t blocksize)
goto bad;
/* Read blocks from original file. */
lseek(orig, SEEK_SET, (blocksize * blockstart));
blocknum = 0;
error = UPDATER_ERR_MSG;
for (blocknum = 0; blocknum < blockcount; blocknum++) {
nbytes = read(orig, buf, blocksize);