Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/dump Use void * for I/O functions and remove no-longer-...



details:   https://anonhg.NetBSD.org/src/rev/04ac666e9210
branches:  trunk
changeset: 783975:04ac666e9210
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 13 23:17:18 2013 +0000

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

diffstat:

 sbin/dump/tape.c |  38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diffs (157 lines):

diff -r 16f7a5ea1bc0 -r 04ac666e9210 sbin/dump/tape.c
--- a/sbin/dump/tape.c  Sun Jan 13 23:07:16 2013 +0000
+++ b/sbin/dump/tape.c  Sun Jan 13 23:17:18 2013 +0000
@@ -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 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 @@
 
        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 @@
 
        /* 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 @@
                        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 @@
                 * 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 @@
                        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 @@
         * 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 @@
 
        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 @@
        /*
         * 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 @@
        /*
         * 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 @@
                                        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 @@
                         * 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 @@
  * 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 @@
  * 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);
 }



Home | Main Index | Thread Index | Old Index