Just some cleaning up while I was surfing the code:

  * Sort headers + spacing (KNF)
  * Remove pointless casts
  * ssize_t for read(2) and write(2) return values

Index: tee.c
===================================================================
RCS file: /cvs/OpenBSD/src/usr.bin/tee/tee.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 tee.c
--- tee.c       19 Jun 2009 18:35:19 -0000      1.1.1.1
+++ tee.c       19 Jun 2009 18:59:41 -0000
@@ -43,17 +43,18 @@ static char sccsid[] = "@(#)tee.c   8.1 (B
 static char rcsid[] = "$OpenBSD: tee.c,v 1.6 2003/06/10 22:20:53 deraadt Exp 
$";
 #endif
 
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <signal.h>
+#include <sys/types.h>
+
+#include <err.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <unistd.h>
+#include <locale.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <locale.h>
-#include <err.h>
+#include <unistd.h>
 
 typedef struct _list {
        struct _list *next;
@@ -68,17 +69,17 @@ int
 main(int argc, char *argv[])
 {
        LIST *p;
-       int n, fd, rval, wval;
-       char *bp;
+       int fd;
+       ssize_t n, rval, wval;
        int append, ch, exitval;
-       char *buf;
-#define        BSIZE (8 * 1024)
+       char *bp, *buf;
+#define        BSIZE (8U * 1024U)
 
        setlocale(LC_ALL, "");
 
        append = 0;
        while ((ch = getopt(argc, argv, "ai")) != -1)
-               switch((char)ch) {
+               switch(ch) {
                case 'a':
                        append = 1;
                        break;
@@ -93,7 +94,7 @@ main(int argc, char *argv[])
        argv += optind;
        argc -= optind;
 
-       if ((buf = malloc((size_t)BSIZE)) == NULL)
+       if ((buf = malloc(BSIZE)) == NULL)
                err(1, NULL);
 
        add(STDOUT_FILENO, "stdout");
@@ -139,7 +140,7 @@ add(int fd, char *name)
 {
        LIST *p;
 
-       if ((p = malloc((size_t)sizeof(LIST))) == NULL)
+       if ((p = malloc(sizeof(LIST))) == NULL)
                err(1, NULL);
        p->fd = fd;
        p->name = name;

Reply via email to