summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-10-28 07:23:00 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-10-28 07:23:00 +0000
commite1eb93081c1a15355b195a51873d6f833e4d6fcc (patch)
tree0b541d83cf7ca112e060ac73fc158ecf71fccd2d /usr.bin
parent1b87e303329de4689e89673013329a46d50ee901 (diff)
Delete some useless setlocale(3) calls in /usr/bin, no functional change.
Patches from Jan Stary <hans at stare dot cz>, tweaked by me and tb@. While here, apply some simple style improvements: Sort headers, static void __dead usage(), return from main(), zap case '?', drop /* NOTREACHED */, drop break after usage(), ... OK tb@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/basename/basename.c12
-rw-r--r--usr.bin/cmp/cmp.c20
-rw-r--r--usr.bin/csplit/csplit.c10
-rw-r--r--usr.bin/dirname/dirname.c11
-rw-r--r--usr.bin/env/env.c11
-rw-r--r--usr.bin/getconf/getconf.c17
-rw-r--r--usr.bin/nice/nice.c13
-rw-r--r--usr.bin/tee/tee.c17
-rw-r--r--usr.bin/uname/uname.c17
-rw-r--r--usr.bin/which/which.c13
10 files changed, 53 insertions, 88 deletions
diff --git a/usr.bin/basename/basename.c b/usr.bin/basename/basename.c
index 21f63b0fbef..f2d8c820ee1 100644
--- a/usr.bin/basename/basename.c
+++ b/usr.bin/basename/basename.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: basename.c,v 1.13 2015/12/24 17:11:47 mmcc Exp $ */
+/* $OpenBSD: basename.c,v 1.14 2016/10/28 07:22:59 schwarze Exp $ */
/* $NetBSD: basename.c,v 1.9 1995/09/02 05:29:46 jtc Exp $ */
/*-
@@ -32,13 +32,12 @@
#include <err.h>
#include <libgen.h>
-#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-void usage(void);
+static void __dead usage(void);
int
main(int argc, char *argv[])
@@ -46,8 +45,6 @@ main(int argc, char *argv[])
int ch;
char *p;
- setlocale(LC_ALL, "");
-
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
@@ -65,7 +62,7 @@ main(int argc, char *argv[])
if (**argv == '\0') {
(void)puts("");
- exit(0);
+ return 0;
}
p = basename(*argv);
if (p == NULL)
@@ -93,7 +90,8 @@ main(int argc, char *argv[])
}
extern char *__progname;
-void
+
+static void __dead
usage(void)
{
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index 58f6758ece0..ec95882c1a6 100644
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmp.c,v 1.15 2016/08/14 18:34:48 guenther Exp $ */
+/* $OpenBSD: cmp.c,v 1.16 2016/10/28 07:22:59 schwarze Exp $ */
/* $NetBSD: cmp.c,v 1.7 1995/09/08 03:22:56 tls Exp $ */
/*
@@ -39,13 +39,12 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <locale.h>
#include "extern.h"
int lflag, sflag;
-static void usage(void);
+static void __dead usage(void);
int
main(int argc, char *argv[])
@@ -55,8 +54,6 @@ main(int argc, char *argv[])
int ch, fd1, fd2, special;
char *file1, *file2;
- setlocale(LC_ALL, "");
-
if (pledge("stdio rpath", NULL) == -1)
err(ERR_EXIT, "pledge");
@@ -68,7 +65,6 @@ main(int argc, char *argv[])
case 's': /* silent run */
sflag = 1;
break;
- case '?':
default:
usage();
}
@@ -90,14 +86,14 @@ main(int argc, char *argv[])
file1 = "stdin";
} else if ((fd1 = open(file1, O_RDONLY, 0)) < 0) {
if (sflag)
- exit(ERR_EXIT);
+ return ERR_EXIT;
else
err(ERR_EXIT, "%s", file1);
}
if (strcmp(file2 = argv[1], "-") == 0) {
if (special) {
if (sflag)
- exit(ERR_EXIT);
+ return ERR_EXIT;
else
errx(ERR_EXIT,
"standard input may only be specified once");
@@ -107,7 +103,7 @@ main(int argc, char *argv[])
file2 = "stdin";
} else if ((fd2 = open(file2, O_RDONLY, 0)) < 0) {
if (sflag)
- exit(ERR_EXIT);
+ return ERR_EXIT;
else
err(ERR_EXIT, "%s", file2);
}
@@ -121,7 +117,7 @@ main(int argc, char *argv[])
if (!special) {
if (fstat(fd1, &sb1)) {
if (sflag)
- exit(ERR_EXIT);
+ return ERR_EXIT;
else
err(ERR_EXIT, "%s", file1);
}
@@ -130,7 +126,7 @@ main(int argc, char *argv[])
else {
if (fstat(fd2, &sb2)) {
if (sflag)
- exit(ERR_EXIT);
+ return ERR_EXIT;
else
err(ERR_EXIT, "%s", file2);
}
@@ -147,7 +143,7 @@ main(int argc, char *argv[])
return 0;
}
-static void
+static void __dead
usage(void)
{
diff --git a/usr.bin/csplit/csplit.c b/usr.bin/csplit/csplit.c
index 86b86c7b4ea..e32c044bc00 100644
--- a/usr.bin/csplit/csplit.c
+++ b/usr.bin/csplit/csplit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: csplit.c,v 1.8 2015/10/11 17:43:03 semarie Exp $ */
+/* $OpenBSD: csplit.c,v 1.9 2016/10/28 07:22:59 schwarze Exp $ */
/* $FreeBSD: src/usr.bin/csplit/csplit.c,v 1.9 2004/03/22 11:15:03 tjr Exp $ */
/*-
@@ -51,7 +51,6 @@
#include <err.h>
#include <errno.h>
#include <limits.h>
-#include <locale.h>
#include <regex.h>
#include <signal.h>
#include <stdint.h>
@@ -67,7 +66,7 @@ char *get_line(void);
void handlesig(int);
FILE *newfile(void);
void toomuch(FILE *, long);
-void usage(void);
+static void __dead usage(void);
/*
* Command line options
@@ -101,8 +100,6 @@ main(int argc, char *argv[])
char *ep, *p;
FILE *ofp;
- setlocale(LC_ALL, "");
-
if (pledge("stdio rpath wpath cpath", NULL) == -1)
err(1, "pledge");
@@ -128,7 +125,6 @@ main(int argc, char *argv[])
break;
default:
usage();
- /*NOTREACHED*/
}
}
@@ -212,7 +208,7 @@ main(int argc, char *argv[])
return (0);
}
-void
+static void __dead
usage(void)
{
extern char *__progname;
diff --git a/usr.bin/dirname/dirname.c b/usr.bin/dirname/dirname.c
index 7e0328e6f86..01dbea472f2 100644
--- a/usr.bin/dirname/dirname.c
+++ b/usr.bin/dirname/dirname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirname.c,v 1.15 2015/10/09 01:37:07 deraadt Exp $ */
+/* $OpenBSD: dirname.c,v 1.16 2016/10/28 07:22:59 schwarze Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -18,12 +18,11 @@
#include <err.h>
#include <libgen.h>
-#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-void usage(void);
+static void __dead usage(void);
int
main(int argc, char *argv[])
@@ -31,8 +30,6 @@ main(int argc, char *argv[])
int ch;
char *dir;
- setlocale(LC_ALL, "");
-
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
@@ -51,12 +48,12 @@ main(int argc, char *argv[])
if ((dir = dirname(argv[0])) == NULL)
err(1, "%s", argv[0]);
puts(dir);
- exit(0);
+ return 0;
}
extern char *__progname;
-void
+static void __dead
usage(void)
{
(void)fprintf(stderr, "usage: %s pathname\n", __progname);
diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c
index 87e9a0b8e4b..08aaa75c695 100644
--- a/usr.bin/env/env.c
+++ b/usr.bin/env/env.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: env.c,v 1.16 2015/10/10 21:19:14 deraadt Exp $ */
+/* $OpenBSD: env.c,v 1.17 2016/10/28 07:22:59 schwarze Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -31,13 +31,12 @@
#include <err.h>
#include <errno.h>
-#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-__dead void usage(void);
+static void __dead usage(void);
int
main(int argc, char *argv[])
@@ -47,8 +46,6 @@ main(int argc, char *argv[])
char **ep, *p;
int ch;
- setlocale(LC_ALL, "");
-
if (pledge("stdio exec", NULL) == -1)
err(1, "pledge");
@@ -86,10 +83,10 @@ main(int argc, char *argv[])
for (ep = environ; *ep; ep++)
(void)printf("%s\n", *ep);
- exit(0);
+ return 0;
}
-void
+static void __dead
usage(void)
{
extern char *__progname;
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c
index 72433648e8b..f4706145468 100644
--- a/usr.bin/getconf/getconf.c
+++ b/usr.bin/getconf/getconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getconf.c,v 1.18 2015/11/17 17:29:27 jca Exp $ */
+/* $OpenBSD: getconf.c,v 1.19 2016/10/28 07:22:59 schwarze Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -40,16 +40,15 @@
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
*/
+#include <err.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <limits.h>
-#include <locale.h>
#include <unistd.h>
-#include <err.h>
-#include <errno.h>
-static void usage(void);
+static void __dead usage(void);
static void list_var(int);
static int compilation_spec_valid(const char *);
@@ -409,8 +408,6 @@ main(int argc, char *argv[])
size_t slen;
char * sval;
- setlocale(LC_ALL, "");
-
while ((ch = getopt(argc, argv, "lLv:")) != -1) {
switch (ch) {
case 'l': /* nonstandard: list system variables */
@@ -530,11 +527,11 @@ main(int argc, char *argv[])
break;
}
- exit(ferror(stdout));
+ return ferror(stdout);
}
-static void
+static void __dead
usage(void)
{
extern char *__progname;
diff --git a/usr.bin/nice/nice.c b/usr.bin/nice/nice.c
index 7b2c8b0f578..bef3caa7210 100644
--- a/usr.bin/nice/nice.c
+++ b/usr.bin/nice/nice.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nice.c,v 1.16 2016/09/04 15:41:23 tb Exp $ */
+/* $OpenBSD: nice.c,v 1.17 2016/10/28 07:22:59 schwarze Exp $ */
/* $NetBSD: nice.c,v 1.9 1995/08/31 23:30:58 jtc Exp $ */
/*
@@ -31,12 +31,12 @@
*/
#include <sys/resource.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <locale.h>
+
#include <ctype.h>
-#include <errno.h>
#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#define DEFNICE 10
@@ -50,8 +50,6 @@ main(int argc, char *argv[])
int prio = DEFNICE;
int c;
- setlocale(LC_ALL, "");
-
if (pledge("stdio exec proc", NULL) == -1)
err(1, "pledge");
@@ -74,7 +72,6 @@ main(int argc, char *argv[])
break;
default:
usage();
- break;
}
}
argc -= optind;
diff --git a/usr.bin/tee/tee.c b/usr.bin/tee/tee.c
index 8da58303ae2..d5e4767e498 100644
--- a/usr.bin/tee/tee.c
+++ b/usr.bin/tee/tee.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tee.c,v 1.10 2015/10/09 01:37:09 deraadt Exp $ */
+/* $OpenBSD: tee.c,v 1.11 2016/10/28 07:22:59 schwarze Exp $ */
/* $NetBSD: tee.c,v 1.5 1994/12/09 01:43:39 jtc Exp $ */
/*
@@ -32,15 +32,15 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <signal.h>
+
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <locale.h>
-#include <err.h>
+#include <unistd.h>
struct list {
struct list *next;
@@ -72,8 +72,6 @@ main(int argc, char *argv[])
int append, ch, exitval;
char buf[8192];
- setlocale(LC_ALL, "");
-
if (pledge("stdio wpath cpath", NULL) == -1)
err(1, "pledge");
@@ -86,10 +84,9 @@ main(int argc, char *argv[])
case 'i':
(void)signal(SIGINT, SIG_IGN);
break;
- case '?':
default:
(void)fprintf(stderr, "usage: tee [-ai] [file ...]\n");
- exit(1);
+ return 1;
}
}
argv += optind;
@@ -137,5 +134,5 @@ main(int argc, char *argv[])
}
}
- exit(exitval);
+ return exitval;
}
diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c
index d15c7c7fe2f..5f219d17d94 100644
--- a/usr.bin/uname/uname.c
+++ b/usr.bin/uname/uname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uname.c,v 1.18 2016/10/10 02:23:54 gsoares Exp $ */
+/* $OpenBSD: uname.c,v 1.19 2016/10/28 07:22:59 schwarze Exp $ */
/*
* Copyright (c) 1994 Winning Strategies, Inc.
@@ -35,12 +35,11 @@
#include <sys/utsname.h>
#include <err.h>
-#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-static void usage(void);
+static void __dead usage(void);
#define PRINT_SYSNAME 0x01
#define PRINT_NODENAME 0x02
@@ -58,8 +57,6 @@ main(int argc, char *argv[])
int space = 0;
int print_mask = 0;
- setlocale(LC_ALL, "");
-
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
@@ -88,18 +85,14 @@ main(int argc, char *argv[])
break;
default:
usage();
- /* NOTREACHED */
}
}
- if (optind != argc) {
+ if (optind != argc)
usage();
- /* NOTREACHED */
- }
- if (!print_mask) {
+ if (!print_mask)
print_mask = PRINT_SYSNAME;
- }
if (uname(&u) == -1)
err(1, NULL);
@@ -143,7 +136,7 @@ main(int argc, char *argv[])
return 0;
}
-static void
+static void __dead
usage(void)
{
fprintf(stderr, "usage: uname [-amnprsv]\n");
diff --git a/usr.bin/which/which.c b/usr.bin/which/which.c
index 76cab1eedc0..547b7f3a9ba 100644
--- a/usr.bin/which/which.c
+++ b/usr.bin/which/which.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: which.c,v 1.25 2016/01/14 22:02:13 millert Exp $ */
+/* $OpenBSD: which.c,v 1.26 2016/10/28 07:22:59 schwarze Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -21,13 +21,12 @@
#include <err.h>
#include <errno.h>
-#include <locale.h>
+#include <limits.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <limits.h>
#define PROG_WHICH 1
#define PROG_WHEREIS 2
@@ -35,7 +34,7 @@
extern char *__progname;
int findprog(char *, char *, int, int);
-__dead void usage(void);
+static void __dead usage(void);
/*
* which(1) -- find an executable(s) in the user's path
@@ -54,8 +53,6 @@ main(int argc, char *argv[])
size_t n;
int ch, allmatches = 0, notfound = 0, progmode = PROG_WHICH;
- (void)setlocale(LC_ALL, "");
-
while ((ch = getopt(argc, argv, "a")) != -1)
switch (ch) {
case 'a':
@@ -91,7 +88,7 @@ main(int argc, char *argv[])
if (findprog(argv[n], path, progmode, allmatches) == 0)
notfound++;
- exit((notfound == 0) ? 0 : ((notfound == argc) ? 2 : 1));
+ return ((notfound == 0) ? 0 : ((notfound == argc) ? 2 : 1));
}
int
@@ -150,7 +147,7 @@ findprog(char *prog, char *path, int progmode, int allmatches)
return (rval);
}
-__dead void
+static void __dead
usage(void)
{
(void)fprintf(stderr, "usage: %s [-a] name ...\n", __progname);