Module Name:    src
Committed By:   dholland
Date:           Sun Jan 13 23:17:18 UTC 2013

Modified Files:
        src/sbin/dump: tape.c

Log Message:
Use void * for I/O functions and remove no-longer-needed casts.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/dump/tape.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/dump/tape.c
diff -u src/sbin/dump/tape.c:1.51 src/sbin/dump/tape.c:1.52
--- src/sbin/dump/tape.c:1.51	Sun Jan 13 22:53:01 2013
+++ src/sbin/dump/tape.c	Sun Jan 13 23:17:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: tape.c,v 1.51 2013/01/13 22:53:01 dholland Exp $	*/
+/*	$NetBSD: tape.c,v 1.52 2013/01/13 23:17:18 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)tape.c	8.4 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: tape.c,v 1.51 2013/01/13 22:53:01 dholland Exp $");
+__RCSID("$NetBSD: tape.c,v 1.52 2013/01/13 23:17:18 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -70,8 +70,8 @@ extern	int cartridge;
 extern	const char *host;
 char	*nexttape;
 
-static	ssize_t atomic_read(int, char *, int);
-static	ssize_t atomic_write(int, const char *, int);
+static	ssize_t atomic_read(int, void *, int);
+static	ssize_t atomic_write(int, const void *, int);
 static	void doslave(int, int);
 static	void enslave(void);
 static	void flushtape(void);
@@ -286,7 +286,7 @@ flushtape(void)
 
 	slp->req[trecno].count = 0;			/* Sentinel */
 
-	if (atomic_write(slp->fd, (char *)slp->req, siz) != siz)
+	if (atomic_write(slp->fd, slp->req, siz) != siz)
 		quit("error writing command pipe: %s\n", strerror(errno));
 	slp->sent = 1; /* we sent a request, read the response later */
 
@@ -297,7 +297,7 @@ flushtape(void)
 
 	/* Read results back from next slave */
 	if (slp->sent) {
-		if (atomic_read(slp->fd, (char *)&got, sizeof got)
+		if (atomic_read(slp->fd, &got, sizeof got)
 		    != sizeof got) {
 			perror("  DUMP: error reading command pipe in master");
 			dumpabort(0);
@@ -315,7 +315,7 @@ flushtape(void)
 			for (i = 0; i < SLAVES; i++) {
 				if (slaves[i].sent) {
 					if (atomic_read(slaves[i].fd,
-					    (char *)&got, sizeof got)
+					    &got, sizeof got)
 					    != sizeof got) {
 						perror("  DUMP: error reading command pipe in master");
 						dumpabort(0);
@@ -369,7 +369,7 @@ trewind(int eject)
 		 * fixme: punt for now.
 		 */
 		if (slaves[f].sent) {
-			if (atomic_read(slaves[f].fd, (char *)&got, sizeof got)
+			if (atomic_read(slaves[f].fd, &got, sizeof got)
 			    != sizeof got) {
 				perror("  DUMP: error reading command pipe in master");
 				dumpabort(0);
@@ -508,7 +508,7 @@ rollforward(void)
 			lastspclrec = savedtapea - 1;
 		}
 		size = (char *)ntb - (char *)q;
-		if (atomic_write(slp->fd, (char *)q, size) != size) {
+		if (atomic_write(slp->fd, q, size) != size) {
 			perror("  DUMP: error writing command pipe");
 			dumpabort(0);
 		}
@@ -548,7 +548,7 @@ rollforward(void)
 	 * worked ok, otherwise the tape is much too short!
 	 */
 	if (slp->sent) {
-		if (atomic_read(slp->fd, (char *)&got, sizeof got)
+		if (atomic_read(slp->fd, &got, sizeof got)
 		    != sizeof got) {
 			perror("  DUMP: error reading command pipe in master");
 			dumpabort(0);
@@ -787,7 +787,7 @@ enslave(void)
 
 	for (i = 0; i < SLAVES; i++)
 		(void) atomic_write(slaves[i].fd,
-				(char *) &slaves[(i + 1) % SLAVES].pid,
+				&slaves[(i + 1) % SLAVES].pid,
 				sizeof slaves[0].pid);
 
 	master = 0;
@@ -829,7 +829,7 @@ doslave(int cmd, int slave_number __unus
 	/*
 	 * Need the pid of the next slave in the loop...
 	 */
-	if ((nread = atomic_read(cmd, (char *)&nextslave, sizeof nextslave))
+	if ((nread = atomic_read(cmd, &nextslave, sizeof nextslave))
 	    != sizeof nextslave) {
 		quit("master/slave protocol botched - didn't get pid of next slave.\n");
 	}
@@ -837,7 +837,7 @@ doslave(int cmd, int slave_number __unus
 	/*
 	 * Get list of blocks to dump, read the blocks into tape buffer
 	 */
-	while ((nread = atomic_read(cmd, (char *)slp->req, reqsiz)) == reqsiz) {
+	while ((nread = atomic_read(cmd, slp->req, reqsiz)) == reqsiz) {
 		struct req *p = slp->req;
 
 		for (trecno = 0; trecno < ntrec;
@@ -847,7 +847,7 @@ doslave(int cmd, int slave_number __unus
 					p->count * TP_BSIZE);
 			} else {
 				if (p->count != 1 || atomic_read(cmd,
-				    (char *)slp->tblock[trecno],
+				    slp->tblock[trecno],
 				    TP_BSIZE) != TP_BSIZE)
 				       quit("master/slave protocol botched.\n");
 			}
@@ -915,7 +915,7 @@ doslave(int cmd, int slave_number __unus
 			 * pass size of write back to master
 			 * (for EOT handling)
 			 */
-			(void) atomic_write(cmd, (char *)&size, sizeof size);
+			(void) atomic_write(cmd, &size, sizeof size);
 		}
 
 		/*
@@ -934,12 +934,12 @@ doslave(int cmd, int slave_number __unus
  * loop until the count is satisfied (or error).
  */
 static ssize_t
-atomic_read(int fd, char *buf, int count)
+atomic_read(int fd, void *buf, int count)
 {
 	ssize_t got, need = count;
 
 	while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0)
-		buf += got;
+		buf = (char *)buf + got;
 	return (got < 0 ? got : count - need);
 }
 
@@ -948,11 +948,11 @@ atomic_read(int fd, char *buf, int count
  * loop until the count is satisfied (or error).
  */
 static ssize_t
-atomic_write(int fd, const char *buf, int count)
+atomic_write(int fd, const void *buf, int count)
 {
 	ssize_t got, need = count;
 
 	while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0)
-		buf += got;
+		buf = (const char *)buf + got;
 	return (got < 0 ? got : count - need);
 }

Reply via email to