}
map = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
close(fd);
- if (-1 == (int)(long)map)
+ if (map == MAP_FAILED)
return;
- endp = map + st.st_size;
+ endp = (char *) map + st.st_size;
for (pass = 0; pass < 2; pass++) {
cnt = 0;
cp = map;
void diffcore_order(const char *orderfile)
{
struct diff_queue_struct *q = &diff_queued_diff;
- struct pair_order *o = xmalloc(sizeof(*o) * q->nr);
+ struct pair_order *o;
int i;
+ if (!q->nr)
+ return;
+
+ o = xmalloc(sizeof(*o) * q->nr);
prepare_order(orderfile);
for (i = 0; i < q->nr; i++) {
o[i].pair = q->queue[i];