Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/tee use more appropriate types



details:   https://anonhg.NetBSD.org/src/rev/c80e5d353842
branches:  trunk
changeset: 785267:c80e5d353842
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Mar 06 11:44:11 2013 +0000

description:
use more appropriate types
remove unnecessary casts

diffstat:

 usr.bin/tee/tee.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (60 lines):

diff -r 91770b4bb26d -r c80e5d353842 usr.bin/tee/tee.c
--- a/usr.bin/tee/tee.c Wed Mar 06 11:42:18 2013 +0000
+++ b/usr.bin/tee/tee.c Wed Mar 06 11:44:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tee.c,v 1.10 2012/03/20 20:34:59 matt Exp $    */
+/*     $NetBSD: tee.c,v 1.11 2013/03/06 11:44:11 yamt Exp $    */
 
 /*
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)tee.c      8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: tee.c,v 1.10 2012/03/20 20:34:59 matt Exp $");
+__RCSID("$NetBSD: tee.c,v 1.11 2013/03/06 11:44:11 yamt Exp $");
 #endif
 
 #include <sys/types.h>
@@ -68,8 +68,8 @@
 main(int argc, char *argv[])
 {
        LIST *p;
-       int n, fd, rval, wval;
-       char *bp;
+       ssize_t rval;
+       int fd;
        int append, ch, exitval;
        char *buf;
 #define        BSIZE (8 * 1024)
@@ -93,7 +93,7 @@
        argv += optind;
        argc -= optind;
 
-       if ((buf = malloc((size_t)BSIZE)) == NULL)
+       if ((buf = malloc(BSIZE)) == NULL)
                err(1, "malloc");
 
        add(STDOUT_FILENO, "stdout");
@@ -108,8 +108,10 @@
 
        while ((rval = read(STDIN_FILENO, buf, BSIZE)) > 0)
                for (p = head; p; p = p->next) {
-                       n = rval;
-                       bp = buf;
+                       const char *bp = buf;
+                       size_t n = rval;
+                       ssize_t wval;
+
                        do {
                                if ((wval = write(p->fd, bp, n)) == -1) {
                                        warn("%s", p->name);
@@ -139,7 +141,7 @@
 {
        LIST *p;
 
-       if ((p = malloc((size_t)sizeof(LIST))) == NULL)
+       if ((p = malloc(sizeof(LIST))) == NULL)
                err(1, "malloc");
        p->fd = fd;
        p->name = name;



Home | Main Index | Thread Index | Old Index