diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2004-03-15 02:50:30 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2004-03-15 02:50:30 +0000 |
commit | 8b2f23f3ea191acc1b81ac0484a2dfe4952f2944 (patch) | |
tree | edef35e9e5933535f1bea2b8e0f56b23faffe7ea | |
parent | 8643441541fb3794d9afa416a43637d0b41375f9 (diff) |
Wall, commons, little knf
-rw-r--r-- | usr.bin/finger/finger.c | 8 | ||||
-rw-r--r-- | usr.bin/finger/finger.h | 6 | ||||
-rw-r--r-- | usr.bin/finger/lprint.c | 10 | ||||
-rw-r--r-- | usr.bin/finger/net.c | 4 | ||||
-rw-r--r-- | usr.bin/finger/sprint.c | 17 | ||||
-rw-r--r-- | usr.bin/finger/util.c | 38 |
6 files changed, 43 insertions, 40 deletions
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index d3bdfadd737..af78432b3f8 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: finger.c,v 1.15 2003/10/17 10:56:09 jmc Exp $ */ +/* $OpenBSD: finger.c,v 1.16 2004/03/15 02:50:29 tedu Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -43,14 +43,14 @@ */ #ifndef lint -char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1989 The Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint /*static char sccsid[] = "from: @(#)finger.c 5.22 (Berkeley) 6/29/90";*/ -static char rcsid[] = "$OpenBSD: finger.c,v 1.15 2003/10/17 10:56:09 jmc Exp $"; +static const char rcsid[] = "$OpenBSD: finger.c,v 1.16 2004/03/15 02:50:29 tedu Exp $"; #endif /* not lint */ /* @@ -82,6 +82,8 @@ static char rcsid[] = "$OpenBSD: finger.c,v 1.15 2003/10/17 10:56:09 jmc Exp $"; time_t now; int entries, lflag, sflag, mflag, oflag, pplan, Mflag; char tbuf[1024]; +PERSON *htab[HSIZE]; +PERSON *phead, *ptail; int main(int argc, char *argv[]) diff --git a/usr.bin/finger/finger.h b/usr.bin/finger/finger.h index a4c3c406f7e..3e95f0bfca1 100644 --- a/usr.bin/finger/finger.h +++ b/usr.bin/finger/finger.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: finger.h,v 1.5 2003/06/25 21:10:55 deraadt Exp $*/ +/* * $OpenBSD: finger.h,v 1.6 2004/03/15 02:50:29 tedu Exp $*/ /* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. @@ -75,5 +75,5 @@ typedef struct where { #define HSIZE (1 << 8) /* hash table size */ #define HMASK (HSIZE - 1) /* hash code mask */ -PERSON *htab[HSIZE]; /* the buckets */ -PERSON *phead, *ptail; /* the linked list of all people */ +extern PERSON *htab[HSIZE]; /* the buckets */ +extern PERSON *phead, *ptail; /* the linked list of all people */ diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c index df8909aa320..c70e27c8f42 100644 --- a/usr.bin/finger/lprint.c +++ b/usr.bin/finger/lprint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lprint.c,v 1.7 2003/06/10 22:20:46 deraadt Exp $ */ +/* $OpenBSD: lprint.c,v 1.8 2004/03/15 02:50:29 tedu Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)lprint.c 5.13 (Berkeley) 10/31/90";*/ -static char rcsid[] = "$OpenBSD: lprint.c,v 1.7 2003/06/10 22:20:46 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: lprint.c,v 1.8 2004/03/15 02:50:29 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -258,7 +258,7 @@ demi_print(char *str, int oddfield) (void)printf("%s", str); oddfield = !oddfield; /* toggle odd/even marker */ lenlast = lenthis; - return(oddfield); + return (oddfield); } int @@ -270,14 +270,14 @@ show_text(char *directory, char *file_name, char *header) lastc = 0; (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", directory, file_name); if ((fp = fopen(tbuf, "r")) == NULL) - return(0); + return (0); (void)printf("%s\n", header); while ((ch = getc(fp)) != EOF) vputc(lastc = ch); if (lastc != '\n') (void)putchar('\n'); (void)fclose(fp); - return(1); + return (1); } void diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c index 79361c3e5ec..75ab36a084a 100644 --- a/usr.bin/finger/net.c +++ b/usr.bin/finger/net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net.c,v 1.9 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: net.c,v 1.10 2004/03/15 02:50:29 tedu Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)net.c 5.5 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$OpenBSD: net.c,v 1.9 2003/06/03 02:56:08 millert Exp $"; +static const char rcsid[] = "$OpenBSD: net.c,v 1.10 2004/03/15 02:50:29 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index de1ae9d2272..39c010cda61 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sprint.c,v 1.9 2003/07/10 00:06:50 david Exp $ */ +/* $OpenBSD: sprint.c,v 1.10 2004/03/15 02:50:29 tedu Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)sprint.c 5.8 (Berkeley) 12/4/90";*/ -static char rcsid[] = "$OpenBSD: sprint.c,v 1.9 2003/07/10 00:06:50 david Exp $"; +static const char rcsid[] = "$OpenBSD: sprint.c,v 1.10 2004/03/15 02:50:29 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -143,13 +143,13 @@ sort(void) for (lp = list, pn = phead; pn != NULL; pn = pn->next) *lp++ = pn; (void)qsort(list, entries, sizeof(PERSON *), psort); - return(list); + return (list); } int psort(const void *p, const void *t) { - return(strcmp((*(PERSON **)p)->name, (*(PERSON **)t)->name)); + return (strcmp((*(PERSON **)p)->name, (*(PERSON **)t)->name)); } void @@ -158,15 +158,16 @@ stimeprint(WHERE *w) struct tm *delta; delta = gmtime(&w->idletime); - if (!delta->tm_yday) - if (!delta->tm_hour) + if (!delta->tm_yday) { + if (!delta->tm_hour) { if (!delta->tm_min) (void)printf(" -"); else (void)printf("%5d", delta->tm_min); - else + } else { (void)printf("%2d:%02d", delta->tm_hour, delta->tm_min); - else + } + } else (void)printf("%4dd", delta->tm_yday); } diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index 98be72cc068..62b8f99cab8 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.19 2003/07/02 21:04:10 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.20 2004/03/15 02:50:29 tedu Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)util.c 5.14 (Berkeley) 1/17/91";*/ -static char rcsid[] = "$OpenBSD: util.c,v 1.19 2003/07/02 21:04:10 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.20 2004/03/15 02:50:29 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -140,12 +140,12 @@ match(struct passwd *pw, char *user) /* ampersands get replaced by the login name */ if (!(p = strtok(p, ","))) - return(0); + return (0); expandusername(p, pw->pw_name, name, sizeof(name)); for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL) if (!strcasecmp(p, user)) - return(1); - return(0); + return (1); + return (0); } /* inspired by usr.sbin/sendmail/util.c::buildfname */ @@ -248,8 +248,8 @@ enter_person(struct passwd *pw) PERSON *pn, **pp; for (pp = htab + hash(pw->pw_name); - *pp != NULL && strcmp((*pp)->name, pw->pw_name) != 0; - pp = &(*pp)->hlink) + *pp != NULL && strcmp((*pp)->name, pw->pw_name) != 0; + pp = &(*pp)->hlink) ; if ((pn = *pp) == NULL) { pn = palloc(); @@ -266,7 +266,7 @@ enter_person(struct passwd *pw) userinfo(pn, pw); pn->whead = NULL; } - return(pn); + return (pn); } PERSON * @@ -276,10 +276,10 @@ find_person(char *name) /* name may be only UT_NAMESIZE long and not terminated */ for (pn = htab[hash(name)]; - pn != NULL && strncmp(pn->name, name, UT_NAMESIZE) != 0; - pn = pn->hlink) + pn != NULL && strncmp(pn->name, name, UT_NAMESIZE) != 0; + pn = pn->hlink) ; - return(pn); + return (pn); } int @@ -291,7 +291,7 @@ hash(char *name) /* name may be only UT_NAMESIZE long and not terminated */ for (i = UT_NAMESIZE; --i >= 0 && *name;) h = ((h << 2 | h >> (HBITS - 2)) ^ *name++) & HMASK; - return(h); + return (h); } PERSON * @@ -301,7 +301,7 @@ palloc(void) if ((p = (PERSON *)malloc((u_int) sizeof(PERSON))) == NULL) err(1, "malloc"); - return(p); + return (p); } WHERE * @@ -318,7 +318,7 @@ walloc(PERSON *pn) pn->wtail = w; } w->next = NULL; - return(w); + return (w); } char * @@ -331,10 +331,10 @@ prphone(char *num) /* don't touch anything if the user has their own formatting */ for (p = num; *p; ++p) if (!isdigit(*p)) - return(num); + return (num); len = p - num; p = pbuf; - switch(len) { + switch (len) { case 11: /* +0-123-456-7890 */ *p++ = '+'; *p++ = *num++; @@ -357,7 +357,7 @@ prphone(char *num) *p++ = *num++; break; default: - return(num); + return (num); } if (len != 4) { *p++ = '-'; @@ -367,7 +367,7 @@ prphone(char *num) *p++ = *num++; *p++ = *num++; *p = '\0'; - return(pbuf); + return (pbuf); } /* Like strvis(), but use malloc() to get the space and return a pointer @@ -384,5 +384,5 @@ vs(char *src) err(1, "malloc failed"); strvis(dst, src, VIS_SAFE|VIS_NOSLASH); - return(dst); + return (dst); } |