git: e93f27e3aeb7 - main - cron: Use C89 function definitions.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 18 Apr 2023 18:31:36 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=e93f27e3aeb7c0778012b7732bc6376e20f80427

commit e93f27e3aeb7c0778012b7732bc6376e20f80427
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-04-18 18:28:07 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-04-18 18:28:07 +0000

    cron: Use C89 function definitions.
    
    Reviewed by:    zlei
    Differential Revision:  https://reviews.freebsd.org/D39529
---
 usr.sbin/cron/cron/cron.c       | 17 +++++--------
 usr.sbin/cron/cron/database.c   | 25 +++++-------------
 usr.sbin/cron/cron/do_command.c |  8 ++----
 usr.sbin/cron/cron/job.c        |  6 ++---
 usr.sbin/cron/cron/popen.c      |  8 ++----
 usr.sbin/cron/cron/user.c       | 12 +++------
 usr.sbin/cron/crontab/crontab.c | 22 ++++++++--------
 usr.sbin/cron/lib/entry.c       | 37 ++++++---------------------
 usr.sbin/cron/lib/env.c         | 20 +++++----------
 usr.sbin/cron/lib/misc.c        | 56 ++++++++++++++---------------------------
 10 files changed, 66 insertions(+), 145 deletions(-)

diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index 460dd58dbd0d..90bae65fd1ee 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -55,7 +55,8 @@ static int	dont_daemonize = 0;
 struct pidfh *pfh;
 
 static void
