summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-10-31 08:59:17 +0000
committered <ed@FreeBSD.org>2011-10-31 08:59:17 +0000
commitf58d00c87a547a1f65cf7b990fda6f4e36feb314 (patch)
treeb068d06018284af5aa8b3feab9edb06109d847bc
parent6458f63cb36a7883be28c39ca995cf3e03bfce69 (diff)
downloadFreeBSD-src-f58d00c87a547a1f65cf7b990fda6f4e36feb314.zip
FreeBSD-src-f58d00c87a547a1f65cf7b990fda6f4e36feb314.tar.gz
Put some static keywords in the source code.
For these simple utilities, it doesn't harm to make all global variables static. In fact, this allows the compiler to perform better forms of optimisation and analysis.
-rw-r--r--bin/cat/cat.c6
-rw-r--r--bin/ln/ln.c18
-rw-r--r--bin/mkdir/mkdir.c2
-rw-r--r--bin/mv/mv.c2
-rw-r--r--bin/rm/rm.c8
-rw-r--r--bin/test/test.c10
6 files changed, 23 insertions, 23 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index d338742..437c013 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -64,9 +64,9 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <stddef.h>
-int bflag, eflag, nflag, sflag, tflag, vflag;
-int rval;
-const char *filename;
+static int bflag, eflag, nflag, sflag, tflag, vflag;
+static int rval;
+static const char *filename;
static void usage(void);
static void scanfiles(char *argv[], int cooked);
diff --git a/bin/ln/ln.c b/bin/ln/ln.c
index e5fdeee..4169e62 100644
--- a/bin/ln/ln.c
+++ b/bin/ln/ln.c
@@ -54,16 +54,16 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-int fflag; /* Unlink existing files. */
-int Fflag; /* Remove empty directories also. */
-int hflag; /* Check new name for symlink first. */
-int iflag; /* Interactive mode. */
-int Pflag; /* Create hard links to symlinks. */
-int sflag; /* Symbolic, not hard, link. */
-int vflag; /* Verbose output. */
-int wflag; /* Warn if symlink target does not
+static int fflag; /* Unlink existing files. */
+static int Fflag; /* Remove empty directories also. */
+static int hflag; /* Check new name for symlink first. */
+static int iflag; /* Interactive mode. */
+static int Pflag; /* Create hard links to symlinks. */
+static int sflag; /* Symbolic, not hard, link. */
+static int vflag; /* Verbose output. */
+static int wflag; /* Warn if symlink target does not
* exist, and -f is not enabled. */
-char linkch;
+static char linkch;
int linkit(const char *, const char *, int);
void usage(void);
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c
index 5fa002f..fda9c24 100644
--- a/bin/mkdir/mkdir.c
+++ b/bin/mkdir/mkdir.c
@@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
static int build(char *, mode_t);
static void usage(void);
-int vflag;
+static int vflag;
int
main(int argc, char *argv[])
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 67108f7..e4fe007 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
/* Exit code for a failed exec. */
#define EXEC_FAILED 127
-int fflg, iflg, nflg, vflg;
+static int fflg, iflg, nflg, vflg;
static int copy(const char *, const char *);
static int do_move(const char *, const char *);
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index af362a9..3c2ba61 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -57,10 +57,10 @@ __FBSDID("$FreeBSD$");
#include <sysexits.h>
#include <unistd.h>
-int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
-int rflag, Iflag;
-uid_t uid;
-volatile sig_atomic_t info;
+static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
+static int rflag, Iflag;
+static uid_t uid;
+static volatile sig_atomic_t info;
int check(char *, char *, struct stat *);
int check2(char **);
diff --git a/bin/test/test.c b/bin/test/test.c
index 62c0309..394988e 100644
--- a/bin/test/test.c
+++ b/bin/test/test.c
@@ -118,7 +118,7 @@ enum token_types {
PAREN
};
-struct t_op {
+static struct t_op {
const char *op_text;
short op_num, op_type;
} const ops [] = {
@@ -165,10 +165,10 @@ struct t_op {
{0, 0, 0}
};
-struct t_op const *t_wp_op;
-int nargc;
-char **t_wp;
-int parenlevel;
+static struct t_op const *t_wp_op;
+static int nargc;
+static char **t_wp;
+static int parenlevel;
static int aexpr(enum token);
static int binop(void);
OpenPOWER on IntegriCloud