Skip site navigation (1)Skip section navigation (2)
Date:      Tue,  9 Sep 2003 22:25:44 +0200 (CEST)
From:      Stefan Farfeleder <stefan@fafoe.narf.at>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        stefan@fafoe.narf.at
Subject:   bin/56653: [patch] Removal of non-standard void * arithmetics
Message-ID:  <20030909202544.08ACB406@frog.fafoe.narf.at>
Resent-Message-ID: <200309092030.h89KUNg2087990@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         56653
>Category:       bin
>Synopsis:       [patch] Removal of non-standard void * arithmetics
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 09 13:30:20 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Farfeleder
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD frog.fafoe.narf.at 5.1-CURRENT FreeBSD 5.1-CURRENT #7: Sun Sep 7 18:53:15 CEST 2003 freebsd@frog.fafoe.narf.at:/freebsd/frog/obj/freebsd/frog/src/sys/FROG i386


	
>Description:
ISO C (both versions) allows the addition of an integer to a pointer that
has object type only, that is, not void *; the same restriction applies to
pointer subtractions.  We're currently depending on a non-standard GNU
extension, this patch is supposed to fix that.
	
>How-To-Repeat:
	
>Fix:

--- voidptr.diff begins here ---
Index: src/lib/libalias/alias_db.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libalias/alias_db.c,v
retrieving revision 1.53
diff -u -r1.53 alias_db.c
--- src/lib/libalias/alias_db.c	1 Jun 2003 23:15:00 -0000	1.53
+++ src/lib/libalias/alias_db.c	9 Sep 2003 13:00:32 -0000
@@ -2732,7 +2732,7 @@
 
     rule->cmd_len = (u_int32_t *)cmd - (u_int32_t *)rule->cmd;
 
-    return ((void *)cmd - buf);
+    return ((char *)cmd - (char *)buf);
 }
 #endif /* IPFW2 */
 
Index: src/lib/libc/gen/opendir.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libc/gen/opendir.c,v
retrieving revision 1.20
diff -u -r1.20 opendir.c
--- src/lib/libc/gen/opendir.c	16 May 2003 02:15:07 -0000	1.20
+++ src/lib/libc/gen/opendir.c	9 Sep 2003 19:26:10 -0000
@@ -97,7 +97,7 @@
 	    (dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
 		goto fail;
 
-	dirp->dd_td = (void *)dirp + sizeof(DIR);
+	dirp->dd_td = (void *)((char *)dirp + sizeof(DIR));
 	LIST_INIT(&dirp->dd_td->td_locq);
 	dirp->dd_td->td_loccnt = 0;
 
Index: src/lib/libc/rpc/clnt_vc.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libc/rpc/clnt_vc.c,v
retrieving revision 1.15
diff -u -r1.15 clnt_vc.c
--- src/lib/libc/rpc/clnt_vc.c	14 Jul 2002 23:35:04 -0000	1.15
+++ src/lib/libc/rpc/clnt_vc.c	8 Sep 2003 01:03:30 -0000
@@ -738,7 +738,7 @@
 			}
 		}
 	} else {
-		for (cnt = len; cnt > 0; cnt -= i, buf += i) {
+		for (cnt = len; cnt > 0; cnt -= i, buf = (char *)buf + i) {
 			if ((i = _write(ct->ct_fd, buf, (size_t)cnt)) == -1) {
 				ct->ct_error.re_errno = errno;
 				ct->ct_error.re_status = RPC_CANTSEND;
Index: src/lib/libc/rpc/svc_vc.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libc/rpc/svc_vc.c,v
retrieving revision 1.22
diff -u -r1.22 svc_vc.c
--- src/lib/libc/rpc/svc_vc.c	15 Jun 2003 10:55:39 -0000	1.22
+++ src/lib/libc/rpc/svc_vc.c	8 Sep 2003 01:04:05 -0000
@@ -541,7 +541,7 @@
 	if (cd->nonblock)
 		gettimeofday(&tv0, NULL);
 	
-	for (cnt = len; cnt > 0; cnt -= i, buf += i) {
+	for (cnt = len; cnt > 0; cnt -= i, buf = (char *)buf + i) {
 		i = _write(xprt->xp_fd, buf, (size_t)cnt);
 		if (i  < 0) {
 			if (errno != EAGAIN || !cd->nonblock) {
Index: src/lib/libc_r/uthread/uthread_write.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libc_r/uthread/uthread_write.c,v
retrieving revision 1.21
diff -u -r1.21 uthread_write.c
--- src/lib/libc_r/uthread/uthread_write.c	5 Nov 2002 00:59:18 -0000	1.21
+++ src/lib/libc_r/uthread/uthread_write.c	9 Sep 2003 13:15:52 -0000
@@ -78,7 +78,8 @@
 		 */
 		while (ret == 0) {
 			/* Perform a non-blocking write syscall: */
-			n = __sys_write(fd, buf + num, nbytes - num);
+			n = __sys_write(fd, (const char *)buf + num,
+			    nbytes - num);
 
 			/* Check if one or more bytes were written: */
 			if (n > 0)
Index: src/lib/libc_r/uthread/uthread_writev.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libc_r/uthread/uthread_writev.c,v
retrieving revision 1.21
diff -u -r1.21 uthread_writev.c
--- src/lib/libc_r/uthread/uthread_writev.c	12 Nov 2002 19:01:49 -0000	1.21
+++ src/lib/libc_r/uthread/uthread_writev.c	9 Sep 2003 13:17:06 -0000
@@ -134,7 +134,9 @@
 						 * for the next write:
 						 */
 						p_iov[idx].iov_len -= cnt;
-						p_iov[idx].iov_base += cnt;
+						p_iov[idx].iov_base =
+						    (char *)p_iov[idx].iov_base
+						    + cnt;
 						cnt = 0;
 					}
 				}
Index: src/sbin/ldconfig/ldconfig.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/ldconfig/ldconfig.c,v
retrieving revision 1.38
diff -u -r1.38 ldconfig.c
--- src/sbin/ldconfig/ldconfig.c	17 Sep 2002 01:48:53 -0000	1.38
+++ src/sbin/ldconfig/ldconfig.c	8 Sep 2003 14:42:13 -0000
@@ -564,8 +564,8 @@
 	}
 	close(fd);
 
-	blist = (struct hints_bucket *)(addr + hdr->hh_hashtab);
-	strtab = (char *)(addr + hdr->hh_strtab);
+	blist = (struct hints_bucket *)((char *)addr + hdr->hh_hashtab);
+	strtab = (char *)addr + hdr->hh_strtab;
 
 	if (hdr->hh_version >= LD_HINTS_VERSION_2)
 		add_search_path(strtab + hdr->hh_dirlist);
Index: src/sbin/ping/ping.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/ping/ping.c,v
retrieving revision 1.101
diff -u -r1.101 ping.c
--- src/sbin/ping/ping.c	14 Jul 2003 12:43:48 -0000	1.101
+++ src/sbin/ping/ping.c	9 Sep 2003 19:33:50 -0000
@@ -954,7 +954,7 @@
 #else
 			tp = icp->icmp_data;
 #endif
-			tp += phdr_len;
+			tp = (const char *)tp + phdr_len;
 
 			if (cc - ICMP_MINLEN - phdr_len >= sizeof(tv1)) {
 				/* Copy to avoid alignment problems: */
--- voidptr.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030909202544.08ACB406>