From owner-freebsd-bugs Thu Sep 10 13:20:15 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA16043 for freebsd-bugs-outgoing; Thu, 10 Sep 1998 13:20:15 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA15946 for ; Thu, 10 Sep 1998 13:20:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id NAA23476; Thu, 10 Sep 1998 13:20:01 -0700 (PDT) Received: from tim.xenologics.com (tim.xenologics.com [194.77.5.24]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA13891 for ; Thu, 10 Sep 1998 13:11:47 -0700 (PDT) (envelope-from seggers@semyam.dinoco.de) Received: (from uucp@localhost) by tim.xenologics.com (8.8.5/8.8.8) with UUCP id WAA23657 for FreeBSD-gnats-submit@freebsd.org; Thu, 10 Sep 1998 22:08:08 +0200 (MET DST) Received: (from seggers@localhost) by semyam.dinoco.de (8.9.1/8.8.8) id WAA28434; Thu, 10 Sep 1998 22:05:02 +0200 (CEST) (envelope-from seggers) Message-Id: <199809102005.WAA28434@semyam.dinoco.de> Date: Thu, 10 Sep 1998 22:05:02 +0200 (CEST) From: Stefan Eggers Reply-To: seggers@semyam.dinoco.de To: FreeBSD-gnats-submit@FreeBSD.ORG Cc: seggers@semyam.dinoco.de X-Send-Pr-Version: 3.2 Subject: bin/7886: lpr code cleanup Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 7886 >Category: bin >Synopsis: lpr code cleanup >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Sep 10 13:20:01 PDT 1998 >Last-Modified: >Originator: Stefan Eggers >Organization: none >Release: FreeBSD 3.0-CURRENT i386 >Environment: -current from Thursday (September 8th, 1998). The system has the standard system GCC and in addition to that egcs from July 15th, 1998 installed. >Description: The code didn't compile w/o warnings with egcs and as part of the lpr code used "-Werror" these were fatal. This was caused by some variable declarations of the form "register i;" which egcs warns about and according to the GCC docs I read GCC 2.8 will do the same on this. In addition to that I noticed some minor bugs (msearch some- times returned int while was declared as returning void in another source file) and declarations scattered among the source files where they could have been in a common include file. I also expanded the use of the CWARNFLAGS variable a bit and made it more strict. >How-To-Repeat: Just read the source and have fun with it. :-( >Fix: The patch I append compiles cleanly with the above mentioned compilers. Real world tests I didn't do, yet as I am waiting for something to print in order not to waste ink and paper. I think it is still worth a look or I wouldn't have committed it. Index: Makefile.inc =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/Makefile.inc,v retrieving revision 1.3 diff -u -r1.3 Makefile.inc --- Makefile.inc 1998/03/07 09:47:52 1.3 +++ Makefile.inc 1998/08/24 17:51:30 @@ -1,6 +1,6 @@ # $Id: Makefile.inc,v 1.3 1998/03/07 09:47:52 bde Exp $ -CWARNFLAGS= -Werror -Wall -Wnested-externs -Wmissing-prototypes -Wno-unused +CWARNFLAGS= -Werror -Wall -Wnested-externs -Wmissing-prototypes -Wno-unused -Wredundant-decls -Wstrict-prototypes .if exists(${.OBJDIR}/../common_source) LIBLPR= ${.OBJDIR}/../common_source/liblpr.a Index: chkprintcap/Makefile =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/chkprintcap/Makefile,v retrieving revision 1.5 diff -u -r1.5 Makefile --- Makefile 1998/06/11 03:51:34 1.5 +++ Makefile 1998/08/24 16:44:56 @@ -2,7 +2,7 @@ PROG= chkprintcap MAN8= chkprintcap.8 -CFLAGS+=-I${.CURDIR}/../common_source -Wall +CFLAGS+=-I${.CURDIR}/../common_source ${CWARNFLAGS} .PATH: ${.CURDIR}/../common_source DPADD= ${LIBLPR} LDADD= ${LIBLPR} Index: common_source/Makefile =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/common_source/Makefile,v retrieving revision 1.3 diff -u -r1.3 Makefile --- Makefile 1998/06/11 03:53:23 1.3 +++ Makefile 1998/08/24 17:58:28 @@ -11,8 +11,7 @@ NOMAN= noman NOPROFILE= noprofile NOPIC= nopic -CFLAGS+= -Wall -Wnested-externs -Wmissing-prototypes \ - -Wstrict-prototypes -Wredundant-decls +CFLAGS+= ${CWARNFLAGS} install: Index: common_source/common.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/common_source/common.c,v retrieving revision 1.10 diff -u -r1.10 common.c --- common.c 1997/12/02 20:45:18 1.10 +++ common.c 1998/08/24 16:35:58 @@ -79,7 +79,7 @@ { register int linel = 0; register char *lp = line; - register c; + register int c; while ((c = getc(cfp)) != '\n' && linel+1 < sizeof(line)) { if (c == EOF) Index: lpc/cmds.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpc/cmds.c,v retrieving revision 1.11 diff -u -r1.11 cmds.c --- cmds.c 1997/12/02 20:45:37 1.11 +++ cmds.c 1998/08/24 17:42:45 @@ -70,8 +70,6 @@ #include "extern.h" #include "pathnames.h" -extern uid_t uid, euid; - static void abortpr __P((struct printer *, int)); static int doarg __P((char *)); static int doselect __P((struct dirent *)); Index: lpc/extern.h =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpc/extern.h,v retrieving revision 1.2 diff -u -r1.2 extern.h --- extern.h 1997/12/02 20:45:41 1.2 +++ extern.h 1998/08/24 17:54:23 @@ -35,6 +35,7 @@ */ +#include #include @@ -57,3 +58,4 @@ extern int NCMDS; extern struct cmd cmdtab[]; +extern uid_t uid, euid; Index: lpc/lpc.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpc/lpc.c,v retrieving revision 1.7 diff -u -r1.7 lpc.c --- lpc.c 1998/03/22 20:19:27 1.7 +++ lpc.c 1998/09/10 19:43:52 @@ -74,16 +74,17 @@ #define MAX_CMDLINE 200 #define MAX_MARGV 20 -int fromatty; +static int fromatty; -char cmdline[MAX_CMDLINE]; -int margc; -char *margv[MAX_MARGV]; -int top; -uid_t uid, euid; +static char cmdline[MAX_CMDLINE]; +static int margc; +static char *margv[MAX_MARGV]; +static int top; +uid_t uid, euid; -jmp_buf toplevel; +static jmp_buf toplevel; +int main __P((int, char *[])); static void cmdscanner __P((int)); static struct cmd *getcmd __P((char *)); static void intr __P((int)); Index: lpd/Makefile =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpd/Makefile,v retrieving revision 1.8 diff -u -r1.8 Makefile --- Makefile 1998/06/11 03:52:41 1.8 +++ Makefile 1998/08/24 16:47:18 @@ -2,7 +2,7 @@ # $Id: Makefile,v 1.8 1998/06/11 03:52:41 jb Exp $ PROG= lpd -CFLAGS+=-I${.CURDIR}/../common_source -Wall +CFLAGS+=-I${.CURDIR}/../common_source ${CWARNFLAGS} MAN8= lpd.8 SRCS= lpd.c printjob.c recvjob.c lpdchar.c modes.c DPADD= ${LIBLPR} Index: lpd/extern.h =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpd/extern.h,v retrieving revision 1.3 diff -u -r1.3 extern.h --- extern.h 1997/12/02 20:45:53 1.3 +++ extern.h 1998/08/24 18:21:33 @@ -40,9 +40,11 @@ extern char fromb[]; 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)); __END_DECLS Index: lpd/lpd.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpd/lpd.c,v retrieving revision 1.9 diff -u -r1.9 lpd.c --- lpd.c 1997/12/02 20:45:54 1.9 +++ lpd.c 1998/09/10 19:45:56 @@ -106,6 +106,7 @@ int lflag; /* log requests 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)); Index: lpd/modes.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpd/modes.c,v retrieving revision 1.4 diff -u -r1.4 modes.c --- modes.c 1997/12/02 20:45:56 1.4 +++ modes.c 1998/08/24 18:23:19 @@ -42,6 +42,8 @@ #include #include #include +#include "lp.local.h" +#include "extern.h" struct modes { char *name; Index: lpd/printjob.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpd/printjob.c,v retrieving revision 1.19 diff -u -r1.19 printjob.c --- printjob.c 1998/08/21 18:08:46 1.19 +++ printjob.c 1998/08/24 18:21:53 @@ -141,8 +141,6 @@ static void sendmail __P((struct printer *pp, char *user, int bombed)); static void setty __P((const struct printer *pp)); -void msearch __P((char *, struct termios *)); - void printjob(pp) struct printer *pp; @@ -1150,7 +1148,7 @@ register char *p; int c; { - register scnwidth; + register int scnwidth; for (scnwidth = WIDTH; --scnwidth;) { key <<= 1; @@ -1168,7 +1166,7 @@ char *scsp; { register char *strp; - register nchrs, j; + register int nchrs, j; char outbuf[LINELEN+1], *sp, c, cc; int d, scnhgt; @@ -1596,7 +1594,7 @@ char *s = strdup(pp->mode_set), *tmp; while ((tmp = strsep(&s, ",")) != NULL) { - msearch(tmp, &ttybuf); + (void) msearch(tmp, &ttybuf); } } if (pp->mode_set != 0 || pp->baud_rate > 0) { Index: lpq/lpq.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpq/lpq.c,v retrieving revision 1.5 diff -u -r1.5 lpq.c --- lpq.c 1997/12/02 20:46:04 1.5 +++ lpq.c 1998/08/24 17:58:00 @@ -79,6 +79,7 @@ static int ckqueue __P((const struct printer *)); static void usage __P((void)); +int main __P((int, char **)); int main(argc, argv) Index: lpr/lpr.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lpr/lpr.c,v retrieving revision 1.24 diff -u -r1.24 lpr.c --- lpr.c 1998/04/17 17:25:49 1.24 +++ lpr.c 1998/09/10 19:49:17 @@ -550,7 +550,7 @@ cleanup(signo) int signo; { - register i; + register int i; signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); @@ -610,6 +610,9 @@ printf("%s: cannot open %s\n", name, file); return(-1); } + /* + * XXX Shall we add a similar test for ELF? + */ if (read(fd, &execb, sizeof(execb)) == sizeof(execb) && !N_BADMAG(execb)) { printf("%s: %s is an executable program", name, file); Index: lprm/lprm.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/lprm/lprm.c,v retrieving revision 1.4 diff -u -r1.4 lprm.c --- lprm.c 1997/12/02 20:46:15 1.4 +++ lprm.c 1998/09/10 19:49:44 @@ -82,6 +82,7 @@ static char luser[16]; /* buffer for person */ +int main __P((int, char *[])); static void usage __P((void)); int Index: pac/Makefile =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/pac/Makefile,v retrieving revision 1.5 diff -u -r1.5 Makefile --- Makefile 1998/03/07 09:48:14 1.5 +++ Makefile 1998/08/24 16:51:17 @@ -2,7 +2,7 @@ # $Id: Makefile,v 1.5 1998/03/07 09:48:14 bde Exp $ PROG= pac -CFLAGS+=-I${.CURDIR}/../common_source +CFLAGS+=-I${.CURDIR}/../common_source ${CWARNFLAGS} MAN8= pac.8 .PATH: ${.CURDIR}/../common_source DPADD= ${LIBLPR} Index: pac/pac.c =================================================================== RCS file: /usr2/FreeBSD/CVSROOT/src/usr.sbin/lpr/pac/pac.c,v retrieving revision 1.8 diff -u -r1.8 pac.c --- pac.c 1997/12/02 20:46:22 1.8 +++ pac.c 1998/09/10 19:51:14 @@ -56,9 +56,11 @@ #include #include +#include #include #include #include +#include #include "lp.h" #include "lp.local.h" @@ -94,6 +96,7 @@ static struct hent *hashtab[HSHSIZE]; /* Hash table proper */ +int main __P((int, char **)); static void account __P((FILE *)); static int any __P((int, char [])); static int chkprinter __P((char *)); >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message