Received: (at submit) by bugs.debian.org; 17 Nov 2000 21:42:47 +0000 From gohmandj@mrs.umn.edu Fri Nov 17 15:42:47 2000 Return-path: Received: from rn082040.mrs.umn.edu [146.57.82.40] by master.debian.org with esmtp (Exim 3.12 1 (Debian)) id 13wtHT-0007Lg-00; Fri, 17 Nov 2000 15:42:47 -0600 Received: from normal by rn082040.mrs.umn.edu with local (Exim 3.16 #1 (Debian)) id 13wtHO-0002u6-00; Fri, 17 Nov 2000 15:42:42 -0600 From: Normal User Subject: cron: misc source cleanups To: submit@bugs.debian.org X-Mailer: bug 3.3.7 Message-Id: Date: Fri, 17 Nov 2000 15:42:42 -0600 Delivered-To: submit@bugs.debian.org Package: cron Version: 3.0pl1-60 Severity: wishlist I'm doing a bit of hacking on cron to meet some local specifications and the first part of this consisted in cleaning up the code a bit. I'm submitting just the cleanup parts here in case you or anyone else wants them. This patch removes all uses of the `register' and `auto' keywords, adds a bunch of `const's, and converts function prototypes to ANSI-style (similar to what the protoize command does). diff -ur cron-3.0pl1.orig/bitstring.h cron-3.0pl1/bitstring.h --- cron-3.0pl1.orig/bitstring.h Thu Sep 1 15:16:51 1994 +++ cron-3.0pl1/bitstring.h Thu Nov 16 18:21:09 2000 @@ -59,10 +59,10 @@ /* clear bits start ... stop in bitstring */ #define bit_nclear(name, start, stop) { \ - register bitstr_t *_name = name; \ - register int _start = start, _stop = stop; \ - register int _startbyte = _bit_byte(_start); \ - register int _stopbyte = _bit_byte(_stop); \ + bitstr_t *_name = name; \ + int _start = start, _stop = stop; \ + int _startbyte = _bit_byte(_start); \ + int _stopbyte = _bit_byte(_stop); \ if (_startbyte == _stopbyte) { \ _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \ (0xff << ((_stop&0x7) + 1))); \ @@ -76,10 +76,10 @@ /* set bits start ... stop in bitstring */ #define bit_nset(name, start, stop) { \ - register bitstr_t *_name = name; \ - register int _start = start, _stop = stop; \ - register int _startbyte = _bit_byte(_start); \ - register int _stopbyte = _bit_byte(_stop); \ + bitstr_t *_name = name; \ + int _start = start, _stop = stop; \ + int _startbyte = _bit_byte(_start); \ + int _stopbyte = _bit_byte(_stop); \ if (_startbyte == _stopbyte) { \ _name[_startbyte] |= ((0xff << (_start&0x7)) & \ (0xff >> (7 - (_stop&0x7)))); \ @@ -93,9 +93,9 @@ /* find first bit clear in name */ #define bit_ffc(name, nbits, value) { \ - register bitstr_t *_name = name; \ - register int _byte, _nbits = nbits; \ - register int _stopbyte = _bit_byte(_nbits), _value = -1; \ + bitstr_t *_name = name; \ + int _byte, _nbits = nbits; \ + int _stopbyte = _bit_byte(_nbits), _value = -1; \ for (_byte = 0; _byte <= _stopbyte; ++_byte) \ if (_name[_byte] != 0xff) { \ _value = _byte << 3; \ @@ -108,9 +108,9 @@ /* find first bit set in name */ #define bit_ffs(name, nbits, value) { \ - register bitstr_t *_name = name; \ - register int _byte, _nbits = nbits; \ - register int _stopbyte = _bit_byte(_nbits), _value = -1; \ + bitstr_t *_name = name; \ + int _byte, _nbits = nbits; \ + int _stopbyte = _bit_byte(_nbits), _value = -1; \ for (_byte = 0; _byte <= _stopbyte; ++_byte) \ if (_name[_byte]) { \ _value = _byte << 3; \ diff -ur cron-3.0pl1.orig/cron.c cron-3.0pl1/cron.c --- cron-3.0pl1.orig/cron.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/cron.c Thu Nov 16 18:37:20 2000 @@ -45,7 +45,7 @@ static void -usage() { +usage(void) { #if DEBUGGING char **dflags; @@ -61,9 +61,7 @@ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { cron_db database; @@ -246,11 +244,10 @@ static void -run_reboot_jobs(db) - cron_db *db; +run_reboot_jobs(cron_db *db) { - register user *u; - register entry *e; + user *u; + entry *e; for (u = db->head; u != NULL; u = u->next) { for (e = u->crontab; e != NULL; e = e->next) { @@ -264,17 +261,13 @@ static void -find_jobs(vtime, db, doWild, doNonWild) - time_min vtime; - cron_db *db; - int doWild; - int doNonWild; +find_jobs(time_min vtime, cron_db *db, int doWild, int doNonWild) { time_t virtualSecond = vtime * SECONDS_PER_MINUTE; - register struct tm *tm = localtime(&virtualSecond); - register int minute, hour, dom, month, dow; - register user *u; - register entry *e; + struct tm *tm = localtime(&virtualSecond); + int minute, hour, dom, month, dow; + user *u; + entry *e; /* make 0-based values out of these so we can use them as indicies */ @@ -320,7 +313,7 @@ * note that clockTime is a unix wallclock time converted to minutes */ static void -set_time() +set_time(void) { StartTime = time((time_t *)0); clockTime = StartTime / (unsigned long)SECONDS_PER_MINUTE; @@ -330,10 +323,9 @@ * try to just hit the next minute */ static void -cron_sleep(target) - time_min target; +cron_sleep(time_min target) { - register int seconds_to_wait; + int seconds_to_wait; seconds_to_wait = (int)(target*SECONDS_PER_MINUTE - time((time_t*)0)) + 1; Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n", @@ -380,7 +372,7 @@ static void -sighup_handler(x) { +sighup_handler(int x) { log_close(); /* we should use sigaction for proper signal blocking as this @@ -390,9 +382,7 @@ static void -parse_args(argc, argv) - int argc; - char *argv[]; +parse_args(int argc, char **argv) { int argch; diff -ur cron-3.0pl1.orig/cron.h cron-3.0pl1/cron.h --- cron-3.0pl1.orig/cron.h Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/cron.h Thu Nov 16 20:01:14 2000 @@ -85,7 +85,6 @@ #define DBIT 0x0080 /* bit twiddling shown (long) */ #define CRON_TAB(u) "%s/%s", SPOOL_DIR, u -#define REG register #define PPC_NULL ((char **)NULL) #ifndef MAXHOSTNAMELEN @@ -188,46 +187,46 @@ } cron_db; -void set_cron_uid __P((void)), - set_cron_cwd __P((void)), - load_database __P((cron_db *)), - open_logfile __P((void)), - sigpipe_func __P((void)), - job_add __P((entry *, user *)), - do_command __P((entry *, user *)), - link_user __P((cron_db *, user *)), - unlink_user __P((cron_db *, user *)), - free_user __P((user *)), - env_free __P((char **)), - unget_char __P((int, FILE *)), - free_entry __P((entry *)), - acquire_daemonlock __P((int)), - skip_comments __P((FILE *)), - log_it __P((char *, int, char *, char *)), - log_close __P((void)); - -int job_runqueue __P((void)), - set_debug_flags __P((char *)), - get_char __P((FILE *)), - get_string __P((char *, int, FILE *, char *)), - swap_uids __P((void)), - swap_uids_back __P((void)), - load_env __P((char *, FILE *)), - cron_pclose __P((FILE *)), - strcmp_until __P((char *, char *, int)), - allowed __P((char *)), - strdtb __P((char *)); - -char *env_get __P((char *, char **)), - *arpadate __P((time_t *)), - *mkprints __P((unsigned char *, unsigned int)), - *first_word __P((char *, char *)), - **env_init __P((void)), - **env_copy __P((char **)), - **env_set __P((char **, char *)); +void set_cron_uid __P((void)); +void set_cron_cwd __P((void)); +void load_database __P((cron_db *)); +void open_logfile __P((void)); +void sigpipe_func __P((void)); +void job_add __P((entry *, user *)); +void do_command __P((entry *, user *)); +void link_user __P((cron_db *, user *)); +void unlink_user __P((cron_db *, user *)); +void free_user __P((user *)); +void env_free __P((char **)); +void unget_char __P((int, FILE *)); +void free_entry __P((entry *)); +void acquire_daemonlock __P((int)); +void skip_comments __P((FILE *)); +void log_it __P((const char *, int, const char *, const char *)); +void log_close __P((void)); + +int job_runqueue __P((void)); +int set_debug_flags __P((char *)); +int get_char __P((FILE *)); +int get_string __P((char *, int, FILE *, const char *)); +int swap_uids __P((void)); +int swap_uids_back __P((void)); +int load_env __P((char *, FILE *)); +int cron_pclose __P((FILE *)); +int strcmp_until __P((const char *, const char *, int)); +int allowed __P((const char *)); +int strdtb __P((char *)); + +char *env_get __P((const char *, char **)); +char *arpadate __P((time_t *)); +char *mkprints __P((const unsigned char *, unsigned int)); +char *first_word __P((const char *, const char *)); +char **env_init __P((void)); +char **env_copy __P((char **)); +char **env_set __P((char **, char *)); -user *load_user __P((int, struct passwd *, char *)), - *find_user __P((cron_db *, char *)); +user *load_user __P((int, struct passwd *, const char *)); +user *find_user __P((cron_db *, const char *)); entry *load_entry __P((FILE *, void (*)(), struct passwd *, char **)); @@ -242,19 +241,19 @@ #ifdef MAIN_PROGRAM # if !defined(LINT) && !defined(lint) -char *copyright[] = { +const char *copyright[] = { "@(#) Copyright 1988,1989,1990,1993,1994 by Paul Vixie", "@(#) All rights reserved" }; # endif -char *MonthNames[] = { +const char *MonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL }; -char *DowNames[] = { +const char *DowNames[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", NULL }; @@ -268,16 +267,16 @@ # if DEBUGGING int DebugFlags; -char *DebugFlagNames[] = { /* sync with #defines */ +const char *DebugFlagNames[] = { /* sync with #defines */ "ext", "sch", "proc", "pars", "load", "misc", "test", "bit", NULL /* NULL must be last element */ }; # endif /* DEBUGGING */ #else /*MAIN_PROGRAM*/ -extern char *copyright[], - *MonthNames[], - *DowNames[], - *ProgramName; +extern char *copyright[]; +extern char *MonthNames[]; +extern char *DowNames[]; +extern char *ProgramName; extern int LineNumber; extern time_t StartTime; extern time_min timeRunning; diff -ur cron-3.0pl1.orig/crontab.c cron-3.0pl1/crontab.c --- cron-3.0pl1.orig/crontab.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/crontab.c Thu Nov 16 19:28:49 2000 @@ -51,7 +51,7 @@ enum opt_t { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace }; #if DEBUGGING -static char *Options[] = { "???", "list", "delete", "edit", "replace" }; +static const char *Options[] = { "???", "list", "delete", "edit", "replace" }; #endif @@ -66,14 +66,13 @@ delete_cmd __P((void)), edit_cmd __P((void)), poke_daemon __P((void)), - check_error __P((char *)), + check_error __P((const char *)), parse_args __P((int c, char *v[])); static int replace_cmd __P((void)); static void -usage(msg) - char *msg; +usage(const char *msg) { fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg); fprintf(stderr, "usage:\t%s [-u user] file\n", ProgramName); @@ -87,9 +86,7 @@ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { int exitstatus; @@ -137,16 +134,14 @@ } #if DEBUGGING -char *getoptarg = "u:lerx:"; +const char *getoptarg = "u:lerx:"; #else -char *getoptarg = "u:ler"; +const char *getoptarg = "u:ler"; #endif static void -parse_args(argc, argv) - int argc; - char *argv[]; +parse_args(int argc, char **argv) { int argch; @@ -262,7 +257,7 @@ static void -list_cmd() { +list_cmd(void) { char n[MAX_FNAME]; FILE *f; int ch; @@ -315,7 +310,7 @@ static void -delete_cmd() { +delete_cmd(void) { char n[MAX_FNAME]; log_it(RealUser, Pid, "DELETE", User); @@ -332,8 +327,7 @@ static void -check_error(msg) - char *msg; +check_error(const char *msg) { CheckErrorCount++; fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg); @@ -341,8 +335,9 @@ static void -edit_cmd() { - char n[MAX_FNAME], q[MAX_TEMPSTR], *editor; +edit_cmd(void) { + char n[MAX_FNAME], q[MAX_TEMPSTR]; + const char *editor; FILE *f; int ch, t, x; struct stat statbuf; @@ -569,7 +564,7 @@ * -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; @@ -688,7 +683,7 @@ static void -poke_daemon() { +poke_daemon(void) { #ifdef USE_UTIMES struct timeval tvs[2]; struct timezone tz; diff -ur cron-3.0pl1.orig/database.c cron-3.0pl1/database.c --- cron-3.0pl1.orig/database.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/database.c Thu Nov 16 19:46:19 2000 @@ -44,16 +44,16 @@ #endif /* ifndef PATH_MAX */ -static void process_crontab __P((char *, char *, char *, +static void process_crontab __P((const char *, const char *, + const char *, struct stat *, cron_db *, cron_db *)); #ifdef DEBIAN -static int valid_name (char *filename); +static int valid_name (const char *filename); static user *get_next_system_crontab __P((user *)); #endif void -load_database(old_db) - cron_db *old_db; +load_database(cron_db *old_db) { DIR *dir; struct stat statbuf; @@ -257,9 +257,7 @@ void -link_user(db, u) - cron_db *db; - user *u; +link_user(cron_db *db, user *u) { if (db->head == NULL) db->head = u; @@ -272,9 +270,7 @@ 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; @@ -289,11 +285,9 @@ user * -find_user(db, name) - cron_db *db; - char *name; +find_user(cron_db *db, const char *name) { - char *env_get(); + char *env_get(const char *name, char **envp); user *u; for (u = db->head; u != NULL; u = u->next) @@ -304,13 +298,7 @@ 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(const char *uname, const char *fname, const char *tabname, struct stat *statbuf, cron_db *new_db, cron_db *old_db) { struct passwd *pw = NULL; int crontab_fd = OK - 1; @@ -405,7 +393,7 @@ #else #include /* Same function, better compliance with ISO C */ -static int valid_name (char *filename) +static int valid_name (const char *filename) { while (*filename) { if (!(isalnum(*filename) || @@ -420,8 +408,7 @@ #endif static user * -get_next_system_crontab (curtab) - user *curtab; +get_next_system_crontab (user *curtab) { for ( ; curtab != NULL; curtab = curtab->next) if (!strncmp(curtab->name, "*system*", 8) && curtab->name [8]) diff -ur cron-3.0pl1.orig/debian/rules cron-3.0pl1/debian/rules --- cron-3.0pl1.orig/debian/rules Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/debian/rules Thu Nov 16 18:41:36 2000 @@ -6,7 +6,7 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -DEB_OPTIM= -O2 -Wall +DEB_OPTIM= -O2 -Wall -pedantic DEB_INSTALL = install DEB_DEBUG_DEFS = -DDEBUGGING=0 diff -ur cron-3.0pl1.orig/do_command.c cron-3.0pl1/do_command.c --- cron-3.0pl1.orig/do_command.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/do_command.c Thu Nov 16 19:21:56 2000 @@ -48,9 +48,7 @@ void -do_command(e, u) - entry *e; - user *u; +do_command(entry *e, user *u) { Debug(DPROC, ("[%d] do_command(%s, (%s,%d,%d))\n", getpid(), e->cmd, u->name, e->uid, e->gid)) @@ -82,12 +80,10 @@ 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; + char *input_data; char *usernm, *mailto; int children = 0; @@ -101,7 +97,7 @@ * our program name. This has no effect on some kernels. */ /*local*/{ - register char *pch; + char *pch; for (pch = ProgramName; *pch; pch++) *pch = MkUpper(*pch); @@ -162,9 +158,9 @@ * If there are escaped %'s, remove the escape character. */ /*local*/{ - register int escaped = FALSE; - register int ch; - register char *p; + int escaped = FALSE; + int ch; + char *p; for (input_data = p = e->cmd; (ch = *input_data); input_data++, p++) { @@ -337,10 +333,10 @@ */ if (*input_data && fork() == 0) { - register FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w"); - register int need_newline = FALSE; - register int escaped = FALSE; - register int ch; + FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w"); + int need_newline = FALSE; + int escaped = FALSE; + int ch; Debug(DPROC, ("[%d] child2 sending data to grandchild\n", getpid())) @@ -399,12 +395,12 @@ Debug(DPROC, ("[%d] child reading output from grandchild\n", getpid())) /*local*/{ - register FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); - register int ch = getc(in); + FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); + int ch = getc(in); if (ch != EOF) { - register FILE *mail; - register int bytes = 1; + FILE *mail; + int bytes = 1; int status = 0; Debug(DPROC|DEXT, @@ -434,9 +430,9 @@ */ if (mailto) { - register char **env; - auto char mailcmd[MAX_COMMAND]; - auto char hostname[MAXHOSTNAMELEN]; + char **env; + char mailcmd[MAX_COMMAND]; + char hostname[MAXHOSTNAMELEN]; (void) gethostname(hostname, MAXHOSTNAMELEN); (void) snprintf(mailcmd, sizeof(mailcmd), @@ -542,8 +538,7 @@ static void -do_univ(u) - user *u; +do_univ(user *u) { #if defined(sequent) /* Dynix (Sequent) hack to put the user associated with diff -ur cron-3.0pl1.orig/entry.c cron-3.0pl1/entry.c --- cron-3.0pl1.orig/entry.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/entry.c Fri Nov 17 15:24:57 2000 @@ -39,7 +39,7 @@ get_number __P((int *, int, char *[], int, FILE *)); static int set_element __P((bitstr_t *, int, int, int)); -static char *ecodes[] = +static const char *ecodes[] = { "no error", "bad minute", @@ -54,8 +54,7 @@ void -free_entry(e) - entry *e; +free_entry(entry *e) { free(e->cmd); env_free(e->envp); @@ -67,11 +66,7 @@ * otherwise return a pointer to a new entry. */ entry * -load_entry(file, error_func, pw, envp) - FILE *file; - void (*error_func)(); - struct passwd *pw; - char **envp; +load_entry(FILE *file, void (*error_func) (/* ??? */), 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 @@ -348,15 +343,15 @@ } +/* bits: one bit per flag, default=FALSE */ +/* low, high: bounds, impl. offset for bitstr */ +/* names: NULL or *[] of names for these elements */ +/* ch: current character being processed */ +/* file: file being read */ 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; + int done; /* we know that we point to a non-blank character here; * must do a Skip_Blanks before we exit, so that the @@ -395,19 +390,19 @@ } +/* bits: one bit per flag, default=FALSE */ +/* low, high: bounds, impl. offset for bitstr */ +/* names: NULL or names of elements */ +/* ch: current character being processed */ +/* file: file being read */ 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 ] */ - register int i; - auto int num1, num2, num3; + int i; + int num1, num2, num3; Debug(DPARS|DEXT, ("get_range()...entering, exit won't show\n")) @@ -480,13 +475,13 @@ } +/* numptr: where does the result go? */ +/* low: offset applied to result if symbolic enum used */ +/* names: symbolic names, if any, for enums */ +/* ch: current character */ +/* FILE: source */ 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; @@ -535,12 +530,9 @@ } +/* bits: one bit per flag, default=FALSE */ 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 -ur cron-3.0pl1.orig/env.c cron-3.0pl1/env.c --- cron-3.0pl1.orig/env.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/env.c Thu Nov 16 19:33:20 2000 @@ -24,9 +24,9 @@ char ** -env_init() +env_init(void) { - register char **p = (char **) malloc(sizeof(char **)); + char **p = (char **) malloc(sizeof(char **)); if (p) p[0] = NULL; @@ -35,8 +35,7 @@ void -env_free(envp) - char **envp; +env_free(char **envp) { char **p; @@ -47,11 +46,10 @@ char ** -env_copy(envp) - register char **envp; +env_copy(char **envp) { - register int count, i; - register char **p; + int count, i; + char **p; for (count = 0; envp[count] != NULL; count++) ; @@ -74,12 +72,10 @@ char ** -env_set(envp, envstr) - char **envp; - char *envstr; +env_set(char **envp, char *envstr) { - register int count, found; - register char **p; + int count, found; + char **p; /* * count the number of elements, including the null pointer; @@ -131,9 +127,7 @@ * TRUE = was an env setting */ int -load_env(envstr, f) - char *envstr; - FILE *f; +load_env(char *envstr, FILE *f) { long filepos; int fileline; @@ -187,12 +181,10 @@ char * -env_get(name, envp) - register char *name; - register char **envp; +env_get(const char *name, char **envp) { - register int len = strlen(name); - register char *p, *q; + int len = strlen(name); + char *p, *q; while ((p = *envp++)) { if (!(q = strchr(p, '='))) diff -ur cron-3.0pl1.orig/job.c cron-3.0pl1/job.c --- cron-3.0pl1.orig/job.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/job.c Thu Nov 16 18:37:20 2000 @@ -34,11 +34,9 @@ void -job_add(e, u) - register entry *e; - register user *u; +job_add(entry *e, user *u) { - register job *j; + job *j; /* if already on queue, keep going */ for (j=jhead; j; j=j->next) @@ -59,10 +57,10 @@ int -job_runqueue() +job_runqueue(void) { - register job *j, *jn; - register int run = 0; + job *j, *jn; + int run = 0; for (j=jhead; j; j=jn) { do_command(j->e, j->u); diff -ur cron-3.0pl1.orig/misc.c cron-3.0pl1/misc.c --- cron-3.0pl1.orig/misc.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/misc.c Thu Nov 16 19:54:43 2000 @@ -49,12 +49,9 @@ int -strcmp_until(left, right, until) - char *left; - char *right; - int until; +strcmp_until(const char *left, const char *right, int until) { - register int diff; + int diff; while (*left && *left != until && *left == *right) { left++; @@ -75,8 +72,7 @@ /* strdtb(s) - delete trailing blanks in string 's' and return new length */ int -strdtb(s) - char *s; +strdtb(char *s) { char *x = s; @@ -104,8 +100,7 @@ int -set_debug_flags(flags) - char *flags; +set_debug_flags(char *flags) { /* debug flags are of the form flag[,flag ...] * @@ -171,7 +166,7 @@ void -set_cron_uid() +set_cron_uid(void) { #if defined(BSD) || defined(POSIX) if (seteuid(ROOT_UID) < OK) { @@ -188,7 +183,7 @@ void -set_cron_cwd() +set_cron_cwd(void) { struct stat sb; @@ -247,8 +242,7 @@ * it would be great if fflush() disassociated the file buffer. */ void -acquire_daemonlock(closeflag) - int closeflag; +acquire_daemonlock(int closeflag) { static FILE *fp = NULL; @@ -303,8 +297,7 @@ /* get_char(file) : like getc() but increment LineNumber on newlines */ int -get_char(file) - FILE *file; +get_char(FILE *file) { int ch; @@ -318,9 +311,7 @@ /* 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') @@ -335,11 +326,7 @@ * (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, const char *terms) { int ch; @@ -360,8 +347,7 @@ /* skip_comments(file) : read past comment (if any) */ void -skip_comments(file) - FILE *file; +skip_comments(FILE *file) { int ch; @@ -397,14 +383,12 @@ } -/* int in_file(char *string, FILE *file) +/* int in_file(const char *string, FILE *file) * return TRUE if one of the lines in file matches string exactly, * FALSE otherwise. */ static int -in_file(string, file) - char *string; - FILE *file; +in_file(const char *string, FILE *file) { char line[MAX_TEMPSTR]; @@ -425,8 +409,7 @@ * or (neither file exists but user=="root" so it's okay) */ int -allowed(username) - char *username; +allowed(const char *username) { static int init = FALSE; static FILE *allow, *deny; @@ -475,17 +458,13 @@ #endif /* SYSLOG */ void -log_it(username, xpid, event, detail) - char *username; - int xpid; - char *event; - char *detail; +log_it(const char *username, int xpid, const char *event, const char *detail) { #if defined(LOG_FILE) PID_T pid = xpid; char *msg; TIME_T now = time((TIME_T) 0); - register struct tm *t = localtime(&now); + struct tm *t = localtime(&now); int msg_size; #endif /*LOG_FILE*/ @@ -602,7 +581,7 @@ void -log_close() { +log_close(void) { #if defined(LOG_FILE) if (LogFD != ERR) { close(LogFD); @@ -620,14 +599,14 @@ * (1) this routine is fairly slow * (2) it returns a pointer to static storage */ +/* s: string we want the first word of */ +/* t: terminators, implicitly including \0 */ char * -first_word(s, t) - register char *s; /* string we want the first word of */ - register char *t; /* terminators, implicitly including \0 */ +first_word(const char *s, const char *t) { static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */ static int retsel = 0; - register char *rb, *rp; + char *rb, *rp; /* select a return buffer */ retsel = 1-retsel; @@ -654,14 +633,11 @@ * heavily ascii-dependent. */ void -mkprint(dst, src, len) - register char *dst; - register unsigned char *src; - register int len; +mkprint(char *dst, const unsigned char *src, int len) { while (len-- > 0) { - register unsigned char ch = *src++; + unsigned char ch = *src++; if (ch < ' ') { /* control character */ *dst++ = '^'; @@ -686,11 +662,9 @@ * 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(const unsigned char *src, unsigned int len) { - register char *dst = malloc(len*4 + 1); + char *dst = malloc(len*4 + 1); if (dst) mkprint(dst, src, len); @@ -704,8 +678,7 @@ * 1234567890123456789012345678901234567 */ char * -arpadate(clock) - time_t *clock; +arpadate(time_t *clock) { static char ret[64]; /* zone name might be >3 chars */ time_t t = clock ? *clock : time(NULL); @@ -740,6 +713,6 @@ int swap_uids() { save_euid = geteuid(); return seteuid(getuid()); } int swap_uids_back() { 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*/ diff -ur cron-3.0pl1.orig/popen.c cron-3.0pl1/popen.c --- cron-3.0pl1.orig/popen.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/popen.c Thu Nov 16 18:37:21 2000 @@ -48,11 +48,9 @@ static int fds; FILE * -cron_popen(program, type, e) - char *program, *type; - entry *e; +cron_popen(char *program, char *type, entry *e) { - register char *cp; + char *cp; FILE *iop; int argc, pdes[2]; PID_T pid; @@ -156,10 +154,9 @@ } int -cron_pclose(iop) - FILE *iop; +cron_pclose(FILE *iop) { - register int fdes; + int fdes; int omask; WAIT_T stat_loc; PID_T pid; diff -ur cron-3.0pl1.orig/user.c cron-3.0pl1/user.c --- cron-3.0pl1.orig/user.c Thu Nov 16 19:58:36 2000 +++ cron-3.0pl1/user.c Thu Nov 16 19:29:41 2000 @@ -27,8 +27,7 @@ void -free_user(u) - user *u; +free_user(user *u) { entry *e, *ne; @@ -42,10 +41,10 @@ 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, const char *name) + + /* NULL implies syscrontab */ + { char envstr[MAX_ENVSTR]; FILE *file;