summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2019-03-10 20:49:24 +0000
committerschwarze <schwarze@openbsd.org>2019-03-10 20:49:24 +0000
commita0a3ab15d80385465aa844b128dbcd5ec72dd765 (patch)
treedcd0a16bbac3c24a2a26e1c0ced8b705d5040be9
parentDelete useless call to setlocale(3): (diff)
downloadwireguard-openbsd-a0a3ab15d80385465aa844b128dbcd5ec72dd765.tar.xz
wireguard-openbsd-a0a3ab15d80385465aa844b128dbcd5ec72dd765.zip
Delete useless calls to setlocale(3):
uudecode(1) and uuencode(1) do nothing locale-dependent. While here, sort headers, make usage() static, return from main() rather than exit(3), and drop two redundant case statements. This is a minimally tweaked version of a patch from Jan Stary. OK tedu@
-rw-r--r--usr.bin/uudecode/uudecode.c12
-rw-r--r--usr.bin/uuencode/uuencode.c12
2 files changed, 9 insertions, 15 deletions
diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c
index bc71e5e760d..528a1725221 100644
--- a/usr.bin/uudecode/uudecode.c
+++ b/usr.bin/uudecode/uudecode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uudecode.c,v 1.25 2018/12/31 13:49:52 bluhm Exp $ */
+/* $OpenBSD: uudecode.c,v 1.26 2019/03/10 20:49:24 schwarze Exp $ */
/* $FreeBSD: uudecode.c,v 1.49 2003/05/03 19:44:46 obrien Exp $ */
/*-
@@ -42,20 +42,19 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <locale.h>
+#include <limits.h>
#include <pwd.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <limits.h>
static const char *infile, *outfile;
static FILE *infp, *outfp;
static int base64, cflag, iflag, oflag, pflag, rflag, sflag;
-static void usage(void);
+static void __dead usage(void);
static int decode(void);
static int decode2(void);
static int uu_decode(void);
@@ -82,7 +81,6 @@ main(int argc, char *argv[])
pmode = MODE_B64DECODE;
}
- setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, optstr[pmode])) != -1) {
switch(ch) {
case 'c':
@@ -153,7 +151,7 @@ main(int argc, char *argv[])
infp = stdin;
rval = decode();
}
- exit(rval);
+ return (rval);
}
static int
@@ -448,7 +446,7 @@ base64_decode(void)
"error decoding base64 input stream"));
}
-static void
+static void __dead
usage(void)
{
switch (pmode) {
diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c
index 8e1e48990d8..4bdd82d0975 100644
--- a/usr.bin/uuencode/uuencode.c
+++ b/usr.bin/uuencode/uuencode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uuencode.c,v 1.14 2018/12/31 09:23:08 kn Exp $ */
+/* $OpenBSD: uuencode.c,v 1.15 2019/03/10 20:49:24 schwarze Exp $ */
/* $FreeBSD: uuencode.c,v 1.18 2004/01/22 07:23:35 grehan Exp $ */
/*-
@@ -39,7 +39,6 @@
#include <netinet/in.h>
#include <err.h>
-#include <locale.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
@@ -48,7 +47,7 @@
void encode(void);
void base64_encode(void);
-static void usage(void);
+static void __dead usage(void);
FILE *output;
int mode;
@@ -80,7 +79,6 @@ main(int argc, char *argv[])
pmode = MODE_B64ENCODE;
}
- setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, optstr[pmode])) != -1) {
switch (ch) {
case 'm':
@@ -89,7 +87,6 @@ main(int argc, char *argv[])
case 'o':
outfile = optarg;
break;
- case '?':
default:
usage();
}
@@ -117,7 +114,6 @@ main(int argc, char *argv[])
#define RW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
mode = RW & ~umask(RW);
break;
- case 0:
default:
usage();
}
@@ -136,7 +132,7 @@ main(int argc, char *argv[])
encode();
if (ferror(output))
errx(1, "write error");
- exit(0);
+ return 0;
}
/* ENC is the basic 1 character encoding function to make a char printing */
@@ -219,7 +215,7 @@ encode(void)
(void)fprintf(output, "%c\nend\n", ENC('\0'));
}
-static void
+static void __dead
usage(void)
{
switch (pmode) {