PM: Convert K&R C -> ANSI C

Aditionally this removes all trailing whitespaces in pm server code
using: sed -i 's/[[:space:]]*$//' *.c

Change-Id: Ie44162fd56cd7042f4f0cc7bd7314b17ea128761
This commit is contained in:
Richard Sailer 2016-07-08 15:17:14 +02:00 committed by Lionel Sambuc
parent 1717959aeb
commit 637f688f0d
13 changed files with 204 additions and 164 deletions

View File

@ -77,8 +77,8 @@ clock_t ticks;
/*===========================================================================* /*===========================================================================*
* is_sane_timeval * * is_sane_timeval *
*===========================================================================*/ *===========================================================================*/
static int is_sane_timeval(tv) static int
struct timeval *tv; is_sane_timeval(struct timeval *tv)
{ {
/* This imposes a reasonable time value range for setitimer. */ /* This imposes a reasonable time value range for setitimer. */
return (tv->tv_sec >= 0 && tv->tv_sec <= MAX_SECS && return (tv->tv_sec >= 0 && tv->tv_sec <= MAX_SECS &&
@ -88,7 +88,8 @@ struct timeval *tv;
/*===========================================================================* /*===========================================================================*
* do_itimer * * do_itimer *
*===========================================================================*/ *===========================================================================*/
int do_itimer() int
do_itimer(void)
{ {
struct itimerval ovalue, value; /* old and new interval timers */ struct itimerval ovalue, value; /* old and new interval timers */
int setval, getval; /* set and/or retrieve the values? */ int setval, getval; /* set and/or retrieve the values? */
@ -154,11 +155,8 @@ int do_itimer()
/*===========================================================================* /*===========================================================================*
* getset_vtimer * * getset_vtimer *
*===========================================================================*/ *===========================================================================*/
static void getset_vtimer(rmp, which, value, ovalue) static void
struct mproc *rmp; getset_vtimer(struct mproc *rmp, int which, struct itimerval *value, struct itimerval *ovalue)
int which;
struct itimerval *value;
struct itimerval *ovalue;
{ {
clock_t newticks, *nptr; /* the new timer value, in ticks */ clock_t newticks, *nptr; /* the new timer value, in ticks */
clock_t oldticks, *optr; /* the old ticks value, in ticks */ clock_t oldticks, *optr; /* the old ticks value, in ticks */
@ -219,9 +217,8 @@ struct itimerval *ovalue;
/*===========================================================================* /*===========================================================================*
* check_vtimer * * check_vtimer *
*===========================================================================*/ *===========================================================================*/
void check_vtimer(proc_nr, sig) void
int proc_nr; check_vtimer(int proc_nr, int sig)
int sig;
{ {
register struct mproc *rmp; register struct mproc *rmp;
int which, num; int which, num;
@ -245,9 +242,8 @@ int sig;
/*===========================================================================* /*===========================================================================*
* get_realtimer * * get_realtimer *
*===========================================================================*/ *===========================================================================*/
static void get_realtimer(rmp, value) static void
struct mproc *rmp; get_realtimer(struct mproc *rmp, struct itimerval *value)
struct itimerval *value;
{ {
clock_t exptime; /* time at which alarm will expire */ clock_t exptime; /* time at which alarm will expire */
clock_t uptime; /* current system time */ clock_t uptime; /* current system time */
@ -278,9 +274,8 @@ struct itimerval *value;
/*===========================================================================* /*===========================================================================*
* set_realtimer * * set_realtimer *
*===========================================================================*/ *===========================================================================*/
static void set_realtimer(rmp, value) static void
struct mproc *rmp; set_realtimer(struct mproc *rmp, struct itimerval *value)
struct itimerval *value;
{ {
clock_t ticks; /* New amount of ticks to the next alarm. */ clock_t ticks; /* New amount of ticks to the next alarm. */
clock_t interval; /* New amount of ticks for the alarm's interval. */ clock_t interval; /* New amount of ticks for the alarm's interval. */

View File

@ -34,7 +34,8 @@
/*===========================================================================* /*===========================================================================*
* do_exec * * do_exec *
*===========================================================================*/ *===========================================================================*/
int do_exec() int
do_exec(void)
{ {
message m; message m;

View File

@ -41,7 +41,8 @@ static void cleanup(register struct mproc *rmp);
/*===========================================================================* /*===========================================================================*
* do_fork * * do_fork *
*===========================================================================*/ *===========================================================================*/
int do_fork() int
do_fork(void)
{ {
/* The process pointed to by 'mp' has forked. Create a child process. */ /* The process pointed to by 'mp' has forked. Create a child process. */
register struct mproc *rmp; /* pointer to parent */ register struct mproc *rmp; /* pointer to parent */
@ -141,7 +142,8 @@ int do_fork()
/*===========================================================================* /*===========================================================================*
* do_srv_fork * * do_srv_fork *
*===========================================================================*/ *===========================================================================*/
int do_srv_fork() int
do_srv_fork(void)
{ {
/* The process pointed to by 'mp' has forked. Create a child process. */ /* The process pointed to by 'mp' has forked. Create a child process. */
register struct mproc *rmp; /* pointer to parent */ register struct mproc *rmp; /* pointer to parent */
@ -240,7 +242,8 @@ int do_srv_fork()
/*===========================================================================* /*===========================================================================*
* do_exit * * do_exit *
*===========================================================================*/ *===========================================================================*/
int do_exit() int
do_exit(void)
{ {
/* Perform the exit(status) system call. The real work is done by exit_proc(), /* Perform the exit(status) system call. The real work is done by exit_proc(),
* which is also called when a process is killed by a signal. System processes * which is also called when a process is killed by a signal. System processes
@ -261,10 +264,12 @@ int do_exit()
/*===========================================================================* /*===========================================================================*
* exit_proc * * exit_proc *
*===========================================================================*/ *===========================================================================*/
void exit_proc(rmp, exit_status, dump_core) void
register struct mproc *rmp; /* pointer to the process to be terminated */ exit_proc(
int exit_status; /* the process' exit status (for parent) */ register struct mproc *rmp, /* pointer to the process to be terminated */
int dump_core; /* flag indicating whether to dump core */ int exit_status, /* the process' exit status (for parent) */
int dump_core /* flag indicating whether to dump core */
)
{ {
/* A process is done. Release most of the process' possessions. If its /* A process is done. Release most of the process' possessions. If its
* parent is waiting, release the rest, else keep the process slot and * parent is waiting, release the rest, else keep the process slot and
@ -466,7 +471,8 @@ void exit_restart(struct mproc *rmp)
/*===========================================================================* /*===========================================================================*
* do_wait4 * * do_wait4 *
*===========================================================================*/ *===========================================================================*/
int do_wait4() int
do_wait4(void)
{ {
/* A process wants to wait for a child to terminate. If a child is already /* A process wants to wait for a child to terminate. If a child is already
* waiting, go clean it up and let this WAIT4 call terminate. Otherwise, * waiting, go clean it up and let this WAIT4 call terminate. Otherwise,
@ -560,9 +566,11 @@ int do_wait4()
/*===========================================================================* /*===========================================================================*
* wait_test * * wait_test *
*===========================================================================*/ *===========================================================================*/
int wait_test(rmp, child) int
struct mproc *rmp; /* process that may be waiting */ wait_test(
struct mproc *child; /* process that may be waited for */ struct mproc *rmp, /* process that may be waiting */
struct mproc *child /* process that may be waited for */
)
{ {
/* See if a parent or tracer process is waiting for a child process. /* See if a parent or tracer process is waiting for a child process.
* A tracer is considered to be a pseudo-parent. * A tracer is considered to be a pseudo-parent.
@ -582,8 +590,8 @@ struct mproc *child; /* process that may be waited for */
/*===========================================================================* /*===========================================================================*
* zombify * * zombify *
*===========================================================================*/ *===========================================================================*/
static void zombify(rmp) static void
struct mproc *rmp; zombify(struct mproc *rmp)
{ {
/* Zombify a process. First check if the exiting process is traced by a process /* Zombify a process. First check if the exiting process is traced by a process
* other than its parent; if so, the tracer must be notified about the exit * other than its parent; if so, the tracer must be notified about the exit
@ -618,9 +626,11 @@ struct mproc *rmp;
/*===========================================================================* /*===========================================================================*
* check_parent * * check_parent *
*===========================================================================*/ *===========================================================================*/
static void check_parent(child, try_cleanup) static void
struct mproc *child; /* tells which process is exiting */ check_parent(
int try_cleanup; /* clean up the child when done? */ struct mproc *child, /* tells which process is exiting */
int try_cleanup /* clean up the child when done? */
)
{ {
/* We would like to inform the parent of an exiting child about the child's /* We would like to inform the parent of an exiting child about the child's
* death. If the parent is waiting for the child, tell it immediately; * death. If the parent is waiting for the child, tell it immediately;
@ -718,8 +728,10 @@ static int tell_parent(struct mproc *child, vir_bytes addr)
/*===========================================================================* /*===========================================================================*
* tell_tracer * * tell_tracer *
*===========================================================================*/ *===========================================================================*/
static void tell_tracer(child) static void
struct mproc *child; /* tells which process is exiting */ tell_tracer(
struct mproc *child /* tells which process is exiting */
)
{ {
int mp_tracer; int mp_tracer;
struct mproc *tracer; struct mproc *tracer;
@ -744,8 +756,10 @@ struct mproc *child; /* tells which process is exiting */
/*===========================================================================* /*===========================================================================*
* tracer_died * * tracer_died *
*===========================================================================*/ *===========================================================================*/
static void tracer_died(child) static void
struct mproc *child; /* process being traced */ tracer_died(
struct mproc *child /* process being traced */
)
{ {
/* The process that was tracing the given child, has died for some reason. /* The process that was tracing the given child, has died for some reason.
* This is really the tracer's fault, but we can't let INIT deal with this. * This is really the tracer's fault, but we can't let INIT deal with this.
@ -778,8 +792,10 @@ struct mproc *child; /* process being traced */
/*===========================================================================* /*===========================================================================*
* cleanup * * cleanup *
*===========================================================================*/ *===========================================================================*/
static void cleanup(rmp) static void
register struct mproc *rmp; /* tells which process is exiting */ cleanup(
register struct mproc *rmp /* tells which process is exiting */
)
{ {
/* Release the process table entry and reinitialize some field. */ /* Release the process table entry and reinitialize some field. */
rmp->mp_pid = 0; rmp->mp_pid = 0;

View File

@ -15,7 +15,8 @@
/*===========================================================================* /*===========================================================================*
* do_get * * do_get *
*===========================================================================*/ *===========================================================================*/
int do_get() int
do_get(void)
{ {
/* Handle PM_GETUID, PM_GETGID, PM_GETGROUPS, PM_GETPID, PM_GETPGRP, PM_GETSID, /* Handle PM_GETUID, PM_GETGID, PM_GETGROUPS, PM_GETPID, PM_GETPGRP, PM_GETSID,
* PM_ISSETUGID. * PM_ISSETUGID.
@ -90,7 +91,8 @@ int do_get()
/*===========================================================================* /*===========================================================================*
* do_set * * do_set *
*===========================================================================*/ *===========================================================================*/
int do_set() int
do_set(void)
{ {
/* Handle PM_SETUID, PM_SETEUID, PM_SETGID, PM_SETGROUPS, PM_SETEGID, and /* Handle PM_SETUID, PM_SETEUID, PM_SETGID, PM_SETGROUPS, PM_SETEGID, and
* SETSID. These calls have in common that, if successful, they will be * SETSID. These calls have in common that, if successful, they will be

View File

@ -47,7 +47,8 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info);
/*===========================================================================* /*===========================================================================*
* main * * main *
*===========================================================================*/ *===========================================================================*/
int main() int
main(void)
{ {
/* Main routine of the process manager. */ /* Main routine of the process manager. */
unsigned int call_index; unsigned int call_index;
@ -112,7 +113,8 @@ int main()
/*===========================================================================* /*===========================================================================*
* sef_local_startup * * sef_local_startup *
*===========================================================================*/ *===========================================================================*/
static void sef_local_startup() static void
sef_local_startup(void)
{ {
/* Register init callbacks. */ /* Register init callbacks. */
sef_setcb_init_fresh(sef_cb_init_fresh); sef_setcb_init_fresh(sef_cb_init_fresh);
@ -246,9 +248,11 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
/*===========================================================================* /*===========================================================================*
* reply * * reply *
*===========================================================================*/ *===========================================================================*/
void reply(proc_nr, result) void
int proc_nr; /* process to reply to */ reply(
int result; /* result of call (usually OK or error #) */ int proc_nr, /* process to reply to */
int result /* result of call (usually OK or error #) */
)
{ {
/* Send a reply to a user process. System calls may occasionally fill in other /* Send a reply to a user process. System calls may occasionally fill in other
* fields, this is only for the main return value and for sending the reply. * fields, this is only for the main return value and for sending the reply.
@ -270,8 +274,10 @@ int result; /* result of call (usually OK or error #) */
/*===========================================================================* /*===========================================================================*
* get_nice_value * * get_nice_value *
*===========================================================================*/ *===========================================================================*/
static int get_nice_value(queue) static int
int queue; /* store mem chunks here */ get_nice_value(
int queue /* store mem chunks here */
)
{ {
/* Processes in the boot image have a priority assigned. The PM doesn't know /* Processes in the boot image have a priority assigned. The PM doesn't know
* about priorities, but uses 'nice' values instead. The priority is between * about priorities, but uses 'nice' values instead. The priority is between
@ -287,7 +293,8 @@ int queue; /* store mem chunks here */
/*===========================================================================* /*===========================================================================*
* handle_vfs_reply * * handle_vfs_reply *
*===========================================================================*/ *===========================================================================*/
static void handle_vfs_reply() static void
handle_vfs_reply(void)
{ {
struct mproc *rmp; struct mproc *rmp;
endpoint_t proc_e; endpoint_t proc_e;

View File

@ -9,7 +9,8 @@
/*===========================================================================* /*===========================================================================*
* do_setmcontext * * do_setmcontext *
*===========================================================================*/ *===========================================================================*/
int do_setmcontext() int
do_setmcontext(void)
{ {
return sys_setmcontext(who_e, m_in.m_lc_pm_mcontext.ctx); return sys_setmcontext(who_e, m_in.m_lc_pm_mcontext.ctx);
} }
@ -18,7 +19,8 @@ int do_setmcontext()
/*===========================================================================* /*===========================================================================*
* do_getmcontext * * do_getmcontext *
*===========================================================================*/ *===========================================================================*/
int do_getmcontext() int
do_getmcontext(void)
{ {
return sys_getmcontext(who_e, m_in.m_lc_pm_mcontext.ctx); return sys_getmcontext(who_e, m_in.m_lc_pm_mcontext.ctx);
} }

View File

@ -68,7 +68,8 @@ unsigned long calls_stats[NR_PM_CALLS];
/*===========================================================================* /*===========================================================================*
* do_sysuname * * do_sysuname *
*===========================================================================*/ *===========================================================================*/
int do_sysuname() int
do_sysuname(void)
{ {
/* Set or get uname strings. */ /* Set or get uname strings. */
int r; int r;
@ -103,7 +104,8 @@ int do_sysuname()
/*===========================================================================* /*===========================================================================*
* do_getsysinfo * * do_getsysinfo *
*===========================================================================*/ *===========================================================================*/
int do_getsysinfo() int
do_getsysinfo(void)
{ {
vir_bytes src_addr, dst_addr; vir_bytes src_addr, dst_addr;
size_t len; size_t len;
@ -183,7 +185,8 @@ int do_getepinfo(void)
/*===========================================================================* /*===========================================================================*
* do_reboot * * do_reboot *
*===========================================================================*/ *===========================================================================*/
int do_reboot() int
do_reboot(void)
{ {
message m; message m;
@ -222,7 +225,8 @@ int do_reboot()
/*===========================================================================* /*===========================================================================*
* do_getsetpriority * * do_getsetpriority *
*===========================================================================*/ *===========================================================================*/
int do_getsetpriority() int
do_getsetpriority(void)
{ {
int r, arg_which, arg_who, arg_pri; int r, arg_which, arg_who, arg_pri;
struct mproc *rmp; struct mproc *rmp;

View File

@ -380,11 +380,13 @@ int process_ksig(endpoint_t proc_nr_e, int signo)
/*===========================================================================* /*===========================================================================*
* sig_proc * * sig_proc *
*===========================================================================*/ *===========================================================================*/
void sig_proc(rmp, signo, trace, ksig) void
register struct mproc *rmp; /* pointer to the process to be signaled */ sig_proc(
int signo; /* signal to send to process (1 to _NSIG-1) */ register struct mproc *rmp, /* pointer to the process to be signaled */
int trace; /* pass signal to tracer first? */ int signo, /* signal to send to process (1 to _NSIG-1) */
int ksig; /* non-zero means signal comes from kernel */ int trace, /* pass signal to tracer first? */
int ksig /* non-zero means signal comes from kernel */
)
{ {
/* Send a signal to a process. Check to see if the signal is to be caught, /* Send a signal to a process. Check to see if the signal is to be caught,
* ignored, tranformed into a message (for system processes) or blocked. * ignored, tranformed into a message (for system processes) or blocked.
@ -540,9 +542,11 @@ int ksig; /* non-zero means signal comes from kernel */
/*===========================================================================* /*===========================================================================*
* sig_proc_exit * * sig_proc_exit *
*===========================================================================*/ *===========================================================================*/
static void sig_proc_exit(rmp, signo) static void
struct mproc *rmp; /* process that must exit */ sig_proc_exit(
int signo; /* signal that caused termination */ struct mproc *rmp, /* process that must exit */
int signo /* signal that caused termination */
)
{ {
rmp->mp_sigstatus = (char) signo; rmp->mp_sigstatus = (char) signo;
if (sigismember(&core_sset, signo)) { if (sigismember(&core_sset, signo)) {
@ -644,8 +648,8 @@ int ksig; /* non-zero means signal comes from kernel */
/*===========================================================================* /*===========================================================================*
* check_pending * * check_pending *
*===========================================================================*/ *===========================================================================*/
void check_pending(rmp) void
register struct mproc *rmp; check_pending(register struct mproc *rmp)
{ {
/* Check to see if any pending signals have been unblocked. Deliver as many /* Check to see if any pending signals have been unblocked. Deliver as many
* of them as we can, until we have to wait for a reply from VFS first. * of them as we can, until we have to wait for a reply from VFS first.
@ -680,8 +684,8 @@ register struct mproc *rmp;
/*===========================================================================* /*===========================================================================*
* restart_sigs * * restart_sigs *
*===========================================================================*/ *===========================================================================*/
void restart_sigs(rmp) void
struct mproc *rmp; restart_sigs(struct mproc *rmp)
{ {
/* VFS has replied to a request from us; do signal-related work. /* VFS has replied to a request from us; do signal-related work.
*/ */
@ -712,8 +716,10 @@ struct mproc *rmp;
/*===========================================================================* /*===========================================================================*
* unpause * * unpause *
*===========================================================================*/ *===========================================================================*/
static int unpause(rmp) static int
struct mproc *rmp; /* which process */ unpause(
struct mproc *rmp /* which process */
)
{ {
/* A signal is to be sent to a process. If that process is hanging on a /* A signal is to be sent to a process. If that process is hanging on a
* system call, the system call must be terminated with EINTR. First check if * system call, the system call must be terminated with EINTR. First check if
@ -766,9 +772,11 @@ struct mproc *rmp; /* which process */
/*===========================================================================* /*===========================================================================*
* sig_send * * sig_send *
*===========================================================================*/ *===========================================================================*/
static int sig_send(rmp, signo) static int
struct mproc *rmp; /* what process to spawn a signal handler in */ sig_send(
int signo; /* signal to send to process (1 to _NSIG-1) */ struct mproc *rmp, /* what process to spawn a signal handler in */
int signo /* signal to send to process (1 to _NSIG-1) */
)
{ {
/* The process is supposed to catch this signal. Spawn a signal handler. /* The process is supposed to catch this signal. Spawn a signal handler.
* Return TRUE if this succeeded, FALSE otherwise. * Return TRUE if this succeeded, FALSE otherwise.

View File

@ -18,7 +18,8 @@
/*===========================================================================* /*===========================================================================*
* do_gettime * * do_gettime *
*===========================================================================*/ *===========================================================================*/
int do_gettime() int
do_gettime(void)
{ {
clock_t ticks, realtime, clock; clock_t ticks, realtime, clock;
time_t boottime; time_t boottime;
@ -48,7 +49,8 @@ int do_gettime()
/*===========================================================================* /*===========================================================================*
* do_getres * * do_getres *
*===========================================================================*/ *===========================================================================*/
int do_getres() int
do_getres(void)
{ {
switch (m_in.m_lc_pm_time.clk_id) { switch (m_in.m_lc_pm_time.clk_id) {
case CLOCK_REALTIME: case CLOCK_REALTIME:
@ -65,7 +67,8 @@ int do_getres()
/*===========================================================================* /*===========================================================================*
* do_settime * * do_settime *
*===========================================================================*/ *===========================================================================*/
int do_settime() int
do_settime(void)
{ {
int s; int s;
@ -87,7 +90,8 @@ int do_settime()
/*===========================================================================* /*===========================================================================*
* do_time * * do_time *
*===========================================================================*/ *===========================================================================*/
int do_time() int
do_time(void)
{ {
/* Perform the time(tp) system call. */ /* Perform the time(tp) system call. */
struct timespec tv; struct timespec tv;
@ -102,7 +106,8 @@ int do_time()
/*===========================================================================* /*===========================================================================*
* do_stime * * do_stime *
*===========================================================================*/ *===========================================================================*/
int do_stime() int
do_stime(void)
{ {
/* Perform the stime(tp) system call. Retrieve the system's uptime (ticks /* Perform the stime(tp) system call. Retrieve the system's uptime (ticks
* since boot) and pass the new time in seconds at system boot to the kernel. * since boot) and pass the new time in seconds at system boot to the kernel.

View File

@ -38,7 +38,8 @@
/*===========================================================================* /*===========================================================================*
* do_trace * * do_trace *
*===========================================================================*/ *===========================================================================*/
int do_trace() int
do_trace(void)
{ {
register struct mproc *child; register struct mproc *child;
struct ptrace_range pr; struct ptrace_range pr;
@ -251,9 +252,8 @@ int do_trace()
/*===========================================================================* /*===========================================================================*
* trace_stop * * trace_stop *
*===========================================================================*/ *===========================================================================*/
void trace_stop(rmp, signo) void
register struct mproc *rmp; trace_stop(register struct mproc *rmp, int signo)
int signo;
{ {
/* A traced process got a signal so stop it. */ /* A traced process got a signal so stop it. */

View File

@ -53,8 +53,8 @@ pid_t get_free_pid()
/*===========================================================================* /*===========================================================================*
* find_param * * find_param *
*===========================================================================*/ *===========================================================================*/
char *find_param(name) char *
const char *name; find_param(const char *name)
{ {
register const char *namep; register const char *namep;
register char *envp; register char *envp;