summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2020-12-03 22:37:12 +0000
committercheloha <cheloha@openbsd.org>2020-12-03 22:37:12 +0000
commit2724571b5981d3ed7e944ac1b3ebcd0530089ac7 (patch)
treeb00b5dc1d7e7c517ad36b67bcb207f413b3348db /bin
parentFix type mismatch. auth_method should be uint8_t. (diff)
downloadwireguard-openbsd-2724571b5981d3ed7e944ac1b3ebcd0530089ac7.tar.xz
wireguard-openbsd-2724571b5981d3ed7e944ac1b3ebcd0530089ac7.zip
cat(1): remove global 'filename' variable
There is no need for the global filename variable. Both cook_buf() and raw_cat() can accept a filename variable from the caller to use for printing warnings. ok martijn@
Diffstat (limited to 'bin')
-rw-r--r--bin/cat/cat.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 609e000db9f..a602e0f1581 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cat.c,v 1.27 2019/06/28 13:34:58 deraadt Exp $ */
+/* $OpenBSD: cat.c,v 1.28 2020/12/03 22:37:12 cheloha Exp $ */
/* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */
/*
@@ -51,12 +51,11 @@ extern char *__progname;
int bflag, eflag, nflag, sflag, tflag, vflag;
int rval;
-char *filename;
void cook_args(char *argv[]);
-void cook_buf(FILE *);
+void cook_buf(FILE *, const char *);
void raw_args(char *argv[]);
-void raw_cat(int);
+void raw_cat(int, const char *);
int
main(int argc, char *argv[])
@@ -108,6 +107,7 @@ main(int argc, char *argv[])
void
cook_args(char **argv)
{
+ char *filename;
FILE *fp;
fp = stdin;
@@ -124,7 +124,7 @@ cook_args(char **argv)
}
filename = *argv++;
}
- cook_buf(fp);
+ cook_buf(fp, filename);
if (fp == stdin)
clearerr(fp);
else
@@ -133,7 +133,7 @@ cook_args(char **argv)
}
void
-cook_buf(FILE *fp)
+cook_buf(FILE *fp, const char *filename)
{
int ch, gobble, line, prev;
@@ -198,6 +198,7 @@ cook_buf(FILE *fp)
void
raw_args(char **argv)
{
+ char *filename;
int fd;
fd = fileno(stdin);
@@ -214,14 +215,14 @@ raw_args(char **argv)
}
filename = *argv++;
}
- raw_cat(fd);
+ raw_cat(fd, filename);
if (fd != fileno(stdin))
(void)close(fd);
} while (*argv);
}
void
-raw_cat(int rfd)
+raw_cat(int rfd, const char *filename)
{
int wfd;
ssize_t nr, nw, off;