Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/init Be more static
details: https://anonhg.NetBSD.org/src/rev/56e196c0b7a7
branches: trunk
changeset: 768805:56e196c0b7a7
user: joerg <joerg%NetBSD.org@localhost>
date: Sat Aug 27 17:43:42 2011 +0000
description:
Be more static
diffstat:
sbin/init/init.c | 181 ++++++++++++++++++++++++++----------------------------
1 files changed, 88 insertions(+), 93 deletions(-)
diffs (truncated from 503 to 300 lines):
diff -r 341b9261d06b -r 56e196c0b7a7 sbin/init/init.c
--- a/sbin/init/init.c Sat Aug 27 17:38:16 2011 +0000
+++ b/sbin/init/init.c Sat Aug 27 17:43:42 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.100 2009/12/29 17:07:17 elad Exp $ */
+/* $NetBSD: init.c,v 1.101 2011/08/27 17:43:42 joerg Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: init.c,v 1.100 2009/12/29 17:07:17 elad Exp $");
+__RCSID("$NetBSD: init.c,v 1.101 2011/08/27 17:43:42 joerg Exp $");
#endif
#endif /* not lint */
@@ -89,7 +89,7 @@
#define STALL_TIMEOUT 30 /* wait N secs after warning */
#define DEATH_WATCH 10 /* wait N secs for procs to die */
-const struct timespec dtrtime = {.tv_sec = 0, .tv_nsec = 250000};
+static const struct timespec dtrtime = {.tv_sec = 0, .tv_nsec = 250000};
#if defined(RESCUEDIR)
#define INIT_BSHELL RESCUEDIR "/sh"
@@ -101,19 +101,14 @@
#define INIT_PATH _PATH_STDPATH
#endif
-int main(int, char *[]);
-
-void handle(sig_t, ...);
-void delset(sigset_t *, ...);
+static void handle(sig_t, ...);
+static void delset(sigset_t *, ...);
-void stall(const char *, ...)
- __attribute__((__format__(__printf__,1,2)));
-void warning(const char *, ...)
- __attribute__((__format__(__printf__,1,2)));
-void emergency(const char *, ...)
- __attribute__((__format__(__printf__,1,2)));
-void disaster(int);
-void badsys(int);
+static void stall(const char *, ...) __printflike(1, 2);
+static void warning(const char *, ...) __printflike(1, 2);
+static void emergency(const char *, ...) __printflike(1, 2);
+__dead static void disaster(int);
+static void badsys(int);
/*
* We really need a recursive typedef...
@@ -131,18 +126,18 @@
#define CLEAN_TTYS 'T'
#define CATATONIA 'c'
-state_func_t single_user(void);
-state_func_t runcom(void);
-state_func_t read_ttys(void);
-state_func_t multi_user(void);
-state_func_t clean_ttys(void);
-state_func_t catatonia(void);
-state_func_t death(void);
+static state_func_t single_user(void);
+static state_func_t runcom(void);
+static state_func_t read_ttys(void);
+static state_func_t multi_user(void);
+static state_func_t clean_ttys(void);
+static state_func_t catatonia(void);
+static state_func_t death(void);
-enum { AUTOBOOT, FASTBOOT } runcom_mode = AUTOBOOT;
+static enum { AUTOBOOT, FASTBOOT } runcom_mode = AUTOBOOT;
-void transition(state_t);
-void setctty(const char *);
+static void transition(state_t);
+static void setctty(const char *);
typedef struct init_session {
int se_index; /* index of entry in ttys file */
@@ -160,39 +155,39 @@
struct init_session *se_next;
} session_t;
-void free_session(session_t *);
-session_t *new_session(session_t *, int, struct ttyent *);
-session_t *sessions;
+static void free_session(session_t *);
+static session_t *new_session(session_t *, int, struct ttyent *);
+static session_t *sessions;
-char **construct_argv(char *);
-void start_window_system(session_t *);
-void collect_child(pid_t, int);
-pid_t start_getty(session_t *);
-void transition_handler(int);
-void alrm_handler(int);
-int has_securelevel(void);
-void setsecuritylevel(int);
-int getsecuritylevel(void);
-int securelevel_present;
-int setupargv(session_t *, struct ttyent *);
-int clang;
+static char **construct_argv(char *);
+static void start_window_system(session_t *);
+static void collect_child(pid_t, int);
+static pid_t start_getty(session_t *);
+static void transition_handler(int);
+static void alrm_handler(int);
+static int has_securelevel(void);
+static void setsecuritylevel(int);
+static int getsecuritylevel(void);
+static int securelevel_present;
+static int setupargv(session_t *, struct ttyent *);
+static int clang;
-int start_session_db(void);
-void add_session(session_t *);
-void del_session(session_t *);
-session_t *find_session(pid_t);
-DB *session_db;
+static int start_session_db(void);
+static void add_session(session_t *);
+static void del_session(session_t *);
+static session_t *find_session(pid_t);
+static DB *session_db;
-int do_setttyent(void);
+static int do_setttyent(void);
#ifndef LETS_GET_SMALL
-state_t requested_transition = runcom;
+static state_t requested_transition = runcom;
-void clear_session_logs(session_t *, int);
-state_func_t runetcrc(int);
+static void clear_session_logs(session_t *, int);
+static state_func_t runetcrc(int);
#ifdef SUPPORT_UTMPX
static struct timeval boot_time;
-state_t current_state = death;
+static state_t current_state = death;
static void session_utmpx(const session_t *, int);
static void make_utmpx(const char *, const char *, int, pid_t,
const struct timeval *, int);
@@ -201,14 +196,14 @@
#endif
#ifdef CHROOT
-int did_multiuser_chroot = 0;
-char rootdir[PATH_MAX];
-int shouldchroot(void);
-int createsysctlnode(void);
+static int did_multiuser_chroot = 0;
+static char rootdir[PATH_MAX];
+static int shouldchroot(void);
+static int createsysctlnode(void);
#endif /* CHROOT */
#else /* LETS_GET_SMALL */
-state_t requested_transition = single_user;
+static state_t requested_transition = single_user;
#endif /* !LETS_GET_SMALL */
#ifdef MFS_DEV_IF_NO_CONSOLE
@@ -347,7 +342,7 @@
/*
* Associate a function with a signal handler.
*/
-void
+static void
handle(sig_t handler, ...)
{
int sig;
@@ -372,7 +367,7 @@
/*
* Delete a set of signals from a mask.
*/
-void
+static void
delset(sigset_t *maskp, ...)
{
int sig;
@@ -418,7 +413,7 @@
* to read it and to save log or hardcopy output if the problem is chronic).
* NB: should send a message to the session logger to avoid blocking.
*/
-void
+static void
stall(const char *message, ...)
{
va_list ap;
@@ -435,7 +430,7 @@
* If cpp had variadic macros, the two functions could be #defines for another.
* NB: should send a message to the session logger to avoid blocking.
*/
-void
+static void
warning(const char *message, ...)
{
va_list ap;
@@ -450,7 +445,7 @@
* Log an emergency message.
* NB: should send a message to the session logger to avoid blocking.
*/
-void
+static void
emergency(const char *message, ...)
{
va_list ap;
@@ -467,7 +462,7 @@
* These may arise if a system does not support sysctl.
* We tolerate up to 25 of these, then throw in the towel.
*/
-void
+static void
badsys(int sig)
{
static int badcount = 0;
@@ -480,7 +475,7 @@
/*
* Catch an unexpected signal.
*/
-void
+static void
disaster(int sig)
{
@@ -492,7 +487,7 @@
/*
* Check if securelevel is present.
*/
-int
+static int
has_securelevel(void)
{
#ifdef KERN_SECURELVL
@@ -516,7 +511,7 @@
/*
* Get the security level of the kernel.
*/
-int
+static int
getsecuritylevel(void)
{
#ifdef KERN_SECURELVL
@@ -542,7 +537,7 @@
/*
* Set the security level of the kernel.
*/
-void
+static void
setsecuritylevel(int newlevel)
{
#ifdef KERN_SECURELVL
@@ -572,7 +567,7 @@
* Change states in the finite state machine.
* The initial state is passed as an argument.
*/
-void
+static void
transition(state_t s)
{
@@ -595,7 +590,7 @@
* Close out the accounting files for a login session.
* NB: should send a message to the session logger to avoid blocking.
*/
-void
+static void
clear_session_logs(session_t *sp, int status)
{
#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
@@ -617,7 +612,7 @@
* Start a session and allocate a controlling terminal.
* Only called by children of init after forking.
*/
-void
+static void
setctty(const char *name)
{
int fd;
@@ -637,7 +632,7 @@
/*
* Bring the system up single user.
*/
-state_func_t
+static state_func_t
single_user(void)
{
pid_t pid, wpid;
@@ -822,7 +817,7 @@
#ifndef LETS_GET_SMALL
/* ARGSUSED */
-state_func_t
+static state_func_t
Home |
Main Index |
Thread Index |
Old Index