git » libjio » commit 497dd46

When compiling with -pedantic (-ansi was just fine) I found out a couple of void * arithmetic that could be messy.

author Alberto Bertogli
2004-05-05 18:06:10 UTC
committer Alberto Bertogli
2007-07-15 12:44:26 UTC
parent 34dccd12c532c15db67bfa61d7ac5f93ef0c8743

When compiling with -pedantic (-ansi was just fine) I found out a couple of void * arithmetic that could be messy.

When compiling with -pedantic (-ansi was just fine) I found out a couple of
void * arithmetic that could be messy.

This patch fixes it up by using the right pointer type (almost unsigned char *
most of the time, because we address buffers byte by byte) on each case.

libjio.c +4 -4

diff --git a/libjio.c b/libjio.c
index 002af47..a0a7e7b 100644
--- a/libjio.c
+++ b/libjio.c
@@ -57,7 +57,7 @@ static ssize_t spread(int fd, void *buf, size_t count, off_t offset)
 	c = 0;
 
 	while (c < count) {
-		rv = pread(fd, buf + c, count - c, offset + c);
+		rv = pread(fd, (char *) buf + c, count - c, offset + c);
 		
 		if (rv == count)
 			/* we're done */
@@ -84,7 +84,7 @@ static ssize_t spwrite(int fd, const void *buf, size_t count, off_t offset)
 	c = 0;
 
 	while (c < count) {
-		rv = pwrite(fd, buf + c, count - c, offset + c);
+		rv = pwrite(fd, (char *) buf + c, count - c, offset + c);
 		
 		if (rv == count)
 			/* we're done */
@@ -267,7 +267,7 @@ int jtrans_commit(struct jtrans *ts)
 {
 	int id, fd, rv, t;
 	char *name;
-	void *buf_init, *bufp;
+	unsigned char *buf_init, *bufp;
 	
 	name = (char *) malloc(PATH_MAX);
 	if (name == NULL)
@@ -763,7 +763,7 @@ int jfsck(char *name, struct jfsck_result *res)
 		}
 		
 		/* load from disk, header first */
-		buf = (char *) malloc(J_DISKTFIXSIZE);
+		buf = (unsigned char *) malloc(J_DISKTFIXSIZE);
 		if (buf == NULL) {
 			res->load_error++;
 			goto loop;