int i;
for (i = 0; i < rr->nr; i++) {
const char *path = rr->items[i].path;
- write(out_fd, rr->items[i].util, 40);
- write(out_fd, "\t", 1);
- write(out_fd, path, strlen(path) + 1);
+ int length = strlen(path) + 1;
+ if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
+ write_in_full(out_fd, "\t", 1) != 1 ||
+ write_in_full(out_fd, path, length) != length)
+ die("unable to write rerere record");
}
close(out_fd);
return commit_lock_file(&write_lock);
{
int i;
for (i = 0; i < nbuf; i++)
- write(1, ptr[i].ptr, ptr[i].size);
+ if (write_in_full(1, ptr[i].ptr, ptr[i].size) != ptr[i].size)
+ return -1;
return 0;
}
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
copy_file(path, rr_path(name, "postimage"));
tail_optimization:
- if (i < rr->nr - 1) {
+ if (i < rr->nr - 1)
memmove(rr->items + i,
- rr->items + i + 1,
- rr->nr - i - 1);
- }
+ rr->items + i + 1,
+ sizeof(rr->items[0]) * (rr->nr - i - 1));
rr->nr--;
i--;
}