-usage() {
+usage(void)
+{
 #if DEBUGGING
     char **dflags;
 #endif
@@ -98,9 +99,7 @@ open_pidfile(void)
 }
 
 int
-main(argc, argv)
-	int	argc;
-	char	*argv[];
+main(int argc, char *argv[])
 {
 	int runnum;
 	int secres1, secres2;
@@ -200,8 +199,7 @@ main(argc, argv)
 
 
 static void
-run_reboot_jobs(db)
-	cron_db *db;
+run_reboot_jobs(cron_db *db)
 {
 	register user		*u;
 	register entry		*e;
@@ -462,8 +460,7 @@ cron_sleep(cron_db *db, int secres)
  */
 
 static void
-cron_clean(db)
-	cron_db	*db;
+cron_clean(cron_db *db)
 {
 	user		*u;
 	entry		*e;
@@ -518,9 +515,7 @@ sighup_handler(int x)
 
 
 static void
-parse_args(argc, argv)
-	int	argc;
-	char	*argv[];
+parse_args(int argc, char *argv[])
 {
 	int	argch;
 	char	*endp;
diff --git a/usr.sbin/cron/cron/database.c b/usr.sbin/cron/cron/database.c
index ce1f916c2042..80b749f8d955 100644
--- a/usr.sbin/cron/cron/database.c
+++ b/usr.sbin/cron/cron/database.c
@@ -39,8 +39,7 @@ static	void		process_crontab(char *, char *, char *,
 
 
 void
-load_database(old_db)
-	cron_db		*old_db;
+load_database(cron_db *old_db)
 {
 	DIR		*dir;
 	struct stat	statbuf;
@@ -201,9 +200,7 @@ load_database(old_db)
 
 
 void
-link_user(db, u)
-	cron_db	*db;
-	user	*u;
+link_user(cron_db *db, user *u)
 {
 	if (db->head == NULL)
 		db->head = u;
@@ -216,9 +213,7 @@ link_user(db, u)
 
 
 void
-unlink_user(db, u)
-	cron_db	*db;
-	user	*u;
+unlink_user(cron_db *db, user *u)
 {
 	if (u->prev == NULL)
 		db->head = u->next;
@@ -233,11 +228,8 @@ unlink_user(db, u)
 
 
 user *
-find_user(db, name)
-	cron_db	*db;
-	char	*name;
+find_user(cron_db *db, char *name)
 {
-	char	*env_get();
 	user	*u;
 
 	for (u = db->head;  u != NULL;  u = u->next)
@@ -248,13 +240,8 @@ find_user(db, name)
 
 
 static void
-process_crontab(uname, fname, tabname, statbuf, new_db, old_db)
-	char		*uname;
-	char		*fname;
-	char		*tabname;
-	struct stat	*statbuf;
-	cron_db		*new_db;
-	cron_db		*old_db;
+process_crontab(char *uname, char *fname, char *tabname, struct stat *statbuf,
+    cron_db *new_db, cron_db *old_db)
 {
 	struct passwd	*pw = NULL;
 	int		crontab_fd = OK - 1;
diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c
index fcc5a5e3eb2a..13e147e5f3df 100644
--- a/usr.sbin/cron/cron/do_command.c
+++ b/usr.sbin/cron/cron/do_command.c
@@ -45,9 +45,7 @@ static WAIT_T		wait_on_child(PID_T, const char *);
 extern char	*environ;
 
 void
-do_command(e, u)
-	entry	*e;
-	user	*u;
+do_command(entry *e, user *u)
 {
 	pid_t pid;
 
@@ -86,9 +84,7 @@ do_command(e, u)
 
 
 static void
-child_process(e, u)
-	entry	*e;
-	user	*u;
+child_process(entry *e, user *u)
 {
 	int		stdin_pipe[2], stdout_pipe[2];
 	register char	*input_data;
diff --git a/usr.sbin/cron/cron/job.c b/usr.sbin/cron/cron/job.c
index 6d1b1af6e474..7ba7643c2c65 100644
--- a/usr.sbin/cron/cron/job.c
+++ b/usr.sbin/cron/cron/job.c
@@ -35,9 +35,7 @@ static job	*jhead = NULL, *jtail = NULL;
 
 
 void
-job_add(e, u)
-	register entry *e;
-	register user *u;
+job_add(entry *e, user *u)
 {
 	register job *j;
 
@@ -60,7 +58,7 @@ job_add(e, u)
 
 
 int
-job_runqueue()
+job_runqueue(void)
 {
 	register job	*j, *jn;
 	register int	run = 0;
diff --git a/usr.sbin/cron/cron/popen.c b/usr.sbin/cron/cron/popen.c
index 44aaa0c990f6..ee8323c49873 100644
--- a/usr.sbin/cron/cron/popen.c
+++ b/usr.sbin/cron/cron/popen.c
@@ -55,10 +55,7 @@ static PID_T *pids;
 static int fds;
 
 FILE *
-cron_popen(program, type, e, pidptr)
-	char *program, *type;
-	entry *e;
-	PID_T *pidptr;
+cron_popen(char *program, char *type, entry *e, PID_T *pidptr)
 {
 	register char *cp;
 	FILE *iop;
@@ -226,8 +223,7 @@ pfree:
 }
 
 int
-cron_pclose(iop)
-	FILE *iop;
+cron_pclose(FILE *iop)
 {
 	register int fdes;
 	int omask;
diff --git a/usr.sbin/cron/cron/user.c b/usr.sbin/cron/cron/user.c
index 16fd61723a86..ce8e08fccf20 100644
--- a/usr.sbin/cron/cron/user.c
+++ b/usr.sbin/cron/cron/user.c
@@ -29,8 +29,7 @@ static const char rcsid[] =
 static char *User_name;
 
 void
-free_user(u)
-	user	*u;
+free_user(user *u)
 {
 	entry	*e, *ne;
 
@@ -43,17 +42,14 @@ free_user(u)
 }
 
 static void
-log_error(msg)
-	char	*msg;
+log_error(char *msg)
 {
 	log_it(User_name, getpid(), "PARSE", msg);
 }
 
+/* NULL pw implies syscrontab */
 user *
-load_user(crontab_fd, pw, name)
-	int		crontab_fd;
-	struct passwd	*pw;		/* NULL implies syscrontab */
-	char		*name;
+load_user(int crontab_fd, struct passwd *pw, char *name)
 {
 	char	envstr[MAX_ENVSTR];
 	FILE	*file;
diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c
index 53c58403406a..13e8250a1b63 100644
--- a/usr.sbin/cron/crontab/crontab.c
+++ b/usr.sbin/cron/crontab/crontab.c
@@ -128,9 +128,7 @@ main(int argc, char *argv[])
 
 
 static void
-parse_args(argc, argv)
-	int	argc;
-	char	*argv[];
+parse_args(int argc, char *argv[])
 {
 	int		argch;
 	char		resolved_path[PATH_MAX];
@@ -261,7 +259,8 @@ copy_file(FILE *in, FILE *out) {
 }
 
 static void
-list_cmd() {
+list_cmd(void)
+{
 	char	n[MAX_FNAME];
 	FILE	*f;
 
@@ -282,7 +281,8 @@ list_cmd() {
 
 
 static void
-delete_cmd() {
+delete_cmd(void)
+{
 	char	n[MAX_FNAME];
 	int ch, first;
 
@@ -308,8 +308,7 @@ delete_cmd() {
 
 
 static void
-check_error(msg)
-	char	*msg;
+check_error(char *msg)
 {
 	CheckErrorCount++;
 	fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg);
@@ -317,7 +316,8 @@ check_error(msg)
 
 
 static void
-edit_cmd() {
+edit_cmd(void)
+{
 	char		n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
 	FILE		*f;
 	int		t;
@@ -502,7 +502,8 @@ edit_cmd() {
  *		-2	on install error
  */
 static int
-replace_cmd() {
+replace_cmd(void)
+{
 	char	n[MAX_FNAME], envstr[MAX_ENVSTR], tn[MAX_FNAME];
 	FILE	*tmp;
 	int	ch, eof;
@@ -629,7 +630,8 @@ replace_cmd() {
 
 
 static void
-poke_daemon() {
+poke_daemon(void)
+{
 #ifdef USE_UTIMES
 	struct timeval tvs[2];
 
diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c
index 2693c9c8d07a..6d8cff847604 100644
--- a/usr.sbin/cron/lib/entry.c
+++ b/usr.sbin/cron/lib/entry.c
@@ -68,8 +68,7 @@ static char *ecodes[] =
 
 
 void
-free_entry(e)
-	entry	*e;
+free_entry(entry *e)
 {
 #ifdef LOGIN_CAP
 	if (e->class != NULL)
@@ -87,11 +86,8 @@ free_entry(e)
  * otherwise return a pointer to a new entry.
  */
 entry *
-load_entry(file, error_func, pw, envp)
-	FILE		*file;
-	void		(*error_func)(char *);
-	struct passwd	*pw;
-	char		**envp;
+load_entry(FILE *file, void (*error_func)(char *), struct passwd *pw,
+    char **envp)
 {
 	/* this function reads one crontab entry -- the next -- from a file.
 	 * it skips any leading blank lines, ignores comments, and returns
@@ -517,12 +513,7 @@ load_entry(file, error_func, pw, envp)
 
 
 static char
-get_list(bits, low, high, names, ch, file)
-	bitstr_t	*bits;		/* one bit per flag, default=FALSE */
-	int		low, high;	/* bounds, impl. offset for bitstr */
-	char		*names[];	/* NULL or *[] of names for these elements */
-	int		ch;		/* current character being processed */
-	FILE		*file;		/* file being read */
+get_list(bitstr_t *bits, int low, int high, char *names[], int ch, FILE *file)
 {
 	register int	done;
 
@@ -564,12 +555,7 @@ get_list(bits, low, high, names, ch, file)
 
 
 static char
-get_range(bits, low, high, names, ch, file)
-	bitstr_t	*bits;		/* one bit per flag, default=FALSE */
-	int		low, high;	/* bounds, impl. offset for bitstr */
-	char		*names[];	/* NULL or names of elements */
-	int		ch;		/* current character being processed */
-	FILE		*file;		/* file being read */
+get_range(bitstr_t *bits, int low, int high, char *names[], int ch, FILE *file)
 {
 	/* range = number | number "-" number [ "/" number ]
 	 */
@@ -651,12 +637,7 @@ get_range(bits, low, high, names, ch, file)
 
 
 static char
-get_number(numptr, low, names, ch, file)
-	int	*numptr;	/* where does the result go? */
-	int	low;		/* offset applied to result if symbolic enum used */
-	char	*names[];	/* symbolic names, if any, for enums */
-	int	ch;		/* current character */
-	FILE	*file;		/* source */
+get_number(int *numptr, int low, char *names[], int ch, FILE *file)
 {
 	char	temp[MAX_TEMPSTR], *pc;
 	int	len, i, all_digits;
@@ -708,11 +689,7 @@ get_number(numptr, low, names, ch, file)
 
 
 static int
-set_element(bits, low, high, number)
-	bitstr_t	*bits; 		/* one bit per flag, default=FALSE */
-	int		low;
-	int		high;
-	int		number;
+set_element(bitstr_t *bits, int low, int high, int number)
 {
 	Debug(DPARS|DEXT, ("set_element(?,%d,%d,%d)\n", low, high, number))
 
diff --git a/usr.sbin/cron/lib/env.c b/usr.sbin/cron/lib/env.c
index fd358176b124..77fbdf0c2627 100644
--- a/usr.sbin/cron/lib/env.c
+++ b/usr.sbin/cron/lib/env.c
@@ -25,7 +25,7 @@ static const char rcsid[] =
 
 
 char **
-env_init()
+env_init(void)
 {
 	register char	**p = (char **) malloc(sizeof(char *));
 
@@ -36,8 +36,7 @@ env_init()
 
 
 void
-env_free(envp)
-	char	**envp;
+env_free(char **envp)
 {
 	char	**p;
 
@@ -49,8 +48,7 @@ env_free(envp)
 
 
 char **
-env_copy(envp)
-	register char	**envp;
+env_copy(char **envp)
 {
 	register int	count, i;
 	register char	**p;
@@ -76,9 +74,7 @@ env_copy(envp)
 
 
 char **
-env_set(envp, envstr)
-	char	**envp;
-	char	*envstr;
+env_set(char **envp, char *envstr)
 {
 	register int	count, found;
 	register char	**p;
@@ -138,9 +134,7 @@ env_set(envp, envstr)
  *		TRUE = was an env setting
  */
 int
-load_env(envstr, f)
-	char	*envstr;
-	FILE	*f;
+load_env(char *envstr, FILE *f)
 {
 	long	filepos;
 	int	fileline;
@@ -252,9 +246,7 @@ load_env(envstr, f)
 
 
 char *
-env_get(name, envp)
-	register char	*name;
-	register char	**envp;
+env_get(char *name, char **envp)
 {
 	register int	len = strlen(name);
 	register char	*p, *q;
diff --git a/usr.sbin/cron/lib/misc.c b/usr.sbin/cron/lib/misc.c
index 6a0b8acbd742..5746bc33ca51 100644
--- a/usr.sbin/cron/lib/misc.c
+++ b/usr.sbin/cron/lib/misc.c
@@ -51,10 +51,7 @@ static int		LogFD = ERR;
 
 
 int
-strcmp_until(left, right, until)
-	char	*left;
-	char	*right;
-	int	until;
+strcmp_until(char *left, char *right, int until)
 {
 	register int	diff;
 
@@ -77,8 +74,7 @@ strcmp_until(left, right, until)
 /* strdtb(s) - delete trailing blanks in string 's' and return new length
  */
 int
-strdtb(s)
-	char	*s;
+strdtb(char *s)
 {
 	char	*x = s;
 
@@ -106,8 +102,7 @@ strdtb(s)
 
 
 int
-set_debug_flags(flags)
-	char	*flags;
+set_debug_flags(char *flags)
 {
 	/* debug flags are of the form    flag[,flag ...]
 	 *
@@ -173,7 +168,7 @@ set_debug_flags(flags)
 
 
 void
-set_cron_uid()
+set_cron_uid(void)
 {
 #if defined(BSD) || defined(POSIX)
 	if (seteuid(ROOT_UID) < OK)
@@ -186,7 +181,7 @@ set_cron_uid()
 
 
 void
-set_cron_cwd()
+set_cron_cwd(void)
 {
 	struct stat	sb;
 
@@ -225,8 +220,7 @@ set_cron_cwd()
 /* get_char(file) : like getc() but increment LineNumber on newlines
  */
 int
-get_char(file)
-	FILE	*file;
+get_char(FILE *file)
 {
 	int	ch;
 
@@ -240,9 +234,7 @@ get_char(file)
 /* unget_char(ch, file) : like ungetc but do LineNumber processing
  */
 void
-unget_char(ch, file)
-	int	ch;
-	FILE	*file;
+unget_char(int ch, FILE *file)
 {
 	ungetc(ch, file);
 	if (ch == '\n')
@@ -257,11 +249,7 @@ unget_char(ch, file)
  *		(4) returns EOF or terminating character, whichever
  */
 int
-get_string(string, size, file, terms)
-	char	*string;
-	int	size;
-	FILE	*file;
-	char	*terms;
+get_string(char *string, int size, FILE *file, char *terms)
 {
 	int	ch;
 
@@ -282,8 +270,7 @@ get_string(string, size, file, terms)
 /* skip_comments(file) : read past comment (if any)
  */
 void
-skip_comments(file)
-	FILE	*file;
+skip_comments(FILE *file)
 {
 	int	ch;
 
@@ -346,8 +333,7 @@ in_file(char *string, FILE *file)
  *	or (neither file exists but user=="root" so it's okay)
  */
 int
-allowed(username)
-	char *username;
+allowed(char *username)
 {
 	FILE	*allow, *deny;
 	int	isallowed;
@@ -471,7 +457,8 @@ log_it(char *username, int xpid, char *event, const char *detail)
 
 
 void
-log_close() {
+log_close(void)
+{
 	if (LogFD != ERR) {
 		close(LogFD);
 		LogFD = ERR;
@@ -484,9 +471,7 @@ log_close() {
  *	(2) it returns a pointer to static storage
  */
 char *
-first_word(s, t)
-	register char *s;	/* string we want the first word of */
-	register char *t;	/* terminators, implicitly including \0 */
+first_word(char *s, char *t)
 {
 	static char retbuf[2][MAX_TEMPSTR + 1];	/* sure wish C had GC */
 	static int retsel = 0;
@@ -544,9 +529,7 @@ mkprint(register char *dst, register unsigned char *src, register int len)
  *	returns a pointer to malloc'd storage, you must call free yourself.
  */
 char *
-mkprints(src, len)
-	register unsigned char *src;
-	register unsigned int len;
+mkprints(unsigned char *src, unsigned int len)
 {
 	register char *dst = malloc(len*4 + 1);
 
@@ -562,8 +545,7 @@ mkprints(src, len)
  * 123456789012345678901234567
  */
 char *
-arpadate(clock)
-	time_t *clock;
+arpadate(time_t *clock)
 {
 	time_t t = clock ?*clock :time(0L);
 	struct tm *tm = localtime(&t);
@@ -588,9 +570,9 @@ arpadate(clock)
 
 #ifdef HAVE_SAVED_UIDS
 static int save_euid;
-int swap_uids() { save_euid = geteuid(); return seteuid(getuid()); }
-int swap_uids_back() { return seteuid(save_euid); }
+int swap_uids(void) { save_euid = geteuid(); return seteuid(getuid()); }
+int swap_uids_back(void) { return seteuid(save_euid); }
 #else /*HAVE_SAVED_UIDS*/
-int swap_uids() { return setreuid(geteuid(), getuid()); }
-int swap_uids_back() { return swap_uids(); }
+int swap_uids(void) { return setreuid(geteuid(), getuid()); }
+int swap_uids_back(void) { return swap_uids(); }
 #endif /*HAVE_SAVED_UIDS*/