static + __dead

This commit is contained in:
joerg 2011-08-29 14:29:21 +00:00
parent 7e47a1209f
commit 693655118a
2 changed files with 121 additions and 134 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: brconfig.c,v 1.12 2009/03/16 12:56:19 lukem Exp $ */
/* $NetBSD: brconfig.c,v 1.13 2011/08/29 14:29:21 joerg Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: brconfig.c,v 1.12 2009/03/16 12:56:19 lukem Exp $");
__RCSID("$NetBSD: brconfig.c,v 1.13 2011/08/29 14:29:21 joerg Exp $");
#endif
@ -74,29 +74,29 @@ struct command {
#define CMD_INVERT 0x01 /* "invert" the sense of the command */
void cmd_add(const struct command *, int, const char *, char **);
void cmd_delete(const struct command *, int, const char *, char **);
void cmd_up(const struct command *, int, const char *, char **);
void cmd_down(const struct command *, int, const char *, char **);
void cmd_discover(const struct command *, int, const char *, char **);
void cmd_learn(const struct command *, int, const char *, char **);
void cmd_flush(const struct command *, int, const char *, char **);
void cmd_flushall(const struct command *, int, const char *, char **);
void cmd_static(const struct command *, int, const char *, char **);
void cmd_deladdr(const struct command *, int, const char *, char **);
void cmd_addr(const struct command *, int, const char *, char **);
void cmd_maxaddr(const struct command *, int, const char *, char **);
void cmd_hellotime(const struct command *, int, const char *, char **);
void cmd_fwddelay(const struct command *, int, const char *, char **);
void cmd_maxage(const struct command *, int, const char *, char **);
void cmd_priority(const struct command *, int, const char *, char **);
void cmd_ifpriority(const struct command *, int, const char *, char **);
void cmd_ifpathcost(const struct command *, int, const char *, char **);
void cmd_timeout(const struct command *, int, const char *, char **);
void cmd_stp(const struct command *, int, const char *, char **);
void cmd_ipf(const struct command *, int, const char *, char **);
static void cmd_add(const struct command *, int, const char *, char **);
static void cmd_delete(const struct command *, int, const char *, char **);
static void cmd_up(const struct command *, int, const char *, char **);
static void cmd_down(const struct command *, int, const char *, char **);
static void cmd_discover(const struct command *, int, const char *, char **);
static void cmd_learn(const struct command *, int, const char *, char **);
static void cmd_flush(const struct command *, int, const char *, char **);
static void cmd_flushall(const struct command *, int, const char *, char **);
static void cmd_static(const struct command *, int, const char *, char **);
static void cmd_deladdr(const struct command *, int, const char *, char **);
static void cmd_addr(const struct command *, int, const char *, char **);
static void cmd_maxaddr(const struct command *, int, const char *, char **);
static void cmd_hellotime(const struct command *, int, const char *, char **);
static void cmd_fwddelay(const struct command *, int, const char *, char **);
static void cmd_maxage(const struct command *, int, const char *, char **);
static void cmd_priority(const struct command *, int, const char *, char **);
static void cmd_ifpriority(const struct command *, int, const char *, char **);
static void cmd_ifpathcost(const struct command *, int, const char *, char **);
static void cmd_timeout(const struct command *, int, const char *, char **);
static void cmd_stp(const struct command *, int, const char *, char **);
static void cmd_ipf(const struct command *, int, const char *, char **);
const struct command command_table[] = {
static const struct command command_table[] = {
{ "add", 1, 0, cmd_add },
{ "delete", 1, 0, cmd_delete },
@ -134,25 +134,25 @@ const struct command command_table[] = {
{ NULL, 0, 0, NULL },
};
void printall(int);
void status(int, const char *);
int is_bridge(const char *);
void show_config(int, const char *, const char *);
void show_interfaces(int, const char *, const char *);
void show_addresses(int, const char *, const char *);
int get_val(const char *, u_long *);
int do_cmd(int, const char *, u_long, void *, size_t, int);
void do_ifflag(int, const char *, int, int);
void do_bridgeflag(int, const char *, const char *, int, int);
static void printall(int);
static void status(int, const char *);
static int is_bridge(const char *);
static void show_config(int, const char *, const char *);
static void show_interfaces(int, const char *, const char *);
static void show_addresses(int, const char *, const char *);
static int get_val(const char *, u_long *);
static int do_cmd(int, const char *, u_long, void *, size_t, int);
static void do_ifflag(int, const char *, int, int);
static void do_bridgeflag(int, const char *, const char *, int, int);
void printb(const char *, u_int, const char *);
static void printb(const char *, u_int, const char *);
void usage(void);
__dead static void usage(void);
int aflag;
static int aflag;
struct ifreq g_ifr;
int g_ifr_updated;
static struct ifreq g_ifr;
static int g_ifr_updated;
int
main(int argc, char *argv[])
@ -239,7 +239,7 @@ main(int argc, char *argv[])
exit (0);
}
void
static void
usage(void)
{
static const char *usage_strings[] = {
@ -278,7 +278,7 @@ usage(void)
exit(1);
}
int
static int
is_bridge(const char *bridge)
{
@ -289,7 +289,7 @@ is_bridge(const char *bridge)
return (1);
}
void
static void
printb(const char *s, u_int v, const char *bits)
{
int i, any = 0;
@ -317,7 +317,7 @@ printb(const char *s, u_int v, const char *bits)
}
}
void
static void
printall(int sock)
{
struct ifaddrs *ifap, *ifa;
@ -338,7 +338,7 @@ printall(int sock)
freeifaddrs(ifap);
}
void
static void
status(int sock, const char *bridge)
{
struct ifreq ifr;
@ -370,7 +370,7 @@ status(int sock, const char *bridge)
show_addresses(sock, bridge, "\t\t");
}
void
static void
show_config(int sock, const char *bridge, const char *prefix)
{
struct ifbrparam param;
@ -408,7 +408,7 @@ show_config(int sock, const char *bridge, const char *prefix)
ipfflags);
}
void
static void
show_interfaces(int sock, const char *bridge, const char *prefix)
{
static const char *stpstates[] = {
@ -459,7 +459,7 @@ show_interfaces(int sock, const char *bridge, const char *prefix)
free(inbuf);
}
void
static void
show_addresses(int sock, const char *bridge, const char *prefix)
{
struct ifbaconf ifbac;
@ -494,7 +494,7 @@ show_addresses(int sock, const char *bridge, const char *prefix)
free(inbuf);
}
int
static int
get_val(const char *cp, u_long *valp)
{
char *endptr;
@ -509,7 +509,7 @@ get_val(const char *cp, u_long *valp)
return (0);
}
int
static int
do_cmd(int sock, const char *bridge, u_long op, void *arg, size_t argsize,
int set)
{
@ -525,7 +525,7 @@ do_cmd(int sock, const char *bridge, u_long op, void *arg, size_t argsize,
return (ioctl(sock, set ? SIOCSDRVSPEC : SIOCGDRVSPEC, &ifd));
}
void
static void
do_ifflag(int sock, const char *bridge, int flag, int set)
{
@ -537,7 +537,7 @@ do_ifflag(int sock, const char *bridge, int flag, int set)
g_ifr_updated = 1;
}
void
static void
do_bridgeflag(int sock, const char *bridge, const char *ifs, int flag,
int set)
{
@ -557,7 +557,7 @@ do_bridgeflag(int sock, const char *bridge, const char *ifs, int flag,
err(1, "unable to set bridge flags");
}
void
static void
cmd_add(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -570,7 +570,7 @@ cmd_add(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_delete(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -582,7 +582,7 @@ cmd_delete(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_up(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -590,7 +590,7 @@ cmd_up(const struct command *cmd, int sock, const char *bridge,
do_ifflag(sock, bridge, IFF_UP, 1);
}
void
static void
cmd_down(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -598,7 +598,7 @@ cmd_down(const struct command *cmd, int sock, const char *bridge,
do_ifflag(sock, bridge, IFF_UP, 0);
}
void
static void
cmd_discover(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -607,7 +607,7 @@ cmd_discover(const struct command *cmd, int sock, const char *bridge,
(cmd->cmd_flags & CMD_INVERT) ? 0 : 1);
}
void
static void
cmd_learn(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -616,7 +616,7 @@ cmd_learn(const struct command *cmd, int sock, const char *bridge,
(cmd->cmd_flags & CMD_INVERT) ? 0 : 1);
}
void
static void
cmd_stp(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -625,7 +625,7 @@ cmd_stp(const struct command *cmd, int sock, const char *bridge,
(cmd->cmd_flags & CMD_INVERT) ? 0 : 1);
}
void
static void
cmd_flush(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -637,7 +637,7 @@ cmd_flush(const struct command *cmd, int sock, const char *bridge,
err(1, "%s", cmd->cmd_keyword);
}
void
static void
cmd_flushall(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -649,7 +649,7 @@ cmd_flushall(const struct command *cmd, int sock, const char *bridge,
err(1, "%s", cmd->cmd_keyword);
}
void
static void
cmd_static(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -670,7 +670,7 @@ cmd_static(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s %s", cmd->cmd_keyword, argv[0], argv[1]);
}
void
static void
cmd_deladdr(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -689,7 +689,7 @@ cmd_deladdr(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_addr(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -697,7 +697,7 @@ cmd_addr(const struct command *cmd, int sock, const char *bridge,
show_addresses(sock, bridge, "\t");
}
void
static void
cmd_maxaddr(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -713,7 +713,7 @@ cmd_maxaddr(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_hellotime(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -729,7 +729,7 @@ cmd_hellotime(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_fwddelay(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -745,7 +745,7 @@ cmd_fwddelay(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_maxage(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -761,7 +761,7 @@ cmd_maxage(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_priority(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -777,7 +777,7 @@ cmd_priority(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_ifpriority(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -796,7 +796,7 @@ cmd_ifpriority(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_ifpathcost(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -815,7 +815,7 @@ cmd_ifpathcost(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_timeout(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
@ -831,7 +831,7 @@ cmd_timeout(const struct command *cmd, int sock, const char *bridge,
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
static void
cmd_ipf(const struct command *cmd, int sock, const char *bridge,
char **argv)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: savecore.c,v 1.81 2009/08/18 04:02:39 dogcow Exp $ */
/* $NetBSD: savecore.c,v 1.82 2011/08/29 14:30:38 joerg Exp $ */
/*-
* Copyright (c) 1986, 1992, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 1992, 1993\
#if 0
static char sccsid[] = "@(#)savecore.c 8.5 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: savecore.c,v 1.81 2009/08/18 04:02:39 dogcow Exp $");
__RCSID("$NetBSD: savecore.c,v 1.82 2011/08/29 14:30:38 joerg Exp $");
#endif
#endif /* not lint */
@ -75,7 +75,7 @@ extern FILE *zopen(const char *fname, const char *mode);
#define KREAD(kd, addr, p)\
(kvm_read(kd, addr, (char *)(p), sizeof(*(p))) != sizeof(*(p)))
struct nlist current_nl[] = { /* Namelist for currently running system. */
static struct nlist current_nl[] = { /* Namelist for currently running system. */
#define X_DUMPDEV 0
{ .n_name = "_dumpdev" },
#define X_DUMPLO 1
@ -110,11 +110,11 @@ struct nlist current_nl[] = { /* Namelist for currently running system. */
{ .n_name = "_ksyms_symtabs" },
{ .n_name = NULL },
};
int cursyms[] = { X_DUMPDEV, X_DUMPLO, X_VERSION, X_DUMPMAG, X_DUMPCDEV, -1 };
int dumpsyms[] = { X_TIME_SECOND, X_TIME, X_DUMPSIZE, X_VERSION, X_PANICSTR,
static int cursyms[] = { X_DUMPDEV, X_DUMPLO, X_VERSION, X_DUMPMAG, X_DUMPCDEV, -1 };
static int dumpsyms[] = { X_TIME_SECOND, X_TIME, X_DUMPSIZE, X_VERSION, X_PANICSTR,
X_DUMPMAG, X_SYMSZ, X_STRSZ, X_KHDR, X_SYMTABS, -1 };
struct nlist dump_nl[] = { /* Name list for dumped system. */
static struct nlist dump_nl[] = { /* Name list for dumped system. */
{ .n_name = "_dumpdev" }, /* Entries MUST be the same as */
{ .n_name = "_dumplo" }, /* those in current_nl[]. */
{ .n_name = "_time_second" },
@ -135,41 +135,39 @@ struct nlist dump_nl[] = { /* Name list for dumped system. */
};
/* Types match kernel declarations. */
off_t dumplo; /* where dump starts on dumpdev */
u_int32_t dumpmag; /* magic number in dump */
int dumpsize; /* amount of memory dumped */
off_t dumpbytes; /* in bytes */
static off_t dumplo; /* where dump starts on dumpdev */
static u_int32_t dumpmag; /* magic number in dump */
static int dumpsize; /* amount of memory dumped */
static off_t dumpbytes; /* in bytes */
const char *kernel; /* name of used kernel */
char *dirname; /* directory to save dumps in */
char *ddname; /* name of dump device */
dev_t dumpdev; /* dump device */
dev_t dumpcdev = NODEV; /* dump device (char equivalent) */
int dumpfd; /* read/write descriptor on dev */
kvm_t *kd_dump; /* kvm descriptor on dev */
time_t now; /* current date */
char panic_mesg[1024];
long panicstr;
char vers[1024];
char gzmode[3];
static const char *kernel; /* name of used kernel */
static char *dirname; /* directory to save dumps in */
static char *ddname; /* name of dump device */
static dev_t dumpdev; /* dump device */
static dev_t dumpcdev = NODEV; /* dump device (char equivalent) */
static int dumpfd; /* read/write descriptor on dev */
static kvm_t *kd_dump; /* kvm descriptor on dev */
static time_t now; /* current date */
static char panic_mesg[1024];
static long panicstr;
static char vers[1024];
static char gzmode[3];
static int clear, compress, force, verbose; /* flags */
void check_kmem(void);
int check_space(void);
void clear_dump(void);
int Create(char *, int);
int dump_exists(void);
char *find_dev(dev_t, mode_t);
int get_crashtime(void);
void kmem_setup(void);
void Lseek(int, off_t, int);
int main(int, char *[]);
int Open(const char *, int rw);
char *rawname(char *s);
void save_core(void);
void usage(void);
void Write(int, void *, int);
static void check_kmem(void);
static int check_space(void);
static void clear_dump(void);
static int Create(char *, int);
static int dump_exists(void);
static char *find_dev(dev_t, mode_t);
static int get_crashtime(void);
static void kmem_setup(void);
static void Lseek(int, off_t, int);
static int Open(const char *, int rw);
static char *rawname(char *s);
static void save_core(void);
__dead static void usage(void);
int
main(int argc, char *argv[])
@ -259,7 +257,7 @@ main(int argc, char *argv[])
exit(0);
}
void
static void
kmem_setup(void)
{
kvm_t *kd_kern;
@ -392,7 +390,7 @@ kmem_setup(void)
kvm_close(kd_kern);
}
void
static void
check_kmem(void)
{
char *cp, *bufdata;
@ -490,7 +488,7 @@ nomsguf:
}
}
int
static int
dump_exists(void)
{
u_int32_t newdumpmag;
@ -525,7 +523,7 @@ dump_exists(void)
return (1);
}
void
static void
clear_dump(void)
{
if (kvm_dump_inval(kd_dump) == -1)
@ -534,7 +532,7 @@ clear_dump(void)
}
char buf[1024 * 1024];
static char buf[1024 * 1024];
static void
save_kernel(int ofd, FILE *fp, char *path)
@ -673,7 +671,7 @@ save_ksyms(int ofd, FILE *fp, char *path)
return 0;
}
void
static void
save_core(void)
{
FILE *fp;
@ -815,7 +813,7 @@ err2: syslog(LOG_WARNING,
sleep(1);
}
char *
static char *
find_dev(dev_t dev, mode_t type)
{
DIR *dfd;
@ -854,7 +852,7 @@ find_dev(dev_t dev, mode_t type)
exit(1);
}
char *
static char *
rawname(char *s)
{
char *sl;
@ -874,7 +872,7 @@ rawname(char *s)
return (sl);
}
int
static int
get_crashtime(void)
{
time_t dumptime; /* Time the dump was taken. */
@ -902,7 +900,7 @@ get_crashtime(void)
return (1);
}
int
static int
check_space(void)
{
FILE *fp;
@ -945,7 +943,7 @@ check_space(void)
return (1);
}
int
static int
Open(const char *name, int rw)
{
int fd;
@ -957,7 +955,7 @@ Open(const char *name, int rw)
return (fd);
}
void
static void
Lseek(int fd, off_t off, int flag)
{
off_t ret;
@ -969,7 +967,7 @@ Lseek(int fd, off_t off, int flag)
}
}
int
static int
Create(char *file, int mode)
{
int fd;
@ -982,18 +980,7 @@ Create(char *file, int mode)
return (fd);
}
void
Write(int fd, void *bp, int size)
{
int n;
if ((n = write(fd, bp, size)) < size) {
syslog(LOG_ERR, "write: %s", strerror(n == -1 ? errno : EIO));
exit(1);
}
}
void
static void
usage(void)
{
(void)syslog(LOG_ERR,