From fbb83e78c0ca90b09e1e9c0a76030f46f419dcaf Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 19 Oct 2012 05:43:38 +0000 Subject: Fix warnings found by -Wmising-variable-declarations. This self-written compiler warning, which is hopefully going to be committed into LLVM sources soon, warns about potentially missing `static' keywords, similar to -Wmissing-prototypes. - bin/pax: Move external declaration of chdname and s_mask into extern.h. - bin/setfacl: Move setfacl.c-specific stuff out of setfacl.h. - sbin/mount_fusefs: Remove char *progname; use getprogname(). - others: add `static' where possible. --- bin/ed/buf.c | 12 ++++++------ bin/ed/cbc.c | 20 ++++++++------------ bin/ed/glbl.c | 10 +++++----- bin/ed/io.c | 4 ++-- bin/ed/main.c | 31 ++++++++++++++++--------------- bin/ed/sub.c | 10 +++++----- bin/ed/undo.c | 6 +++--- 7 files changed, 45 insertions(+), 48 deletions(-) (limited to 'bin/ed') diff --git a/bin/ed/buf.c b/bin/ed/buf.c index b4b78a5..2f3559a 100644 --- a/bin/ed/buf.c +++ b/bin/ed/buf.c @@ -35,10 +35,10 @@ __FBSDID("$FreeBSD$"); #include "ed.h" -FILE *sfp; /* scratch file pointer */ -off_t sfseek; /* scratch file position */ -int seek_write; /* seek before writing */ -line_t buffer_head; /* incore buffer */ +static FILE *sfp; /* scratch file pointer */ +static off_t sfseek; /* scratch file position */ +static int seek_write; /* seek before writing */ +static line_t buffer_head; /* incore buffer */ /* get_sbuf_line: get a line of text from the scratch file; return pointer to the text */ @@ -188,7 +188,7 @@ get_addressed_line_node(long n) extern int newline_added; -char sfn[15] = ""; /* scratch file name */ +static char sfn[15] = ""; /* scratch file name */ /* open_sbuf: open scratch file */ int @@ -244,7 +244,7 @@ quit(int n) } -unsigned char ctab[256]; /* character translation table */ +static unsigned char ctab[256]; /* character translation table */ /* init_buffers: open scratch buffer; initialize line queue */ void diff --git a/bin/ed/cbc.c b/bin/ed/cbc.c index 52e9999..08e48cd 100644 --- a/bin/ed/cbc.c +++ b/bin/ed/cbc.c @@ -68,28 +68,24 @@ __FBSDID("$FreeBSD$"); * global variables and related macros */ -enum { /* encrypt, decrypt, authenticate */ - MODE_ENCRYPT, MODE_DECRYPT, MODE_AUTHENTICATE -} mode = MODE_ENCRYPT; - #ifdef DES -DES_cblock ivec; /* initialization vector */ -DES_cblock pvec; /* padding vector */ +static DES_cblock ivec; /* initialization vector */ +static DES_cblock pvec; /* padding vector */ #endif -char bits[] = { /* used to extract bits from a char */ +static char bits[] = { /* used to extract bits from a char */ '\200', '\100', '\040', '\020', '\010', '\004', '\002', '\001' }; -int pflag; /* 1 to preserve parity bits */ +static int pflag; /* 1 to preserve parity bits */ #ifdef DES -DES_key_schedule schedule; /* expanded DES key */ +static DES_key_schedule schedule; /* expanded DES key */ #endif -unsigned char des_buf[8]; /* shared buffer for get_des_char/put_des_char */ -int des_ct = 0; /* count for get_des_char/put_des_char */ -int des_n = 0; /* index for put_des_char/get_des_char */ +static unsigned char des_buf[8];/* shared buffer for get_des_char/put_des_char */ +static int des_ct = 0; /* count for get_des_char/put_des_char */ +static int des_n = 0; /* index for put_des_char/get_des_char */ /* init_des_cipher: initialize DES */ void diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index 11dcc19..5524700 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -135,11 +135,11 @@ exec_global(int interact, int gflag) } -line_t **active_list; /* list of lines active in a global command */ -long active_last; /* index of last active line in active_list */ -long active_size; /* size of active_list */ -long active_ptr; /* active_list index (non-decreasing) */ -long active_ndx; /* active_list index (modulo active_last) */ +static line_t **active_list; /* list of lines active in a global command */ +static long active_last; /* index of last active line in active_list */ +static long active_size; /* size of active_list */ +static long active_ptr; /* active_list index (non-decreasing) */ +static long active_ndx; /* active_list index (modulo active_last) */ /* set_active_node: add a line node to the global-active list */ int diff --git a/bin/ed/io.c b/bin/ed/io.c index 63fe10c..29c5612 100644 --- a/bin/ed/io.c +++ b/bin/ed/io.c @@ -61,8 +61,8 @@ read_file(char *fn, long n) extern int des; -char *sbuf; /* file i/o buffer */ -int sbufsz; /* file i/o buffer size */ +static char *sbuf; /* file i/o buffer */ +static int sbufsz; /* file i/o buffer size */ int newline_added; /* if set, newline appended to input file */ /* read_stream: read a stream into the editor buffer; return status */ diff --git a/bin/ed/main.c b/bin/ed/main.c index f414d40..98bb300 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -66,40 +66,40 @@ __FBSDID("$FreeBSD$"); #ifdef _POSIX_SOURCE -sigjmp_buf env; +static sigjmp_buf env; #else -jmp_buf env; +static jmp_buf env; #endif /* static buffers */ char stdinbuf[1]; /* stdin buffer */ -char *shcmd; /* shell command buffer */ -int shcmdsz; /* shell command buffer size */ -int shcmdi; /* shell command buffer index */ +static char *shcmd; /* shell command buffer */ +static int shcmdsz; /* shell command buffer size */ +static int shcmdi; /* shell command buffer index */ char *ibuf; /* ed command-line buffer */ int ibufsz; /* ed command-line buffer size */ char *ibufp; /* pointer to ed command-line buffer */ /* global flags */ int des = 0; /* if set, use crypt(3) for i/o */ -int garrulous = 0; /* if set, print all error messages */ +static int garrulous = 0; /* if set, print all error messages */ int isbinary; /* if set, buffer contains ASCII NULs */ int isglobal; /* if set, doing a global command */ int modified; /* if set, buffer modified since last write */ int mutex = 0; /* if set, signals set "sigflags" */ -int red = 0; /* if set, restrict shell/directory access */ +static int red = 0; /* if set, restrict shell/directory access */ int scripted = 0; /* if set, suppress diagnostics */ int sigflags = 0; /* if set, signals received while mutex set */ -int sigactive = 0; /* if set, signal handlers are enabled */ +static int sigactive = 0; /* if set, signal handlers are enabled */ -char old_filename[PATH_MAX] = ""; /* default filename */ +static char old_filename[PATH_MAX] = ""; /* default filename */ long current_addr; /* current address in editor buffer */ long addr_last; /* last address in editor buffer */ int lineno; /* script line number */ -const char *prompt; /* command-line prompt */ -const char *dps = "*"; /* default command-line prompt */ +static const char *prompt; /* command-line prompt */ +static const char *dps = "*"; /* default command-line prompt */ -const char usage[] = "usage: %s [-] [-sx] [-p string] [file]\n"; +static const char *usage = "usage: %s [-] [-sx] [-p string] [file]\n"; /* ed: line editor */ int @@ -254,7 +254,8 @@ top: /*NOTREACHED*/ } -long first_addr, second_addr, addr_cnt; +long first_addr, second_addr; +static long addr_cnt; /* extract_addr_range: get line addresses from the command buffer until an illegal address is seen; return status */ @@ -1241,8 +1242,8 @@ display_lines(long from, long to, int gflag) #define MAXMARK 26 /* max number of marks */ -line_t *mark[MAXMARK]; /* line markers */ -int markno; /* line marker count */ +static line_t *mark[MAXMARK]; /* line markers */ +static int markno; /* line marker count */ /* mark_line_node: set a line node mark */ int diff --git a/bin/ed/sub.c b/bin/ed/sub.c index 1c44328..d12a5c9 100644 --- a/bin/ed/sub.c +++ b/bin/ed/sub.c @@ -32,9 +32,9 @@ __FBSDID("$FreeBSD$"); #include "ed.h" -char *rhbuf; /* rhs substitution buffer */ -int rhbufsz; /* rhs substitution buffer size */ -int rhbufi; /* rhs substitution buffer index */ +static char *rhbuf; /* rhs substitution buffer */ +static int rhbufsz; /* rhs substitution buffer size */ +static int rhbufi; /* rhs substitution buffer index */ /* extract_subst_tail: extract substitution tail from the command buffer */ int @@ -105,8 +105,8 @@ extract_subst_template(void) } -char *rbuf; /* substitute_matching_text buffer */ -int rbufsz; /* substitute_matching_text buffer size */ +static char *rbuf; /* substitute_matching_text buffer */ +static int rbufsz; /* substitute_matching_text buffer size */ /* search_and_replace: for each line in a range, change text matching a pattern according to a substitution template; return status */ diff --git a/bin/ed/undo.c b/bin/ed/undo.c index 6a8ca9e..603e39f 100644 --- a/bin/ed/undo.c +++ b/bin/ed/undo.c @@ -32,9 +32,9 @@ __FBSDID("$FreeBSD$"); #define USIZE 100 /* undo stack size */ -undo_t *ustack = NULL; /* undo stack */ -long usize = 0; /* stack size variable */ -long u_p = 0; /* undo stack pointer */ +static undo_t *ustack = NULL; /* undo stack */ +static long usize = 0; /* stack size variable */ +static long u_p = 0; /* undo stack pointer */ /* push_undo_stack: return pointer to initialized undo node */ undo_t * -- cgit v1.1