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.
This commit is contained in:
Ed Schouten 2012-10-19 05:43:38 +00:00
parent 8241616dc5
commit ae824d80f2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241720
30 changed files with 114 additions and 116 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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 @@ main(volatile int argc, char ** volatile argv)
/*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

View file

@ -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 */

View file

@ -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 *

View file

@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
int more_than_one = 0;
static int more_than_one = 0;
static void
usage(void)

View file

@ -85,7 +85,6 @@ const char *gzip_program; /* name of gzip program */
static pid_t zpid = -1; /* pid of child process */
static int get_phys(void);
extern sigset_t s_mask;
static void ar_start_gzip(int, const char *, int);
/*

View file

@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
static void wr_archive(ARCHD *, int is_app);
static int get_arc(void);
static int next_head(ARCHD *);
extern sigset_t s_mask;
/*
* Routines which control the overall operation modes of pax as specified by

View file

@ -186,7 +186,7 @@ void options(int, char **);
OPLIST * opt_next(void);
int opt_add(const char *);
int bad_opt(void);
char *chdname;
extern char *chdname;
/*
* pat_rep.c
@ -231,6 +231,7 @@ extern int exit_val;
extern int docrc;
extern char *dirptr;
extern const char *argv0;
extern sigset_t s_mask;
extern FILE *listf;
extern char *tempfile;
extern char *tempbase;

View file

@ -81,6 +81,7 @@ static void cpio_usage(void);
#define GETLINE_OUT_OF_MEM 2
static int getline_error;
char *chdname;
#define GZIP_CMD "gzip" /* command to run as gzip */
#define COMPRESS_CMD "compress" /* command to run as compress */

View file

@ -76,12 +76,13 @@ __FBSDID("$FreeBSD$");
#define OPTIONS "46dfprt"
struct passwd *pwd;
u_short port;
uid_t userid;
int errs, rem;
int pflag, iamremote, iamrecursive, targetshouldbedirectory;
int family = PF_UNSPEC;
static struct passwd *pwd;
static u_short port;
static uid_t userid;
static int errs, rem;
int iamremote;
static int pflag, iamrecursive, targetshouldbedirectory;
static int family = PF_UNSPEC;
static int argc_copy;
static const char **argv_copy;
@ -89,7 +90,7 @@ static const char **argv_copy;
static char period[] = ".";
#define CMDNEEDS 64
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
static char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
int response(void);
void rsource(char *, struct stat *);

View file

@ -42,6 +42,35 @@ __FBSDID("$FreeBSD$");
#include "setfacl.h"
/* file operations */
#define OP_MERGE_ACL 0x00 /* merge acl's (-mM) */
#define OP_REMOVE_DEF 0x01 /* remove default acl's (-k) */
#define OP_REMOVE_EXT 0x02 /* remove extended acl's (-b) */
#define OP_REMOVE_ACL 0x03 /* remove acl's (-xX) */
#define OP_REMOVE_BY_NUMBER 0x04 /* remove acl's (-xX) by acl entry number */
#define OP_ADD_ACL 0x05 /* add acls entries at a given position */
/* TAILQ entry for acl operations */
struct sf_entry {
uint op;
acl_t acl;
uint entry_number;
TAILQ_ENTRY(sf_entry) next;
};
static TAILQ_HEAD(, sf_entry) entrylist;
/* TAILQ entry for files */
struct sf_file {
const char *filename;
TAILQ_ENTRY(sf_file) next;
};
static TAILQ_HEAD(, sf_file) filelist;
uint have_mask;
uint need_mask;
uint have_stdin;
uint n_flag;
static void add_filename(const char *filename);
static void usage(void);

View file

