]> granicus.if.org Git - sudo/commitdiff
K&R fixes
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 4 Jun 2010 19:35:13 +0000 (15:35 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 4 Jun 2010 19:35:13 +0000 (15:35 -0400)
--HG--
branch : 1.7

exec.c
iolog.c
missing.h
sudo_edit.c

diff --git a/exec.c b/exec.c
index a0448443838362cf36477a10ed20a2785c900d4e..dc8e96d495fe80da7225a1935563f56b3fdd30b9 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -143,7 +143,7 @@ pty_setup(uid)
 }
 
 static void
-check_foreground(void)
+check_foreground()
 {
     if (io_fds[SFD_USERTTY] != -1) {
        foreground = tcgetpgrp(io_fds[SFD_USERTTY]) == ppgrp;
@@ -161,7 +161,9 @@ check_foreground(void)
  * Returns SIGUSR1 if the child should be resume in foreground else SIGUSR2.
  */
 static int
-suspend_parent(int signo, struct io_buffer *iobufs)
+suspend_parent(signo, iobufs)
+    int signo;
+    struct io_buffer *iobufs;
 {
     sigaction_t sa, osa;
     int n, oldmode = ttymode, rval = 0;
@@ -236,7 +238,10 @@ suspend_parent(int signo, struct io_buffer *iobufs)
  * ala execvp(3) if we get ENOEXEC.
  */
 static int
-my_execve(const char *path, char *argv[], char *envp[])
+my_execve(path, argv, envp)
+    const char *path;
+    char *argv[];
+    char *envp[];
 {
     execve(path, argv, envp);
     if (errno == ENOEXEC) {
@@ -249,7 +254,9 @@ my_execve(const char *path, char *argv[], char *envp[])
 }
 
 static void
-terminate_child(pid_t pid, int use_pgrp)
+terminate_child(pid, use_pgrp)
+    pid_t pid;
+    int use_pgrp;
 {
     /*
      * Kill child with increasing urgency.
@@ -269,8 +276,11 @@ terminate_child(pid_t pid, int use_pgrp)
 }
 
 static struct io_buffer *
-io_buf_new(int rfd, int wfd, int (*action)(const char *, unsigned int),
-    struct io_buffer *head)
+io_buf_new(rfd, wfd, action, head)
+    int rfd;
+    int wfd;
+    int (*action) __P((const char *, unsigned int));
+    struct io_buffer *head;
 {
     struct io_buffer *iob;
 
@@ -288,7 +298,10 @@ io_buf_new(int rfd, int wfd, int (*action)(const char *, unsigned int),
  * Returns the number of errors.
  */
 static int
-perform_io(struct io_buffer *iobufs, fd_set *fdsr, fd_set *fdsw)
+perform_io(iobufs, fdsr, fdsw)
+    struct io_buffer *iobufs;
+    fd_set *fdsr;
+    fd_set *fdsw;
 {
     struct io_buffer *iob;
     int n, errors = 0;
@@ -353,8 +366,12 @@ perform_io(struct io_buffer *iobufs, fd_set *fdsr, fd_set *fdsw)
  *     controlling tty, belongs to child's session but has its own pgrp.
  */
 int
-sudo_execve(const char *path, char *argv[], char *envp[], uid_t uid,
-    struct command_status *cstat)
+sudo_execve(path, argv, envp, uid, cstat)
+    const char *path;
+    char *argv[];
+    char *envp[];
+    uid_t uid;
+    struct command_status *cstat;
 {
     sigaction_t sa;
     struct io_buffer *iob, *iobufs = NULL;
@@ -742,7 +759,9 @@ sudo_execve(const char *path, char *argv[], char *envp[], uid_t uid,
 }
 
 static void
-deliver_signal(pid_t pid, int signo)
+deliver_signal(pid, signo)
+    pid_t pid;
+    int signo;
 {
     int status;
 
@@ -788,7 +807,9 @@ deliver_signal(pid_t pid, int signo)
  * Return value is the same as send(2).
  */
 static int
-send_status(int fd, struct command_status *cstat)
+send_status(fd, cstat)
+    int fd;
+    struct command_status *cstat;
 {
     int n = -1;
 
@@ -808,7 +829,9 @@ send_status(int fd, struct command_status *cstat)
  * Returns TRUE if child is still alive, else FALSE.
  */
 static int
-handle_sigchld(int backchannel, struct command_status *cstat)
+handle_sigchld(backchannel, cstat)
+    int backchannel;
+    struct command_status *cstat;
 {
     int status, alive = TRUE;
     pid_t pid;
@@ -840,8 +863,12 @@ handle_sigchld(int backchannel, struct command_status *cstat)
  * Returns an error if fork(2) fails, else calls _exit(2).
  */
 int
-exec_monitor(const char *path, char *argv[], char *envp[],
-    int backchannel, int rbac)
+exec_monitor(path, argv, envp, backchannel, rbac)
+    const char *path;
+    char *argv[];
+    char *envp[];
+    int backchannel;
+    int rbac;
 {
     struct command_status cstat;
     struct timeval tv;
@@ -1042,7 +1069,8 @@ bad:
  * Does not read from /dev/tty.
  */
 static void
-flush_output(struct io_buffer *iobufs)
+flush_output(iobufs)
+    struct io_buffer *iobufs;
 {
     struct io_buffer *iob;
     struct timeval tv;
@@ -1115,8 +1143,11 @@ flush_output(struct io_buffer *iobufs)
  * Returns only if execve() fails.
  */
 static void
-exec_pty(const char *path, char *argv[], char *envp[],
-    int rbac_enabled)
+exec_pty(path, argv, envp, rbac_enabled)
+    const char *path;
+    char *argv[];
+    char *envp[];
+    int rbac_enabled;
 {
     sigaction_t sa;
     pid_t self = getpid();
@@ -1174,7 +1205,9 @@ exec_pty(const char *path, char *argv[], char *envp[],
  * Propagates tty size change signals to pty being used by the command.
  */
 static void
-sync_ttysize(int src, int dst)
+sync_ttysize(src, dst)
+    int src;
+    int dst;
 {
 #ifdef TIOCGSIZE
     struct ttysize tsize;
@@ -1195,7 +1228,8 @@ sync_ttysize(int src, int dst)
  * The recvsig[] array is checked in the main event loop.
  */
 static void
-handler(int s)
+handler(s)
+    int s;
 {
     recvsig[s] = TRUE;
 }
@@ -1204,7 +1238,8 @@ handler(int s)
  * Handler for SIGWINCH in parent.
  */
 static void
-sigwinch(int s)
+sigwinch(s)
+    int s;
 {
     int serrno = errno;
 
@@ -1217,7 +1252,8 @@ sigwinch(int s)
  * Return value is the same as send(2).
  */
 static int
-safe_close(int fd)
+safe_close(fd)
+    int fd;
 {
     /* Avoid closing /dev/tty or std{in,out,err}. */
     if (fd < 3 || fd == io_fds[SFD_USERTTY]) {
diff --git a/iolog.c b/iolog.c
index 4ac05b00556d9a4b8beafa84771f879199baa80d..5ef3a3eefbfc65ab5ff2b0e7c110373df1fd327b 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -80,7 +80,7 @@ static struct timeval last_time;
 static union io_fd io_fds[IOFD_MAX];
 
 void
-io_nextid(void)
+io_nextid()
 {
     struct stat sb;
     char buf[32], *ep;
@@ -147,7 +147,9 @@ io_nextid(void)
 }
 
 static int
-build_idpath(char *pathbuf, size_t pathsize)
+build_idpath(pathbuf, pathsize)
+    char *pathbuf;
+    size_t pathsize;
 {
     struct stat sb;
     int i, len;
@@ -184,7 +186,11 @@ build_idpath(char *pathbuf, size_t pathsize)
 }
 
 static void *
-open_io_fd(char *pathbuf, int len, const char *suffix, int docompress)
+open_io_fd(pathbuf, len, suffix, docompress)
+    char *pathbuf;
+    int len;
+    const char *suffix;
+    int docompress;
 {
     void *vfd = NULL;
     int fd;
@@ -295,7 +301,10 @@ io_log_close()
 }
 
 static int
-log_io(const char *buf, unsigned int len, int idx)
+log_io(buf, len, idx)
+    const char *buf;
+    unsigned int len;
+    int idx;
 {
     struct timeval now, tv;
     sigset_t omask;
@@ -328,31 +337,41 @@ log_io(const char *buf, unsigned int len, int idx)
 }
 
 int
-log_ttyin(const char *buf, unsigned int len)
+log_ttyin(buf, len)
+    const char *buf;
+    unsigned int len;
 {
     return log_io(buf, len, IOFD_TTYIN);
 }
 
 int
-log_ttyout(const char *buf, unsigned int len)
+log_ttyout(buf, len)
+    const char *buf;
+    unsigned int len;
 {
     return log_io(buf, len, IOFD_TTYOUT);
 }
 
 int
-log_stdin(const char *buf, unsigned int len)
+log_stdin(buf, len)
+    const char *buf;
+    unsigned int len;
 {
     return log_io(buf, len, IOFD_STDIN);
 }
 
 int
-log_stdout(const char *buf, unsigned int len)
+log_stdout(buf, len)
+    const char *buf;
+    unsigned int len;
 {
     return log_io(buf, len, IOFD_STDOUT);
 }
 
 int
-log_stderr(const char *buf, unsigned int len)
+log_stderr(buf, len)
+    const char *buf;
+    unsigned int len;
 {
     return log_io(buf, len, IOFD_STDERR);
 }
index 5e38ede2e3ce8681bdf65f8bd6215f4194feb968..bb44e8a7784edc64c708dbec3ac2b6be030c20fc 100644 (file)
--- a/missing.h
+++ b/missing.h
 #ifndef _SUDO_MISSING_H
 #define _SUDO_MISSING_H
 
+#ifdef __STDC__
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#endif
+
 /* Functions "missing" from libc. */
 
 struct timeval;
index 71efb2666b50953dffd58374ec7323bd28551de2..3413344c7cfdd1c65b2f8f5c76b9e91a7b2693b6 100644 (file)
@@ -299,7 +299,10 @@ cleanup:
 }
 
 static char *
-resolve_editor(char *editor, int *argc_out, char ***argv_out)
+resolve_editor(editor, argc_out, argv_out)
+    char *editor;
+    int *argc_out;
+    char ***argv_out;
 {
     char *cp, **nargv, *editor_path = NULL;
     int ac, nargc, wasblank;
@@ -347,7 +350,9 @@ resolve_editor(char *editor, int *argc_out, char ***argv_out)
  * includes the editor with the specified files.
  */
 static char *
-find_editor(int *argc_out, char ***argv_out)
+find_editor(argc_out, argv_out)
+    int *argc_out;
+    char ***argv_out;
 {
     char *cp, *editor, *editor_path = NULL, **ev, *ev0[4];
 
@@ -389,7 +394,10 @@ find_editor(int *argc_out, char ***argv_out)
  * Must have the ability to change the effective uid to use sudoedit.
  */
 int
-sudo_edit(int argc, char *argv[], char *envp[])
+sudo_edit(argc, argv, envp)
+    int argc;
+    char *argv[];
+    char *envp[];
 {
     return 1;
 }