[Sheepdog] [PATCH 08/12] avoid using a void pointer in arithmetic

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri May 21 13:42:35 CEST 2010


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 lib/logger.c |    8 ++++----
 lib/net.c    |    6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index 542fe5a..5779418 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -90,7 +90,7 @@ static int logarea_init (int size)
 	shmctl(shmid, IPC_RMID, NULL);
 
 	la->empty = 1;
-	la->end = la->start + size;
+	la->end = (char *)la->start + size;
 	la->head = la->start;
 	la->tail = la->start;
 
@@ -175,7 +175,7 @@ static int log_enqueue(int prio, const char *func, int line, const char *fmt,
 	if (!la->empty) {
 		fwd = sizeof(struct logmsg) +
 		      strlen((char *)&lastmsg->str) * sizeof(char) + 1;
-		la->tail += fwd;
+		la->tail = (char *)la->tail + fwd;
 	}
 
 	p = buff;
@@ -206,14 +206,14 @@ static int log_enqueue(int prio, const char *func, int line, const char *fmt,
 
 	/* not enough space on tail : rewind */
 	if (la->head <= la->tail &&
-	    (len + sizeof(struct logmsg)) > (la->end - la->tail)) {
+	    (len + sizeof(struct logmsg)) > ((char *)la->end - (char *)la->tail)) {
 		logdbg(stderr, "enqueue: rewind tail to %p\n", la->tail);
 			la->tail = la->start;
 	}
 
 	/* not enough space on head : drop msg */
 	if (la->head > la->tail &&
-	    (len + sizeof(struct logmsg)) > (la->head - la->tail)) {
+	    (len + sizeof(struct logmsg)) > ((char *)la->head - (char *)la->tail)) {
 		logdbg(stderr, "enqueue: log area overrun, drop msg\n");
 
 		if (!la->empty)
diff --git a/lib/net.c b/lib/net.c
index 2459a0c..9b260ab 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -59,7 +59,7 @@ int rx(struct connection *conn, enum conn_state next_state)
 	}
 
 	conn->rx_length -= ret;
-	conn->rx_buf += ret;
+	conn->rx_buf = (char *)conn->rx_buf + ret;
 
 	if (!conn->rx_length)
 		conn->c_rx_state = next_state;
@@ -81,7 +81,7 @@ again:
 	}
 
 	conn->tx_length -= ret;
-	conn->tx_buf += ret;
+	conn->tx_buf = (char *)conn->tx_buf + ret;
 
 	if (conn->tx_length)
 		goto again;
@@ -243,7 +243,7 @@ reread:
 	}
 
 	len -= ret;
-	buf += ret;
+	buf = (char *)buf + ret;
 	if (len)
 		goto reread;
 
-- 
1.5.6.5




More information about the sheepdog mailing list