From 785ecd145f0144f42d9fb9678f744427b52289b2 Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 23 Jan 2015 19:07:27 +0000 Subject: [PATCH] braces to open a function go on their own line like god intended --- usr.sbin/cron/cron.c | 35 +++++++++++++++++++++----------- usr.sbin/cron/crontab.c | 32 +++++++++++++++++++---------- usr.sbin/cron/database.c | 14 ++++++++----- usr.sbin/cron/do_command.c | 11 ++++++---- usr.sbin/cron/entry.c | 14 ++++++++----- usr.sbin/cron/env.c | 20 ++++++++++++------- usr.sbin/cron/job.c | 8 +++++--- usr.sbin/cron/misc.c | 41 +++++++++++++++++++++++++------------- usr.sbin/cron/popen.c | 8 +++++--- usr.sbin/cron/user.c | 8 +++++--- 10 files changed, 124 insertions(+), 67 deletions(-) diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index 6de05033951..71f9e204cd8 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.50 2015/01/23 01:03:03 tedu Exp $ */ +/* $OpenBSD: cron.c,v 1.51 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -47,14 +47,16 @@ static at_db at_database; static double batch_maxload = BATCH_MAXLOAD; static void -usage(void) { +usage(void) +{ fprintf(stderr, "usage: %s [-n] [-l load_avg]\n", ProgramName); exit(EXIT_FAILURE); } int -main(int argc, char *argv[]) { +main(int argc, char *argv[]) +{ struct sigaction sact; int fd; @@ -259,7 +261,8 @@ main(int argc, char *argv[]) { } static void -run_reboot_jobs(cron_db *db) { +run_reboot_jobs(cron_db *db) +{ user *u; entry *e; @@ -273,7 +276,8 @@ run_reboot_jobs(cron_db *db) { } static void -find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) { +find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) +{ time_t virtualSecond = vtime * SECONDS_PER_MINUTE; struct tm *tm = gmtime(&virtualSecond); int minute, hour, dom, month, dow; @@ -319,7 +323,8 @@ find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) { * Note that clockTime is a unix wallclock time converted to minutes. */ static void -set_time(int initialize) { +set_time(int initialize) +{ struct tm tm; static int isdst; @@ -338,7 +343,8 @@ set_time(int initialize) { * Try to just hit the next minute. */ static void -cron_sleep(time_t target) { +cron_sleep(time_t target) +{ int fd, nfds; unsigned char poke; struct timeval t1, t2, tv; @@ -412,23 +418,27 @@ cron_sleep(time_t target) { } static void -sighup_handler(int x) { +sighup_handler(int x) +{ got_sighup = 1; } static void -sigchld_handler(int x) { +sigchld_handler(int x) +{ got_sigchld = 1; } static void -quit(int x) { +quit(int x) +{ (void) unlink(_PATH_CRON_PID); _exit(0); } static void -sigchld_reaper(void) { +sigchld_reaper(void) +{ int waiter; pid_t pid; @@ -448,7 +458,8 @@ sigchld_reaper(void) { } static void -parse_args(int argc, char *argv[]) { +parse_args(int argc, char *argv[]) +{ int argch; char *ep; diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 05971bec12c..237a720ca76 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.69 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: crontab.c,v 1.70 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -56,7 +56,8 @@ static void list_cmd(void), static int replace_cmd(void); static void -usage(const char *msg) { +usage(const char *msg) +{ fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg); fprintf(stderr, "usage: %s [-u user] file\n", ProgramName); fprintf(stderr, " %s [-e | -l | -r] [-u user]\n", ProgramName); @@ -69,7 +70,8 @@ usage(const char *msg) { } int -main(int argc, char *argv[]) { +main(int argc, char *argv[]) +{ int exitstatus; Pid = getpid(); @@ -112,7 +114,8 @@ main(int argc, char *argv[]) { } static void -parse_args(int argc, char *argv[]) { +parse_args(int argc, char *argv[]) +{ int argch; if (!(pw = getpwuid(getuid()))) { @@ -213,7 +216,8 @@ parse_args(int argc, char *argv[]) { } static void -list_cmd(void) { +list_cmd(void) +{ char n[MAX_FNAME]; FILE *f; @@ -239,7 +243,8 @@ list_cmd(void) { } static void -delete_cmd(void) { +delete_cmd(void) +{ char n[MAX_FNAME]; log_it(RealUser, Pid, "DELETE", User); @@ -258,13 +263,15 @@ delete_cmd(void) { } static void -check_error(const char *msg) { +check_error(const char *msg) +{ CheckErrorCount++; fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg); } static void -edit_cmd(void) { +edit_cmd(void) +{ char n[MAX_FNAME], q[MAX_TEMPSTR]; const char *tmpdir; FILE *f; @@ -445,7 +452,8 @@ edit_cmd(void) { * -2 on install error */ static int -replace_cmd(void) { +replace_cmd(void) +{ char n[MAX_FNAME], envstr[MAX_ENVSTR]; FILE *tmp; int ch, eof, fd; @@ -635,14 +643,16 @@ editit(const char *pathname) } static void -die(int x) { +die(int x) +{ if (TempFilename[0]) (void) unlink(TempFilename); _exit(EXIT_FAILURE); } static void -copy_crontab(FILE *f, FILE *out) { +copy_crontab(FILE *f, FILE *out) +{ int ch, x; /* ignore the top few comments since we probably put them there. diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c index 840c9b9fcbf..97f3a80437b 100644 --- a/usr.sbin/cron/database.c +++ b/usr.sbin/cron/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.23 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: database.c,v 1.24 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -33,7 +33,8 @@ static void process_crontab(const char *, const char *, cron_db *, cron_db *); void -load_database(cron_db *old_db) { +load_database(cron_db *old_db) +{ struct stat statbuf, syscron_stat; cron_db new_db; struct dirent *dp; @@ -130,7 +131,8 @@ load_database(cron_db *old_db) { } void -link_user(cron_db *db, user *u) { +link_user(cron_db *db, user *u) +{ if (db->head == NULL) db->head = u; if (db->tail) @@ -141,7 +143,8 @@ link_user(cron_db *db, user *u) { } void -unlink_user(cron_db *db, user *u) { +unlink_user(cron_db *db, user *u) +{ if (u->prev == NULL) db->head = u->next; else @@ -154,7 +157,8 @@ unlink_user(cron_db *db, user *u) { } user * -find_user(cron_db *db, const char *name) { +find_user(cron_db *db, const char *name) +{ user *u; for (u = db->head; u != NULL; u = u->next) diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 351dd97939b..1193df3f5fa 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.44 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: do_command.c,v 1.45 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -26,7 +26,8 @@ static void child_process(entry *, user *); void -do_command(entry *e, user *u) { +do_command(entry *e, user *u) +{ /* fork to become asynchronous -- parent process is done immediately, * and continues to run the normal cron code, which means return to @@ -52,7 +53,8 @@ do_command(entry *e, user *u) { } static void -child_process(entry *e, user *u) { +child_process(entry *e, user *u) +{ FILE *in; int stdin_pipe[2], stdout_pipe[2]; char *input_data, *usernm; @@ -461,7 +463,8 @@ child_process(entry *e, user *u) { } int -safe_p(const char *usernm, const char *s) { +safe_p(const char *usernm, const char *s) +{ static const char safe_delim[] = "@!:%+-.,"; /* conservative! */ const char *t; int ch, first; diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 43e42d789b0..8e5eaf77920 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.38 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: entry.c,v 1.39 2015/01/23 19:07:27 tedu Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -56,7 +56,8 @@ static int get_list(bitstr_t *, int, int, const char *[], int, FILE *), set_element(bitstr_t *, int, int, int); void -free_entry(entry *e) { +free_entry(entry *e) +{ free(e->cmd); free(e->pwd); if (e->envp) @@ -69,7 +70,8 @@ free_entry(entry *e) { */ entry * load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, - char **envp) { + char **envp) +{ /* this function reads one crontab entry -- the next -- from a file. * it skips any leading blank lines, ignores comments, and returns * NULL if for any reason the entry can't be read and parsed. @@ -510,7 +512,8 @@ get_range(bitstr_t *bits, int low, int high, const char *names[], static int get_number(int *numptr, int low, const char *names[], int ch, FILE *file, - const char *terms) { + const char *terms) +{ char temp[MAX_TEMPSTR], *pc; int len, i; @@ -558,7 +561,8 @@ bad: } static int -set_element(bitstr_t *bits, int low, int high, int number) { +set_element(bitstr_t *bits, int low, int high, int number) +{ if (number < low || number > high) return (EOF); diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c index 56c9d1ec0f3..ae7a754f5c1 100644 --- a/usr.sbin/cron/env.c +++ b/usr.sbin/cron/env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: env.c,v 1.27 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: env.c,v 1.28 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -24,7 +24,8 @@ #include "cron.h" char ** -env_init(void) { +env_init(void) +{ char **p = malloc(sizeof(char **)); if (p != NULL) @@ -33,7 +34,8 @@ env_init(void) { } void -env_free(char **envp) { +env_free(char **envp) +{ char **p; for (p = envp; *p != NULL; p++) @@ -42,7 +44,8 @@ env_free(char **envp) { } char ** -env_copy(char **envp) { +env_copy(char **envp) +{ int count, i, save_errno; char **p; @@ -65,7 +68,8 @@ env_copy(char **envp) { } char ** -env_set(char **envp, char *envstr) { +env_set(char **envp, char *envstr) +{ int count, found; char **p, *envtmp; @@ -126,7 +130,8 @@ enum env_state { * TRUE = was an env setting */ int -load_env(char *envstr, FILE *f) { +load_env(char *envstr, FILE *f) +{ long filepos; int fileline; enum env_state state; @@ -227,7 +232,8 @@ load_env(char *envstr, FILE *f) { } char * -env_get(char *name, char **envp) { +env_get(char *name, char **envp) +{ int len = strlen(name); char *p, *q; diff --git a/usr.sbin/cron/job.c b/usr.sbin/cron/job.c index aa18dee8cad..98d09a228cf 100644 --- a/usr.sbin/cron/job.c +++ b/usr.sbin/cron/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.9 2015/01/22 22:38:55 tedu Exp $ */ +/* $OpenBSD: job.c,v 1.10 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -32,7 +32,8 @@ typedef struct _job { static job *jhead = NULL, *jtail = NULL; void -job_add(entry *e, user *u) { +job_add(entry *e, user *u) +{ job *j; /* if already on queue, keep going */ @@ -56,7 +57,8 @@ job_add(entry *e, user *u) { } int -job_runqueue(void) { +job_runqueue(void) +{ job *j, *jn; int run = 0; diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index cd5aae94c05..7da9eee8abb 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.53 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: misc.c,v 1.54 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -47,7 +47,8 @@ static int syslog_open = FALSE; #endif int -strcmp_until(const char *left, const char *right, char until) { +strcmp_until(const char *left, const char *right, char until) +{ while (*left && *left != until && *left == *right) { left++; right++; @@ -61,7 +62,8 @@ strcmp_until(const char *left, const char *right, char until) { } void -set_cron_uid(void) { +set_cron_uid(void) +{ if (seteuid(ROOT_UID) < 0) { perror("seteuid"); exit(EXIT_FAILURE); @@ -69,7 +71,8 @@ set_cron_uid(void) { } void -set_cron_cwd(void) { +set_cron_cwd(void) +{ struct stat sb; struct group *grp = NULL; @@ -159,7 +162,8 @@ set_cron_cwd(void) { * can rewrite our PID into _PATH_CRON_PID after the fork. */ void -acquire_daemonlock(int closeflag) { +acquire_daemonlock(int closeflag) +{ static int fd = -1; char buf[3*MAX_FNAME]; const char *pidfile; @@ -240,7 +244,8 @@ acquire_daemonlock(int closeflag) { /* get_char(file) : like getc() but increment LineNumber on newlines */ int -get_char(FILE *file) { +get_char(FILE *file) +{ int ch; ch = getc(file); @@ -252,7 +257,8 @@ get_char(FILE *file) { /* unget_char(ch, file) : like ungetc but do LineNumber processing */ void -unget_char(int ch, FILE *file) { +unget_char(int ch, FILE *file) +{ ungetc(ch, file); if (ch == '\n') Set_LineNum(LineNumber - 1) @@ -265,7 +271,8 @@ unget_char(int ch, FILE *file) { * (4) returns EOF or terminating character, whichever */ int -get_string(char *string, int size, FILE *file, char *terms) { +get_string(char *string, int size, FILE *file, char *terms) +{ int ch; while (EOF != (ch = get_char(file)) && !strchr(terms, ch)) { @@ -284,7 +291,8 @@ get_string(char *string, int size, FILE *file, char *terms) { /* skip_comments(file) : read past comment (if any) */ void -skip_comments(FILE *file) { +skip_comments(FILE *file) +{ int ch; while (EOF != (ch = get_char(file))) { @@ -351,7 +359,8 @@ in_file(const char *string, FILE *file, int error) * root is always allowed. */ int -allowed(const char *username, const char *allow_file, const char *deny_file) { +allowed(const char *username, const char *allow_file, const char *deny_file) +{ FILE *fp; int isallowed; @@ -369,7 +378,8 @@ allowed(const char *username, const char *allow_file, const char *deny_file) { } void -log_it(const char *username, pid_t xpid, const char *event, const char *detail) { +log_it(const char *username, pid_t xpid, const char *event, const char *detail) +{ #if defined(LOG_FILE) || DEBUGGING pid_t pid = xpid; #endif @@ -438,7 +448,8 @@ log_it(const char *username, pid_t xpid, const char *event, const char *detail) } void -log_close(void) { +log_close(void) +{ if (LogFD != -1) { close(LogFD); LogFD = -1; @@ -459,7 +470,8 @@ log_close(void) { * (2) it returns a pointer to static storage */ char * -first_word(char *s, char *t) { +first_word(char *s, char *t) +{ static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */ static int retsel = 0; char *rb, *rp; @@ -673,7 +685,8 @@ open_socket(void) } void -poke_daemon(const char *spool_dir, unsigned char cookie) { +poke_daemon(const char *spool_dir, unsigned char cookie) +{ int sock = -1; struct sockaddr_un s_un; diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c index 5b9da7ebce9..e3d2eb998b9 100644 --- a/usr.sbin/cron/popen.c +++ b/usr.sbin/cron/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.24 2015/01/14 17:27:51 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.25 2015/01/23 19:07:27 tedu Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -51,7 +51,8 @@ static pid_t *pids; static int fds; FILE * -cron_popen(char *program, char *type, struct passwd *pw) { +cron_popen(char *program, char *type, struct passwd *pw) +{ char *cp; FILE *iop; int argc, pdes[2]; @@ -142,7 +143,8 @@ cron_popen(char *program, char *type, struct passwd *pw) { } int -cron_pclose(FILE *iop) { +cron_pclose(FILE *iop) +{ int fdes; pid_t pid; int status; diff --git a/usr.sbin/cron/user.c b/usr.sbin/cron/user.c index 87fde990b46..2b18ddd7926 100644 --- a/usr.sbin/cron/user.c +++ b/usr.sbin/cron/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.12 2015/01/23 18:52:31 tedu Exp $ */ +/* $OpenBSD: user.c,v 1.13 2015/01/23 19:07:27 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -27,7 +27,8 @@ #include "cron.h" void -free_user(user *u) { +free_user(user *u) +{ entry *e, *ne; free(u->name); @@ -39,7 +40,8 @@ free_user(user *u) { } user * -load_user(int crontab_fd, struct passwd *pw, const char *name) { +load_user(int crontab_fd, struct passwd *pw, const char *name) +{ char envstr[MAX_ENVSTR]; FILE *file; user *u; -- 2.20.1