@ -33,30 +33,6 @@
#include <sys/acl.h>
#include <sys/queue.h>
/* file operations */
#define OP_MERGE_ACL 0x00 /* merge acl's (-mM) */
#define OP_REMOVE_DEF 0x01 /* remove default acl's (-k) */
#define OP_REMOVE_EXT 0x02 /* remove extended acl's (-b) */
#define OP_REMOVE_ACL 0x03 /* remove acl's (-xX) */
#define OP_REMOVE_BY_NUMBER 0x04 /* remove acl's (-xX) by acl entry number */
#define OP_ADD_ACL 0x05 /* add acls entries at a given position */
/* TAILQ entry for acl operations */
struct sf_entry {
uint op;
acl_t acl;
uint entry_number;
TAILQ_ENTRY(sf_entry) next;
};
TAILQ_HEAD(, sf_entry) entrylist;
/* TAILQ entry for files */
struct sf_file {
const char *filename;
TAILQ_ENTRY(sf_file) next;
};
TAILQ_HEAD(, sf_file) filelist;
/* files.c */
acl_t get_acl_from_file(const char *filename);
/* merge.c */
@ -74,9 +50,9 @@ void *zmalloc(size_t size);
const char *brand_name(int brand);
int branding_mismatch(int brand1, int brand2);
uint have_mask;
uint need_mask;
uint have_stdin;
uint n_flag;
extern uint have_mask;
extern uint need_mask;
extern uint have_stdin;
extern uint n_flag;
#endif /* _SETFACL_H */

View file

