summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2bda77e)
raw | patch | inline | side by side (parent: 2bda77e)
author | Florian Forster <octo@verplant.org> | |
Sun, 18 Jun 2006 15:18:09 +0000 (17:18 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 20 Jun 2006 08:59:46 +0000 (01:59 -0700) |
ANSI C99 doesn't allow void-pointer arithmetic. This patch fixes this in
various ways. Usually the strategy that required the least changes was used.
Signed-off-by: Florian Forster <octo@verplant.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
various ways. Usually the strategy that required the least changes was used.
Signed-off-by: Florian Forster <octo@verplant.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
19 files changed:
builtin-apply.c | patch | blob | history | |
convert-objects.c | patch | blob | history | |
csum-file.c | patch | blob | history | |
diff-delta.c | patch | blob | history | |
diff.c | patch | blob | history | |
diffcore-order.c | patch | blob | history | |
http-fetch.c | patch | blob | history | |
http-push.c | patch | blob | history | |
http.c | patch | blob | history | |
pack-check.c | patch | blob | history | |
pack-objects.c | patch | blob | history | |
pack-redundant.c | patch | blob | history | |
patch-delta.c | patch | blob | history | |
pkt-line.c | patch | blob | history | |
read-cache.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
ssh-fetch.c | patch | blob | history | |
tag.c | patch | blob | history | |
tree-walk.c | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index e113c74dd80d458116788500baca2740cfaa9a00..6dd0472ae07cac291d26b9e547a92c7c51d569df 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
buffer = xrealloc(buffer, alloc);
nr = alloc - size;
}
- nr = xread(fd, buffer + size, nr);
+ nr = xread(fd, (char *) buffer + size, nr);
if (!nr)
break;
if (nr < 0)
*/
if (alloc < size + SLOP)
buffer = xrealloc(buffer, size + SLOP);
- memset(buffer + size, 0, SLOP);
+ memset((char *) buffer + size, 0, SLOP);
return buffer;
}
@@ -1194,7 +1194,7 @@ static int read_old_data(struct stat *st, const char *path, void *buf, unsigned
return error("unable to open %s", path);
got = 0;
for (;;) {
- int ret = xread(fd, buf + got, size - got);
+ int ret = xread(fd, (char *) buf + got, size - got);
if (ret <= 0)
break;
got += ret;
diff --git a/convert-objects.c b/convert-objects.c
index a67d6b479ec57816de1b259f9efed2258e999703..0fabd8981c6047e5144cfb3776b4f4a5588f24e5 100644 (file)
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -103,12 +103,12 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base
if (!slash) {
newlen += sprintf(new + newlen, "%o %s", mode, path);
new[newlen++] = '\0';
- memcpy(new + newlen, buffer + len - 20, 20);
+ memcpy(new + newlen, (char *) buffer + len - 20, 20);
newlen += 20;
used += len;
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
continue;
}
@@ -121,7 +121,7 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base
used += len;
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
}
write_sha1_file(new, newlen, tree_type, result_sha1);
@@ -137,13 +137,13 @@ static void convert_tree(void *buffer, unsigned long size, unsigned char *result
while (size) {
int len = 1+strlen(buffer);
- convert_binary_sha1(buffer + len);
+ convert_binary_sha1((char *) buffer + len);
len += 20;
if (len > size)
die("corrupt tree object");
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
}
write_subdirectory(orig_buffer, orig_size, "", 0, result_sha1);
@@ -244,14 +244,14 @@ static void convert_date(void *buffer, unsigned long size, unsigned char *result
// "tree <sha1>\n"
memcpy(new + newlen, buffer, 46);
newlen += 46;
- buffer += 46;
+ buffer = (char *) buffer + 46;
size -= 46;
// "parent <sha1>\n"
while (!memcmp(buffer, "parent ", 7)) {
memcpy(new + newlen, buffer, 48);
newlen += 48;
- buffer += 48;
+ buffer = (char *) buffer + 48;
size -= 48;
}
@@ -275,11 +275,11 @@ static void convert_commit(void *buffer, unsigned long size, unsigned char *resu
if (memcmp(buffer, "tree ", 5))
die("Bad commit '%s'", (char*) buffer);
- convert_ascii_sha1(buffer+5);
- buffer += 46; /* "tree " + "hex sha1" + "\n" */
+ convert_ascii_sha1((char *) buffer + 5);
+ buffer = (char *) buffer + 46; /* "tree " + "hex sha1" + "\n" */
while (!memcmp(buffer, "parent ", 7)) {
- convert_ascii_sha1(buffer+7);
- buffer += 48;
+ convert_ascii_sha1((char *) buffer + 7);
+ buffer = (char *) buffer + 48;
}
convert_date(orig_buffer, orig_size, result_sha1);
}
diff --git a/csum-file.c b/csum-file.c
index 5f9249aeedfa7d4156cf412da6a7e7d77f33ff86..ebaad0397f0bce50db7542abb904ba42b6173344 100644 (file)
--- a/csum-file.c
+++ b/csum-file.c
for (;;) {
int ret = xwrite(f->fd, buf, count);
if (ret > 0) {
- buf += ret;
+ buf = (char *) buf + ret;
count -= ret;
if (count)
continue;
memcpy(f->buffer + offset, buf, nr);
count -= nr;
offset += nr;
- buf += nr;
+ buf = (char *) buf + nr;
left -= nr;
if (!left) {
SHA1_Update(&f->ctx, f->buffer, offset);
diff --git a/diff-delta.c b/diff-delta.c
index 74486b1b81419d0078d8f1e43c96db437d6d4f65..8b9172aa2ef7402b0a847815bb11a26d1c4444fe 100644 (file)
--- a/diff-delta.c
+++ b/diff-delta.c
ref_data = index->src_buf;
ref_top = ref_data + index->src_size;
data = trg_buf;
- top = trg_buf + trg_size;
+ top = (const unsigned char *) trg_buf + trg_size;
outpos++;
val = 0;
index 9e9cfc8b75b7b761980b0d32cb0c516ea3505ba3..fb1411c52d1cce9c51ad33272624e4d027debc2e 100644 (file)
--- a/diff.c
+++ b/diff.c
else
line[0] = bytes - 26 + 'a' - 1;
encode_85(line + 1, cp, bytes);
- cp += bytes;
+ cp = (char *) cp + bytes;
puts(line);
}
printf("\n");
diff --git a/diffcore-order.c b/diffcore-order.c
index 0bc2b22f848457a8e6ffafc6a1d9a26be677209f..aef6da60447b98a05d91513b4aa74e505b0a0d84 100644 (file)
--- a/diffcore-order.c
+++ b/diffcore-order.c
close(fd);
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;
diff --git a/http-fetch.c b/http-fetch.c
index 3a2cb5e1fc1b2794f632c5ddbedfa99500081e5a..2b63d89501cc8838cca96506b3532d33fc452a15 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
struct object_request *obj_req = (struct object_request *)data;
do {
ssize_t retval = write(obj_req->local,
- ptr + posn, size - posn);
+ (char *) ptr + posn, size - posn);
if (retval < 0)
return posn;
posn += retval;
diff --git a/http-push.c b/http-push.c
index aaf155c5bcb5b7587afa1a3063316d3183020984..9853619687a25501d1dee052f39ebeedcbd8dc69 100644 (file)
--- a/http-push.c
+++ b/http-push.c
struct transfer_request *request = (struct transfer_request *)data;
do {
ssize_t retval = write(request->local_fileno,
- ptr + posn, size - posn);
+ (char *) ptr + posn, size - posn);
if (retval < 0)
return posn;
posn += retval;
index 08769cc7cd4282a485fb9cd22c4ecfa97096a419..6c1937b676ecd584cededed1c82df30448046ebe 100644 (file)
--- a/http.c
+++ b/http.c
size_t size = eltsize * nmemb;
if (size > buffer->size - buffer->posn)
size = buffer->size - buffer->posn;
- memcpy(ptr, buffer->buffer + buffer->posn, size);
+ memcpy(ptr, (char *) buffer->buffer + buffer->posn, size);
buffer->posn += size;
return size;
}
buffer->size = buffer->posn + size;
buffer->buffer = xrealloc(buffer->buffer, buffer->size);
}
- memcpy(buffer->buffer + buffer->posn, ptr, size);
+ memcpy((char *) buffer->buffer + buffer->posn, ptr, size);
buffer->posn += size;
data_received++;
return size;
diff --git a/pack-check.c b/pack-check.c
index e57587909e54d9317a18e3bfd43559562a40f0d5..3a62e1b7e40927390e10ae63943596a367ecbf47 100644 (file)
--- a/pack-check.c
+++ b/pack-check.c
pack_base = p->pack_base;
SHA1_Update(&ctx, pack_base, pack_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, pack_base + pack_size - 20, 20))
+ if (memcmp(sha1, (char *) pack_base + pack_size - 20, 20))
return error("Packfile %s SHA1 mismatch with itself",
p->pack_name);
- if (memcmp(sha1, index_base + index_size - 40, 20))
+ if (memcmp(sha1, (char *) index_base + index_size - 40, 20))
return error("Packfile %s SHA1 mismatch with idx",
p->pack_name);
SHA1_Init(&ctx);
SHA1_Update(&ctx, index_base, index_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, index_base + index_size - 20, 20))
+ if (memcmp(sha1, (char *) index_base + index_size - 20, 20))
ret = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
diff --git a/pack-objects.c b/pack-objects.c
index 179560f2bd67e08d25bef0199c41ee0ee70793f9..ba6525d1f4786dad167994bf7a635c13b2b08ef6 100644 (file)
--- a/pack-objects.c
+++ b/pack-objects.c
rix->revindex = xmalloc(sizeof(unsigned long) * (num_ent + 1));
for (i = 0; i < num_ent; i++) {
- unsigned int hl = *((unsigned int *)(index + 24 * i));
+ unsigned int hl = *((unsigned int *)((char *) index + 24*i));
rix->revindex[i] = ntohl(hl);
}
/* This knows the pack format -- the 20-byte trailer
use_packed_git(p);
datalen = find_packed_object_size(p, entry->in_pack_offset);
- buf = p->pack_base + entry->in_pack_offset;
+ buf = (char *) p->pack_base + entry->in_pack_offset;
sha1write(f, buf, datalen);
unuse_packed_git(p);
hdrlen = 0; /* not really */
diff --git a/pack-redundant.c b/pack-redundant.c
index cd81f5a66eae2a4c1fdab4086b896d6a06dcf687..41fb960569e1c7ed479fb123902752c552ff1341 100644 (file)
--- a/pack-redundant.c
+++ b/pack-redundant.c
static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
{
int p1_off, p2_off;
- void *p1_base, *p2_base;
+ unsigned char *p1_base, *p2_base;
struct llist_item *p1_hint = NULL, *p2_hint = NULL;
-
+
p1_off = p2_off = 256 * 4 + 4;
- p1_base = (void *)p1->pack->index_base;
- p2_base = (void *)p2->pack->index_base;
+ p1_base = (unsigned char *) p1->pack->index_base;
+ p2_base = (unsigned char *) p2->pack->index_base;
while (p1_off <= p1->pack->index_size - 3 * 20 &&
p2_off <= p2->pack->index_size - 3 * 20)
{
size_t ret = 0;
int p1_off, p2_off;
- void *p1_base, *p2_base;
+ char *p1_base, *p2_base;
p1_off = p2_off = 256 * 4 + 4;
- p1_base = (void *)p1->index_base;
- p2_base = (void *)p2->index_base;
+ p1_base = (char *)p1->index_base;
+ p2_base = (char *)p2->index_base;
while (p1_off <= p1->index_size - 3 * 20 &&
p2_off <= p2->index_size - 3 * 20)
{
struct pack_list l;
size_t off;
- void *base;
+ unsigned char *base;
if (!p->pack_local && !(alt_odb || verbose))
return NULL;
llist_init(&l.all_objects);
off = 256 * 4 + 4;
- base = (void *)p->index_base;
+ base = (unsigned char *)p->index_base;
while (off <= p->index_size - 3 * 20) {
llist_insert_back(l.all_objects, base + off);
off += 24;
diff --git a/patch-delta.c b/patch-delta.c
index 8f318ed8aaf180419f97887501317fc1d2b54c09..e3a1d425ee2e333bce0f87b1e50fc112a8ec51a3 100644 (file)
--- a/patch-delta.c
+++ b/patch-delta.c
return NULL;
data = delta_buf;
- top = delta_buf + delta_size;
+ top = (const unsigned char *) delta_buf + delta_size;
/* make sure the orig file size matches what we expect */
size = get_delta_hdr_size(&data, top);
cp_off + cp_size > src_size ||
cp_size > size)
goto bad;
- memcpy(out, src_buf + cp_off, cp_size);
+ memcpy(out, (char *) src_buf + cp_off, cp_size);
out += cp_size;
size -= cp_size;
} else if (cmd) {
diff --git a/pkt-line.c b/pkt-line.c
index bb3bab05cd203e114b24b778cb5f55218abdec95..44d42969e558cf85aca41cf29604dcfda4ebaf7e 100644 (file)
--- a/pkt-line.c
+++ b/pkt-line.c
while (n) {
int ret = xwrite(fd, buf, n);
if (ret > 0) {
- buf += ret;
+ buf = (char *) buf + ret;
n -= ret;
continue;
}
int n = 0;
while (n < size) {
- int ret = xread(fd, buffer + n, size - n);
+ int ret = xread(fd, (char *) buffer + n, size - n);
if (ret < 0)
die("read error (%s)", strerror(errno));
if (!ret)
diff --git a/read-cache.c b/read-cache.c
index c499c5185678b6b4ac35d57d1ab0b36cc2ff056b..3c32aae7e8ae63bccad83a603f2b86c66965cd26 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
SHA1_Init(&c);
SHA1_Update(&c, hdr, size - 20);
SHA1_Final(sha1, &c);
- if (memcmp(sha1, (void *)hdr + size - 20, 20))
+ if (memcmp(sha1, (char *) hdr + size - 20, 20))
return error("bad index file sha1 signature");
return 0;
}
offset = sizeof(*hdr);
for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = map + offset;
+ struct cache_entry *ce = (struct cache_entry *) ((char *) map + offset);
offset = offset + ce_size(ce);
active_cache[i] = ce;
}
* in 4-byte network byte order.
*/
unsigned long extsize;
- memcpy(&extsize, map + offset + 4, 4);
+ memcpy(&extsize, (char *) map + offset + 4, 4);
extsize = ntohl(extsize);
- if (read_index_extension(map + offset,
- map + offset + 8, extsize) < 0)
+ if (read_index_extension(((const char *) map) + offset,
+ (char *) map + offset + 8,
+ extsize) < 0)
goto unmap;
offset += 8;
offset += extsize;
}
write_buffer_len = buffered;
len -= partial;
- data += partial;
+ data = (char *) data + partial;
}
return 0;
}
diff --git a/sha1_file.c b/sha1_file.c
index b4ff233bad3c15692610f93549b25cd0cf042392..c80528b506e98c1e1dae463fa08159677a2a9473 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
* this is cheap.
*/
if (memcmp((char*)(p->index_base) + p->index_size - 40,
- p->pack_base + p->pack_size - 20, 20)) {
-
+ (char *) p->pack_base + p->pack_size - 20,
+ 20)) {
+
die("packfile %s does not match index.", p->pack_name);
}
}
@@ -701,7 +702,7 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size
int bytes = strlen(buffer) + 1;
unsigned char *buf = xmalloc(1+size);
- memcpy(buf, buffer + bytes, stream->total_out - bytes);
+ memcpy(buf, (char *) buffer + bytes, stream->total_out - bytes);
bytes = stream->total_out - bytes;
if (bytes < size) {
stream->next_out = buf + bytes;
@@ -853,7 +854,7 @@ static unsigned long unpack_object_header(struct packed_git *p, unsigned long of
if (offset >= p->pack_size)
die("object offset outside of pack file");
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
c = *pack++;
offset++;
*type = (c >> 4) & 7;
ptr = unpack_object_header(p, ptr, kindp, sizep);
if (*kindp != OBJ_DELTA)
goto done;
- memcpy(base, p->pack_base + ptr, 20);
+ memcpy(base, (char *) p->pack_base + ptr, 20);
status = 0;
done:
unuse_packed_git(p);
enum object_type kind;
offset = unpack_object_header(p, e->offset, &kind, size);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
if (kind != OBJ_DELTA)
*delta_chain_length = 0;
else {
find_pack_entry_one(pack, &base_ent, p);
offset = unpack_object_header(p, base_ent.offset,
&kind, &junk);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
chain_length++;
} while (kind == OBJ_DELTA);
*delta_chain_length = chain_length;
die("cannot map packed file");
offset = unpack_object_header(p, entry->offset, &kind, &size);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
left = p->pack_size - offset;
switch (kind) {
void *retval;
offset = unpack_object_header(p, entry->offset, &kind, &size);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
left = p->pack_size - offset;
switch (kind) {
case OBJ_DELTA:
void *index = p->index_base + 256;
if (n < 0 || num_packed_objects(p) <= n)
return -1;
- memcpy(sha1, (index + 24 * n + 4), 20);
+ memcpy(sha1, (char *) index + (24 * n) + 4, 20);
return 0;
}
do {
int mi = (lo + hi) / 2;
- int cmp = memcmp(index + 24 * mi + 4, sha1, 20);
+ int cmp = memcmp((char *) index + (24 * mi) + 4, sha1, 20);
if (!cmp) {
- e->offset = ntohl(*((unsigned int *)(index + 24 * mi)));
+ e->offset = ntohl(*((unsigned int *) ((char *) index + (24 * mi))));
memcpy(e->sha1, sha1, 20);
e->p = p;
return 1;
ref_length = strlen(ref_type);
if (memcmp(buffer, ref_type, ref_length) ||
- get_sha1_hex(buffer + ref_length, actual_sha1)) {
+ get_sha1_hex((char *) buffer + ref_length, actual_sha1)) {
free(buffer);
return NULL;
}
return error("file write error (%s)", strerror(errno));
}
len -= size;
- buf += size;
+ buf = (char *) buf + size;
}
return 0;
}
diff --git a/ssh-fetch.c b/ssh-fetch.c
index e3067b878e8721886c9fe61b136b46415165671d..1e59cd2008d8089efef74b940d1a1094add7e687 100644 (file)
--- a/ssh-fetch.c
+++ b/ssh-fetch.c
{
ssize_t ret = 0;
while (ret < length) {
- ssize_t size = write(fd, buffer + ret, length - ret);
+ ssize_t size = write(fd, (char *) buffer + ret, length - ret);
if (size < 0) {
return size;
}
index 91913332709eb67252a776ddd1995e183a1a5bf5..bee8a09cbf5fec119e9b2555beb4cb8b38d8057e 100644 (file)
--- a/tag.c
+++ b/tag.c
if (size < 64)
return -1;
- if (memcmp("object ", data, 7) || get_sha1_hex(data + 7, object))
+ if (memcmp("object ", data, 7) || get_sha1_hex((char *) data + 7, object))
return -1;
- type_line = data + 48;
+ type_line = (char *) data + 48;
if (memcmp("\ntype ", type_line-1, 6))
return -1;
diff --git a/tree-walk.c b/tree-walk.c
index 297c6972b9256578f9cd7a92404dda55c8e34a2e..3f83e98f3a443e4537f53abf32bcca1389c5d9d8 100644 (file)
--- a/tree-walk.c
+++ b/tree-walk.c
if (size < len)
die("corrupt tree file");
- desc->buf = buf + len;
+ desc->buf = (char *) buf + len;
desc->size = size - len;
}
const void *tree = desc->buf;
unsigned long size = desc->size;
int len = strlen(tree)+1;
- const unsigned char *sha1 = tree + len;
+ const unsigned char *sha1 = (unsigned char *) tree + len;
const char *path;
unsigned int mode;
int tree_entry(struct tree_desc *desc, struct name_entry *entry)
{
- const void *tree = desc->buf, *path;
+ const void *tree = desc->buf;
+ const char *path;
unsigned long len, size = desc->size;
if (!size)
entry->pathlen = len;
path += len + 1;
- entry->sha1 = path;
+ entry->sha1 = (const unsigned char *) path;
path += 20;
- len = path - tree;
+ len = path - (char *) tree;
if (len > size)
die("corrupt tree file");