diff options
author | gad <gad@FreeBSD.org> | 2001-06-12 16:38:20 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2001-06-12 16:38:20 +0000 |
commit | d61428321f0ceb41de748a616b592b50195c51fb (patch) | |
tree | 115b09aed7f19dda18dbe2e66eba92a08b0d2441 /usr.sbin/lpr/lpd | |
parent | b39990d7f9947621a844c7a4936eeb286a471c47 (diff) | |
download | FreeBSD-src-d61428321f0ceb41de748a616b592b50195c51fb.zip FreeBSD-src-d61428321f0ceb41de748a616b592b50195c51fb.tar.gz |
Fix about 90-100 warnings one gets when trying to compile lpr&friends
with BDECFLAGS on, mainly by adding 'const' to parameters in a number
of routine declarations. While I'm at it, ANSI-fy all of the routine
declarations. The resulting object code is exactly the same after
this update as before it, with the exception of one unavoidable
change to lpd.o on freebsd/alpha.
Also added $FreeBSD$ line to lpc/extern.h lpc/lpc.h lptest/lptest.c
Reviewed by: /sbin/md5, and no feedback from freebsd-audit
Diffstat (limited to 'usr.sbin/lpr/lpd')
-rw-r--r-- | usr.sbin/lpr/lpd/extern.h | 8 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/lpd.c | 45 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/modes.c | 8 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 134 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/recvjob.c | 38 |
5 files changed, 91 insertions, 142 deletions
diff --git a/usr.sbin/lpr/lpd/extern.h b/usr.sbin/lpr/lpd/extern.h index d4b4966..dc9b109 100644 --- a/usr.sbin/lpr/lpd/extern.h +++ b/usr.sbin/lpr/lpd/extern.h @@ -44,8 +44,8 @@ struct printer; struct termios; __BEGIN_DECLS -void printjob __P((struct printer *pp)); -void startprinting __P((const char *printer)); -void recvjob __P((const char *printer)); -int msearch __P((char *str, struct termios *ip)); +void printjob(struct printer *_pp); +void startprinting(const char *_printer); +void recvjob(const char *_printer); +int msearch(char *_str, struct termios *_ip); __END_DECLS diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index 729852a..0394351 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -107,15 +107,15 @@ int lflag; /* log requests flag */ int pflag; /* no incoming port flag */ int from_remote; /* from remote socket */ -int main __P((int, char **)); -static void reapchild __P((int)); -static void mcleanup __P((int)); -static void doit __P((void)); -static void startup __P((void)); -static void chkhost __P((struct sockaddr *)); -static int ckqueue __P((struct printer *)); -static void usage __P((void)); -static int *socksetup __P((int, int)); +int main(int argc, char **_argv); +static void reapchild(int _signo); +static void mcleanup(int _signo); +static void doit(void); +static void startup(void); +static void chkhost(struct sockaddr *_f); +static int ckqueue(struct printer *_pp); +static void usage(void); +static int *socksetup(int _af, int _options); /* XXX from libc/net/rcmd.c */ extern int __ivaliduser_sa __P((FILE *, struct sockaddr *, socklen_t, @@ -124,9 +124,7 @@ extern int __ivaliduser_sa __P((FILE *, struct sockaddr *, socklen_t, uid_t uid, euid; int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { int errs, f, funix, *finet, fromlen, i, options, socket_debug; fd_set defreadfds; @@ -382,8 +380,7 @@ main(argc, argv) } static void -reapchild(signo) - int signo; +reapchild(int signo __unused) { union wait status; @@ -392,8 +389,7 @@ reapchild(signo) } static void -mcleanup(signo) - int signo; +mcleanup(int signo) { /* * XXX syslog(3) is not signal-safe. @@ -419,7 +415,7 @@ char *person; /* name of person doing lprm */ char fromb[MAXHOSTNAMELEN]; /* buffer for client's machine name */ char cbuf[BUFSIZ]; /* command line buffer */ -char *cmdnames[] = { +const char *cmdnames[] = { "null", "printjob", "recvjob", @@ -429,7 +425,7 @@ char *cmdnames[] = { }; static void -doit() +doit(void) { char *cp, *printer; int n; @@ -543,7 +539,7 @@ doit() * files left from the last time the machine went down. */ static void -startup() +startup(void) { int pid, status, more; struct printer myprinter, *pp = &myprinter; @@ -584,8 +580,7 @@ errloop: * Make sure there's some work to do before forking off a child */ static int -ckqueue(pp) - struct printer *pp; +ckqueue(struct printer *pp) { register struct dirent *d; DIR *dirp; @@ -610,8 +605,7 @@ ckqueue(pp) * Check to see if the from host has access to the line printer. */ static void -chkhost(f) - struct sockaddr *f; +chkhost(struct sockaddr *f) { struct addrinfo hints, *res, *r; register FILE *hostf; @@ -706,8 +700,7 @@ again: /* if af is PF_UNSPEC more than one socket may be returned */ /* the returned list is dynamically allocated, so caller needs to free it */ static int * -socksetup(af, options) - int af, options; +socksetup(int af, int options) { struct addrinfo hints, *res, *r; int error, maxs, *s, *socks; @@ -786,7 +779,7 @@ socksetup(af, options) } static void -usage() +usage(void) { #ifdef INET6 fprintf(stderr, "usage: lpd [-dlp46] [port#]\n"); diff --git a/usr.sbin/lpr/lpd/modes.c b/usr.sbin/lpr/lpd/modes.c index 517b02e..2abac5a 100644 --- a/usr.sbin/lpr/lpd/modes.c +++ b/usr.sbin/lpr/lpd/modes.c @@ -47,8 +47,8 @@ static const char rcsid[] = struct modes { const char *name; - const long set; - const long unset; + const long set; + const long unset; }; /* @@ -202,9 +202,7 @@ struct modes omodes[] = { #define CHK(name, s) (*name == s[0] && !strcmp(name, s)) int -msearch(str, ip) - char *str; - struct termios *ip; +msearch(char *str, struct termios *ip) { struct modes *mp; diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index e4e9838..14dc49c 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -121,32 +121,31 @@ static char width[10] = "-w"; /* page width in static characters */ #define TFILENAME "fltXXXXXX" static char tfile[] = TFILENAME; /* file name for filter output */ -static void abortpr __P((int)); -static void alarmhandler __P((int)); -static void banner __P((struct printer *pp, char *name1, char *name2)); -static int dofork __P((const struct printer *pp, int action)); -static int dropit __P((int)); -static void init __P((struct printer *pp)); -static void openpr __P((const struct printer *pp)); -static void opennet __P((const struct printer *pp)); -static void opentty __P((const struct printer *pp)); -static void openrem __P((const struct printer *pp)); -static int print __P((struct printer *pp, int format, char *file)); -static int printit __P((struct printer *pp, char *file)); -static void pstatus __P((const struct printer *, const char *, ...)); -static char response __P((const struct printer *pp)); -static void scan_out __P((struct printer *pp, int scfd, char *scsp, - int dlm)); -static char *scnline __P((int, char *, int)); -static int sendfile __P((struct printer *pp, int type, char *file, - int format)); -static int sendit __P((struct printer *pp, char *file)); -static void sendmail __P((struct printer *pp, char *user, int bombed)); -static void setty __P((const struct printer *pp)); +static void abortpr(int _signo); +static void alarmhandler(int _signo); +static void banner(struct printer *_pp, char *_name1, char *_name2); +static int dofork(const struct printer *_pp, int _action); +static int dropit(int _c); +static void init(struct printer *_pp); +static void openpr(const struct printer *_pp); +static void opennet(const struct printer *_pp); +static void opentty(const struct printer *_pp); +static void openrem(const struct printer *pp); +static int print(struct printer *_pp, int _format, char *_file); +static int printit(struct printer *_pp, char *_file); +static void pstatus(const struct printer *_pp, const char *_msg, ...); +static char response(const struct printer *_pp); +static void scan_out(struct printer *_pp, int _scfd, char *_scsp, + int _dlm); +static char *scnline(int _key, char *_p, int _c); +static int sendfile(struct printer *_pp, int _type, char *_file, + char _format); +static int sendit(struct printer *_pp, char *_file); +static void sendmail(struct printer *_pp, char *_user, int _bombed); +static void setty(const struct printer *_pp); void -printjob(pp) - struct printer *pp; +printjob(struct printer *pp) { struct stat stb; register struct jobqueue *q, **qp; @@ -349,9 +348,7 @@ char ifonts[4][40] = { * and performing the various actions. */ static int -printit(pp, file) - struct printer *pp; - char *file; +printit(struct printer *pp, char *file) { register int i; char *cp; @@ -584,10 +581,7 @@ pass2: * stderr as the log file, and must not ignore SIGINT. */ static int -print(pp, format, file) - struct printer *pp; - int format; - char *file; +print(struct printer *pp, int format, char *file) { register int n, i; register char *prog; @@ -837,9 +831,7 @@ start: * 0 if all is well. */ static int -sendit(pp, file) - struct printer *pp; - char *file; +sendit(struct printer *pp, char *file) { register int i, err = OK; char *cp, last[BUFSIZ]; @@ -946,11 +938,7 @@ sendit(pp, file) * Return positive if we should try resending. */ static int -sendfile(pp, type, file, format) - struct printer *pp; - int type; - char *file; - char format; +sendfile(struct printer *pp, int type, char *file, char format) { register int f, i, amt; struct stat stb; @@ -1188,8 +1176,7 @@ sendfile(pp, type, file, format) * Return non-zero if the connection was lost. */ static char -response(pp) - const struct printer *pp; +response(const struct printer *pp) { char resp; @@ -1204,9 +1191,7 @@ response(pp) * Banner printing stuff */ static void -banner(pp, name1, name2) - struct printer *pp; - char *name1, *name2; +banner(struct printer *pp, char *name1, char *name2) { time_t tvec; @@ -1245,10 +1230,7 @@ banner(pp, name1, name2) } static char * -scnline(key, p, c) - register int key; - register char *p; - int c; +scnline(int key, char *p, int c) { register int scnwidth; @@ -1262,10 +1244,7 @@ scnline(key, p, c) #define TRC(q) (((q)-' ')&0177) static void -scan_out(pp, scfd, scsp, dlm) - struct printer *pp; - int scfd, dlm; - char *scsp; +scan_out(struct printer *pp, int scfd, char *scsp, int dlm) { register char *strp; register int nchrs, j; @@ -1297,8 +1276,7 @@ scan_out(pp, scfd, scsp, dlm) } static int -dropit(c) - int c; +dropit(int c) { switch(c) { @@ -1322,14 +1300,11 @@ dropit(c) * tell people about job completion */ static void -sendmail(pp, user, bombed) - struct printer *pp; - char *user; - int bombed; +sendmail(struct printer *pp, char *user, int bombed) { register int i; int p[2], s; - register char *cp; + register const char *cp; struct stat stb; FILE *fp; @@ -1402,22 +1377,20 @@ sendmail(pp, user, bombed) * dofork - fork with retries on failure */ static int -dofork(pp, action) - const struct printer *pp; - int action; +dofork(const struct printer *pp, int action) { - register int i, pid; + register int i, forkpid; struct passwd *pwd; for (i = 0; i < 20; i++) { - if ((pid = fork()) < 0) { + if ((forkpid = fork()) < 0) { sleep((unsigned)(i*i)); continue; } /* * Child should run as daemon instead of root */ - if (pid == 0) { + if (forkpid == 0) { if ((pwd = getpwuid(pp->daemon_user)) == NULL) { syslog(LOG_ERR, "Can't lookup default daemon uid (%ld) in password file", pp->daemon_user); @@ -1427,7 +1400,7 @@ dofork(pp, action) setgid(pwd->pw_gid); setuid(pp->daemon_user); } - return(pid); + return(forkpid); } syslog(LOG_ERR, "can't fork"); @@ -1447,8 +1420,7 @@ dofork(pp, action) * Kill child processes to abort current job. */ static void -abortpr(signo) - int signo; +abortpr(int signo __unused) { (void) unlink(tempstderr); @@ -1463,8 +1435,7 @@ abortpr(signo) } static void -init(pp) - struct printer *pp; +init(struct printer *pp) { char *s; @@ -1479,8 +1450,7 @@ init(pp) } void -startprinting(printer) - const char *printer; +startprinting(const char *printer) { struct printer myprinter, *pp = &myprinter; int status; @@ -1506,8 +1476,7 @@ startprinting(printer) * Acquire line printer or remote connection. */ static void -openpr(pp) - const struct printer *pp; +openpr(const struct printer *pp) { int p[2]; char *cp; @@ -1562,8 +1531,7 @@ openpr(pp) * or to a terminal server on the net */ static void -opennet(pp) - const struct printer *pp; +opennet(const struct printer *pp) { register int i; int resp; @@ -1615,8 +1583,7 @@ opennet(pp) * Printer is connected to an RS232 port on this host */ static void -opentty(pp) - const struct printer *pp; +opentty(const struct printer *pp) { register int i; @@ -1645,8 +1612,7 @@ opentty(pp) * Printer is on a remote host */ static void -openrem(pp) - const struct printer *pp; +openrem(const struct printer *pp) { register int i; int resp; @@ -1687,8 +1653,7 @@ openrem(pp) * setup tty lines. */ static void -setty(pp) - const struct printer *pp; +setty(const struct printer *pp) { struct termios ttybuf; @@ -1756,7 +1721,8 @@ pstatus(pp, msg, va_alist) } void -alarmhandler(signo) +alarmhandler(int signo __unused) { - /* ignored */ + /* the signal is ignored */ + /* (the '__unused' is just to avoid a compile-time warning) */ } diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c index a5a56db..661ad05 100644 --- a/usr.sbin/lpr/lpd/recvjob.c +++ b/usr.sbin/lpr/lpd/recvjob.c @@ -71,21 +71,20 @@ static const char rcsid[] = static char dfname[NAME_MAX]; /* data files */ static int minfree; /* keep at least minfree blocks available */ -static char *sp = ""; +static const char *sp = ""; static char tfname[NAME_MAX]; /* tmp copy of cf before linking */ -static int chksize __P((int)); -static void frecverr __P((const char *, ...)); -static int noresponse __P((void)); -static void rcleanup __P((int)); -static int read_number __P((char *)); -static int readfile __P((struct printer *pp, char *, int)); -static int readjob __P((struct printer *pp)); +static int chksize(int _size); +static void frecverr(const char *_msg, ...); +static int noresponse(void); +static void rcleanup(int _signo); +static int read_number(const char *_fn); +static int readfile(struct printer *_pp, char *_file, int _size); +static int readjob(struct printer *_pp); void -recvjob(printer) - const char *printer; +recvjob(const char *printer) { struct stat stb; int status; @@ -138,8 +137,7 @@ recvjob(printer) * Return the number of jobs successfully transfered. */ static int -readjob(pp) - struct printer *pp; +readjob(struct printer *pp) { register int size; register char *cp; @@ -246,10 +244,7 @@ readjob(pp) * Read files send by lpd and copy them to the spooling directory. */ static int -readfile(pp, file, size) - struct printer *pp; - char *file; - int size; +readfile(struct printer *pp, char *file, int size) { register char *cp; char buf[BUFSIZ]; @@ -301,7 +296,7 @@ readfile(pp, file, size) } static int -noresponse() +noresponse(void) { char resp; @@ -319,8 +314,7 @@ noresponse() * 1 == OK, 0 == Not OK. */ static int -chksize(size) - int size; +chksize(int size) { int spacefree; struct statfs sfb; @@ -337,8 +331,7 @@ chksize(size) } static int -read_number(fn) - char *fn; +read_number(const char *fn) { char lin[80]; register FILE *fp; @@ -357,8 +350,7 @@ read_number(fn) * Remove all the files associated with the current job being transfered. */ static void -rcleanup(signo) - int signo; +rcleanup(int signo __unused) { if (tfname[0] && strchr(tfname, '/') == NULL) (void) unlink(tfname); |