@ -29,7 +29,7 @@
#include <stdio.h>
#include "_libdwarf.h"
const char *_libdwarf_errors[] = {
static const char *_libdwarf_errors[] = {
#define DEFINE_ERROR(N,S) [DWARF_E_##N] = S
DEFINE_ERROR(NONE, "No Error"),
DEFINE_ERROR(ERROR, "An error"),

View file

@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
* Retrieve a human readable translation for an error message.
*/
const char *_libelf_errors[] = {
static const char *_libelf_errors[] = {
#define DEFINE_ERROR(N,S) [ELF_E_##N] = S
DEFINE_ERROR(NONE, "No Error"),
DEFINE_ERROR(ARCHIVE, "Malformed ar(1) archive"),

View file

@ -140,8 +140,8 @@ TAILQ_HEAD(svc_rpc_gss_client_list, svc_rpc_gss_client);
#define CLIENT_HASH_SIZE 256
#define CLIENT_MAX 128
struct svc_rpc_gss_client_list svc_rpc_gss_client_hash[CLIENT_HASH_SIZE];
struct svc_rpc_gss_client_list svc_rpc_gss_clients;
static struct svc_rpc_gss_client_list svc_rpc_gss_client_hash[CLIENT_HASH_SIZE];
static struct svc_rpc_gss_client_list svc_rpc_gss_clients;
static size_t svc_rpc_gss_client_count;
static uint32_t svc_rpc_gss_next_clientid = 1;

View file

@ -1107,7 +1107,7 @@ pt_thr_tls_get_addr(const td_thrhandle_t *th, psaddr_t _linkmap, size_t offset,
return (TD_OK);
}
struct ta_ops libpthread_db_ops = {
static struct ta_ops libpthread_db_ops = {
.to_init = pt_init,
.to_ta_clear_event = pt_ta_clear_event,
.to_ta_delete = pt_ta_delete,

View file

@ -765,7 +765,7 @@ pt_thr_tls_get_addr(const td_thrhandle_t *th, psaddr_t _linkmap, size_t offset,
return (TD_OK);
}
struct ta_ops libthr_db_ops = {
static struct ta_ops libthr_db_ops = {
.to_init = pt_init,
.to_ta_clear_event = pt_ta_clear_event,
.to_ta_delete = pt_ta_delete,

View file

@ -53,7 +53,7 @@ struct sockaddr_storage me_sock;
static int send_packet(int peer, uint16_t block, char *pkt, int size);
struct errmsg {
static struct errmsg {
int e_code;
const char *e_msg;
} errmsgs[] = {
@ -375,7 +375,7 @@ send_data(int peer, uint16_t block, char *data, int size)
/*
* Receive a packet
*/
jmp_buf timeoutbuf;
static jmp_buf timeoutbuf;
static void
timeout(int sig __unused)

View file

@ -121,7 +121,7 @@ get_field(int peer, char *buffer, ssize_t size)
/*
* Logging functions
*/
int _tftp_logtostdout = 1;
static int _tftp_logtostdout = 1;
void
tftp_openlog(const char *ident, int logopt, int facility)

View file

@ -107,9 +107,9 @@ static void tftp_xmitfile(int peer, const char *mode);
static int validate_access(int peer, char **, int);
static char peername[NI_MAXHOST];
FILE *file;
static FILE *file;
struct formats {
static struct formats {
const char *f_mode;
int f_convert;
} formats[] = {

View file

@ -79,7 +79,7 @@ struct cmds {
int args;
void (*f)(struct cfg *, char *argv[]);
};
struct cmds cmds[];
static struct cmds cmds[];
static void usage(void);
@ -501,7 +501,7 @@ main(int argc, char *argv[])
return (0);
}
struct cmds cmds[] = {
static struct cmds cmds[] = {
{ MODE_PORT, "vlangroup", 1, set_port_vlangroup },
{ MODE_PORT, "media", 1, set_port_media },
{ MODE_PORT, "mediaopt", 1, set_port_mediaopt },

View file

@ -396,10 +396,10 @@ static struct ifmedia_description ifm_subtype_ieee80211_aliases[] =
static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =
IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;
struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] =
static struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] =
IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS;
struct ifmedia_description ifm_subtype_ieee80211_mode_aliases[] =
static struct ifmedia_description ifm_subtype_ieee80211_mode_aliases[] =
IFM_SUBTYPE_IEEE80211_MODE_ALIASES;
static struct ifmedia_description ifm_subtype_atm_descriptions[] =

View file

@ -55,7 +55,7 @@
#include "ggate.h"
enum { UNSET, CREATE, DESTROY, LIST, RESCUE } action = UNSET;
static enum { UNSET, CREATE, DESTROY, LIST, RESCUE } action = UNSET;
static const char *path = NULL;
static const char *host = NULL;

View file

@ -92,12 +92,12 @@ struct ggd_export {
static const char *exports_file = GGATED_EXPORT_FILE;
static int got_sighup = 0;
in_addr_t bindaddr;
static in_addr_t bindaddr;
static TAILQ_HEAD(, ggd_request) inqueue = TAILQ_HEAD_INITIALIZER(inqueue);
static TAILQ_HEAD(, ggd_request) outqueue = TAILQ_HEAD_INITIALIZER(outqueue);
pthread_mutex_t inqueue_mtx, outqueue_mtx;
pthread_cond_t inqueue_cond, outqueue_cond;
static pthread_mutex_t inqueue_mtx, outqueue_mtx;
static pthread_cond_t inqueue_cond, outqueue_cond;
static SLIST_HEAD(, ggd_export) exports = SLIST_HEAD_INITIALIZER(exports);
static LIST_HEAD(, ggd_connection) connections = LIST_HEAD_INITIALIZER(connections);

View file

@ -47,7 +47,7 @@
#include "ggate.h"
enum { UNSET, CREATE, DESTROY, LIST, RESCUE } action = UNSET;
static enum { UNSET, CREATE, DESTROY, LIST, RESCUE } action = UNSET;
static const char *path = NULL;
static int unit = G_GATE_UNIT_AUTO;

View file

@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <signal.h>
#include <getopt.h>
#include <libgen.h>
#include <limits.h>
#include <osreldate.h>
#include <paths.h>
@ -61,7 +60,7 @@ void helpmsg(void);
void showversion(void);
int init_backgrounded(void);
struct mntopt mopts[] = {
static struct mntopt mopts[] = {
#define ALTF_PRIVATE 0x01
{ "private", 0, ALTF_PRIVATE, 1 },
{ "neglect_shares", 0, 0x02, 1 },
@ -93,14 +92,12 @@ struct mntval {
int mv_len;
};
struct mntval mvals[] = {
static struct mntval mvals[] = {
{ ALTF_MAXREAD, NULL, 0 },
{ ALTF_SUBTYPE, NULL, 0 },
{ 0, NULL, 0 }
};
char *progname;
#define DEFAULT_MOUNT_FLAGS ALTF_PRIVATE | ALTF_SYNC_UNMOUNT
int
@ -133,8 +130,6 @@ main(int argc, char *argv[])
char *ep;
char *daemon_str = NULL, *daemon_opts = NULL;
progname = argv[0];
/*
* We want a parsing routine which is not sensitive to
* the position of args/opts; it should extract the
@ -432,7 +427,7 @@ void
__usage_short(void) {
fprintf(stderr,
"usage:\n%s [-A|-S|-v|-V|-h|-D daemon|-O args|-s special|-m node|-o option...] special node [daemon args...]\n\n",
basename(progname));
getprogname());
}
void

View file

@ -84,7 +84,7 @@ typedef bool flag;
#define SET TRUE
#define RESET FALSE
Hash_Table provide_hash_s, *provide_hash;
static Hash_Table provide_hash_s, *provide_hash;
typedef struct provnode provnode;
typedef struct filenode filenode;