diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-01-04 18:30:06 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-01-04 18:30:06 +0000 |
commit | 27fd401569750304c84062fbd263c0ddc9ffb4e9 (patch) | |
tree | 31cae54062a308f658e39ed89d05873ef295aa6b /usr.sbin | |
parent | 0e1adc1ef708c6d4bbd352ef834deb2247c3a329 (diff) |
knf and lint
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/config/cmd.c | 6 | ||||
-rw-r--r-- | usr.sbin/config/config.h | 10 | ||||
-rw-r--r-- | usr.sbin/config/exec_elf.c | 19 | ||||
-rw-r--r-- | usr.sbin/config/hash.c | 16 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 8 | ||||
-rw-r--r-- | usr.sbin/config/mkioconf.c | 5 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 30 | ||||
-rw-r--r-- | usr.sbin/config/scan.l | 6 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 6 | ||||
-rw-r--r-- | usr.sbin/config/ukcutil.c | 161 |
10 files changed, 128 insertions, 139 deletions
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c index 0f9210027ec..275905bcd50 100644 --- a/usr.sbin/config/cmd.c +++ b/usr.sbin/config/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.11 2004/01/04 00:47:01 deraadt Exp $ */ +/* $OpenBSD: cmd.c,v 1.12 2004/01/04 18:30:05 deraadt Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -25,7 +25,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: cmd.c,v 1.11 2004/01/04 00:47:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: cmd.c,v 1.12 2004/01/04 18:30:05 deraadt Exp $"; #endif #include <sys/types.h> @@ -77,7 +77,7 @@ Xhelp(cmd_t *cmd) /* Hmm, print out cmd_table here... */ for (i = 0; cmd_table[i].cmd != NULL; i++) printf("\t%-12s%-20s%s\n", cmd_table[i].cmd, - cmd_table[i].opt, cmd_table[i].help); + cmd_table[i].opt, cmd_table[i].help); return (CMD_CONT); } diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 640d8f38164..f44da6b8b76 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.20 2004/01/04 00:47:01 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.21 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */ /* @@ -240,9 +240,9 @@ struct files { struct objects { struct objects *oi_next;/* linked list */ const char *oi_srcfile; /* the name of the "objects" file that got us */ - u_short oi_srcline; /* and the line number */ - u_char oi_flags; /* as below */ - char oi_lastc; /* last char from path */ + u_short oi_srcline; /* and the line number */ + u_char oi_flags; /* as below */ + char oi_lastc; /* last char from path */ const char *oi_path; /* full object path */ struct nvlist *oi_optx;/* options expression */ struct nvlist *oi_optf;/* flattened version of above, if needed */ @@ -326,7 +326,7 @@ void addobject(const char *, struct nvlist *, int); /* hash.c */ struct hashtab *ht_new(void); int ht_insrep(struct hashtab *, const char *, void *, int); -int ht_remove(struct hashtab *, const char *); +int ht_remove(struct hashtab *, const char *); #define ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0) #define ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1) void *ht_lookup(struct hashtab *, const char *); diff --git a/usr.sbin/config/exec_elf.c b/usr.sbin/config/exec_elf.c index 33b27997615..09e8c37aa7f 100644 --- a/usr.sbin/config/exec_elf.c +++ b/usr.sbin/config/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.9 2003/09/26 17:00:27 deraadt Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.10 2004/01/04 18:30:05 deraadt Exp $ */ /* * Copyright (c) 1999 Mats O Jansson. All rights reserved. @@ -25,7 +25,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: exec_elf.c,v 1.9 2003/09/26 17:00:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: exec_elf.c,v 1.10 2004/01/04 18:30:05 deraadt Exp $"; #endif #include <err.h> @@ -124,8 +124,6 @@ void elf_loadkernel(char *file) { int fd; - Elf_Phdr *p; - Elf_Shdr *s; if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0) err(1, "%s", file); @@ -136,19 +134,16 @@ elf_loadkernel(char *file) if (!IS_ELF(elf_ex)) errx(1, "bad elf magic"); - elf_size = lseek(fd, 0L, SEEK_END); - (void)lseek(fd, 0L, SEEK_SET); - elf_total = emalloc(elf_size); + elf_size = lseek(fd, (off_t)0, SEEK_END); + (void)lseek(fd, (off_t)0, SEEK_SET); + elf_total = emalloc((size_t)elf_size); - if (read(fd, elf_total, elf_size) != elf_size) + if (read(fd, elf_total, (size_t)elf_size) != elf_size) errx(1, "can't read elf kernel"); elf_phdr = (Elf_Phdr *)&elf_total[elf_ex.e_phoff]; elf_shdr = (Elf_Shdr *)&elf_total[elf_ex.e_shoff]; - p = elf_phdr; - s = elf_shdr; - elf_shstrtab = &elf_total[elf_shdr[elf_ex.e_shstrndx].sh_offset]; close(fd); @@ -162,7 +157,7 @@ elf_savekernel(char *outfile) if ((fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0755)) < 0) err(1, "%s", outfile); - if (write(fd, elf_total, elf_size) != elf_size) + if (write(fd, elf_total, (size_t)elf_size) != elf_size) errx(1, "can't write file %s", outfile); close(fd); diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c index 2ee2d6e1740..6da03b377cf 100644 --- a/usr.sbin/config/hash.c +++ b/usr.sbin/config/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.13 2003/06/28 04:55:07 deraadt Exp $ */ +/* $OpenBSD: hash.c,v 1.14 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: hash.c,v 1.4 1996/11/07 22:59:43 gwr Exp $ */ /* @@ -168,7 +168,7 @@ ht_expand(struct hashtab *ht) /* * Make a new hash entry, setting its h_next to NULL. */ -static inline struct hashent * +static __inline struct hashent * newhashent(const char *name, u_int h) { struct hashent *hp; @@ -185,7 +185,7 @@ newhashent(const char *name, u_int h) /* * Hash a string. */ -static inline u_int +static __inline u_int hash(const char *str) { u_int h; @@ -252,20 +252,20 @@ ht_remove(struct hashtab *ht, const char *nam) h = hash(nam); hp = ht->ht_tab[h & ht->ht_mask]; while (hp && hp->h_name == nam) { - ht->ht_tab[h & ht->ht_mask] = hp->h_next; + ht->ht_tab[h & ht->ht_mask] = hp->h_next; /* XXX free hp ? */ hp = ht->ht_tab[h & ht->ht_mask]; } if ((hp = ht->ht_tab[h & ht->ht_mask]) == NULL) - return (0); + return (0); for (thp = hp->h_next; thp != NULL; thp = hp->h_next) { - if (thp->h_name == nam) { - hp->h_next = thp->h_next; + if (thp->h_name == nam) { + hp->h_next = thp->h_next; /* XXX free thp ? */ } else - hp = thp; + hp = thp; } return (0); diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 48cb7aea2cb..2d2cb808db0 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.35 2004/01/04 00:47:01 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.36 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */ /* @@ -658,17 +658,17 @@ setupdirs(void) madedir = 1; } else if (!S_ISDIR(st.st_mode)) { (void)fprintf(stderr, "config: %s is not a directory\n", - builddir); + builddir); exit(2); } if (chdir(builddir) != 0) { (void)fprintf(stderr, "config: cannot change to %s\n", - builddir); + builddir); exit(2); } if (stat(srcdir, &st) != 0 || !S_ISDIR(st.st_mode)) { (void)fprintf(stderr, "config: %s is not a directory\n", - srcdir); + srcdir); exit(2); } } diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index ec75dd34148..067f0d6ff14 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkioconf.c,v 1.24 2003/12/06 21:46:53 deraadt Exp $ */ +/* $OpenBSD: mkioconf.c,v 1.25 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: mkioconf.c,v 1.41 1996/11/11 14:18:49 mycroft Exp $ */ /* @@ -334,7 +334,7 @@ short pv[%d] = {", parents.used) < 0) static int emitcfdata(FILE *fp) { - struct devi **p, *i, **par; + struct devi **p, *i; int unit, v; const char *vs, *state, *basename, *attachment; struct nvlist *nv; @@ -355,7 +355,6 @@ struct cfdata cfdata[] = {\n\ /* the description */ if (fprintf(fp, "/*%3d: %s at ", i->i_cfindex, i->i_name) < 0) return (1); - par = i->i_parents; for (v = 0; v < i->i_pvlen; v++) if (fprintf(fp, "%s%s", v == 0 ? "" : "|", i->i_parents[v]->i_name) < 0) diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 86dec823d93..dff4bac249b 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkmakefile.c,v 1.15 2003/06/28 04:55:07 deraadt Exp $ */ +/* $OpenBSD: mkmakefile.c,v 1.16 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */ /* @@ -244,19 +244,19 @@ emitobjs(FILE *fp) sp = ' '; } for (oi = allobjects; oi != NULL; oi = oi->oi_next) { - if ((oi->oi_flags & OI_SEL) == 0) - continue; - len = strlen(oi->oi_path) + 3; - if (lpos + len > 72) { - if (fputs(" \\\n", fp) < 0) - return (1); - sp = '\t'; - lpos = 7; - } - if (fprintf(fp, "%c$S/%s", sp, oi->oi_path) < 0) - return (1); - lpos += len + 1; - sp = ' '; + if ((oi->oi_flags & OI_SEL) == 0) + continue; + len = strlen(oi->oi_path) + 3; + if (lpos + len > 72) { + if (fputs(" \\\n", fp) < 0) + return (1); + sp = '\t'; + lpos = 7; + } + if (fprintf(fp, "%c$S/%s", sp, oi->oi_path) < 0) + return (1); + lpos += len + 1; + sp = ' '; } if (putc('\n', fp) < 0) return (1); @@ -294,7 +294,7 @@ emitfiles(FILE *fp, int suffix) if ((fi->fi_flags & FI_SEL) == 0) continue; if ((fpath = srcpath(fi)) == NULL) - return (1); + return (1); len = strlen(fpath); if (fpath[len - 1] != suffix) continue; diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index 11cac938912..e185c16ba8d 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.16 2003/06/02 23:36:52 millert Exp $ */ +/* $OpenBSD: scan.l,v 1.17 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: scan.l,v 1.13 1997/02/02 21:12:37 thorpej Exp $ */ /* @@ -112,8 +112,8 @@ root return ROOT; source return SOURCE; swap return SWAP; with return WITH; -rmoption return RMOPTIONS; -rmoptions return RMOPTIONS; +rmoption return RMOPTIONS; +rmoptions return RMOPTIONS; {PATH} { yylval.str = intern(yytext); diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index 69907ca9059..3d5e60491c5 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.29 2003/06/28 04:55:07 deraadt Exp $ */ +/* $OpenBSD: sem.c,v 1.30 2004/01/04 18:30:05 deraadt Exp $ */ /* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */ /* @@ -58,7 +58,6 @@ const char *s_generic; const char *s_nfs; -static const char *s_qmark; static struct hashtab *attrtab; /* for attribute lookup */ static struct hashtab *cfhashtab; /* for config lookup */ @@ -116,7 +115,6 @@ initsem(void) s_generic = intern("generic"); s_nfs = intern("nfs"); - s_qmark = intern("?"); } /* Name of include file just ended (set in scan.l) */ @@ -404,7 +402,7 @@ defdevattach(struct deva *deva, struct devbase *dev, struct nvlist *atlist, for (da = dev->d_ahead; da != NULL; da = da->d_bsame) if (onlist(da->d_atlist, a)) error("attach at `%s' already done by `%s'", - a ? a->a_name : "root", da->d_name); + a ? a->a_name : "root", da->d_name); if (a == NULL) continue; /* at root; don't add */ diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c index 03958ea575e..288915c12ad 100644 --- a/usr.sbin/config/ukcutil.c +++ b/usr.sbin/config/ukcutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukcutil.c,v 1.13 2003/06/02 21:19:03 maja Exp $ */ +/* $OpenBSD: ukcutil.c,v 1.14 2004/01/04 18:30:05 deraadt Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -25,7 +25,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.13 2003/06/02 21:19:03 maja Exp $"; +static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.14 2004/01/04 18:30:05 deraadt Exp $"; #endif #include <sys/types.h> @@ -48,28 +48,28 @@ struct cfdata * get_cfdata(int idx) { return((struct cfdata *)(adjust((caddr_t)nl[P_CFDATA].n_value) + - idx*sizeof(struct cfdata))); + idx * sizeof(struct cfdata))); } short * get_locnamp(int idx) { return((short *)(adjust((caddr_t)nl[S_LOCNAMP].n_value) + - idx*sizeof(short))); + idx * sizeof(short))); } caddr_t * get_locnames(int idx) { return((caddr_t *)(adjust((caddr_t)nl[P_LOCNAMES].n_value) + - idx*sizeof(caddr_t))); + idx * sizeof(caddr_t))); } int * get_extraloc(int idx) { return((int *)(adjust((caddr_t)nl[IA_EXTRALOC].n_value) + - idx*sizeof(int))); + idx * sizeof(int))); } char * @@ -78,7 +78,7 @@ get_pdevnames(int idx) caddr_t *p; p = (caddr_t *)adjust((caddr_t)nl[P_PDEVNAMES].n_value + - idx*sizeof(caddr_t)); + idx * sizeof(caddr_t)); return(char *)adjust((caddr_t)*p); } @@ -87,7 +87,7 @@ struct pdevinit * get_pdevinit(int idx) { return((struct pdevinit *)(adjust((caddr_t)nl[S_PDEVINIT].n_value) + - idx*sizeof(struct pdevinit))); + idx * sizeof(struct pdevinit))); } int @@ -133,7 +133,7 @@ pnum(int val) } void -pdevnam(short int devno) +pdevnam(short devno) { struct cfdata *cd; struct cfdriver *cdrv; @@ -167,14 +167,14 @@ pdevnam(short int devno) } void -pdev(short int devno) +pdev(short devno) { + struct pdevinit *pi; struct cfdata *cd; short *s, *ln; int *i; caddr_t *p; char c; - struct pdevinit *pi; if (nopdev == 0) { if (devno > maxdev && devno <= totdev) { @@ -240,9 +240,8 @@ pdev(short int devno) int number(const char *c, int *val) { + int neg = 0, base = 10; u_int num = 0; - int neg = 0; - int base = 10; if (*c == '-') { neg = 1; @@ -281,9 +280,9 @@ number(const char *c, int *val) } int -device(char *cmd, int *len, short int *unit, short int *state) +device(char *cmd, int *len, short *unit, short *state) { - short int u = 0, s = FSTATE_FOUND; + short u = 0, s = FSTATE_FOUND; int l = 0; char *c; @@ -292,6 +291,7 @@ device(char *cmd, int *len, short int *unit, short int *state) l++; c++; } + if (*c == '*') { s = FSTATE_STAR; c++; @@ -311,16 +311,15 @@ device(char *cmd, int *len, short int *unit, short int *state) *state = s; return(0); } - return(-1); } int attr(char *cmd, int *val) { - char *c; + short attr = -1, i = 0, l = 0; caddr_t *p; - short int attr = -1, i = 0, l = 0; + char *c; c = cmd; while (*c != ' ' && *c != '\t' && *c != '\n' && *c != '\0') { @@ -377,81 +376,81 @@ modify(char *item, int *val) void change(int devno) { + int i, share = 0, *j = NULL, *k = NULL, *l; struct cfdata *cd, *c; - caddr_t *p; struct pdevinit *pi; - int i, share = 0, *j = NULL, *k = NULL, *l; short *ln, *lk; + caddr_t *p; ukc_mod_kernel = 1; if (devno <= maxdev) { pdev(devno); - if (ask_yn("change")) { - - cd = get_cfdata(devno); - - /* - * Search for some other driver sharing this - * locator table. if one does, we may need to - * replace the locators with a new copy. - */ - c = get_cfdata(0); - for (i = 0; c->cf_driver; i++) { - if (i != devno && c->cf_loc == cd->cf_loc) - share = 1; - c++; - } - - ln = get_locnamp(cd->cf_locnames); - l = (int *)adjust((caddr_t)cd->cf_loc); + if (!ask_yn("change")) + return; - if (share) { - if (oldkernel) { - printf("Can't do that on this kernel\n"); - return; - } + cd = get_cfdata(devno); - lk = ln; - i = 0; - while (*lk != -1) { - lk++; - i++; - } - lk = ln; + /* + * Search for some other driver sharing this + * locator table. if one does, we may need to + * replace the locators with a new copy. + */ + c = get_cfdata(0); + for (i = 0; c->cf_driver; i++) { + if (i != devno && c->cf_loc == cd->cf_loc) + share = 1; + c++; + } - j = (int *)adjust((caddr_t)nl[I_NEXTRALOC].n_value); - k = (int *)adjust((caddr_t)nl[I_UEXTRALOC].n_value); - if ((i + *k) > *j) { - printf("Not enough space to change device.\n"); - return; - } + ln = get_locnamp(cd->cf_locnames); + l = (int *)adjust((caddr_t)cd->cf_loc); - j = l = get_extraloc(*k); - bcopy(adjust((caddr_t)cd->cf_loc), - l, sizeof(int) * i); + if (share) { + if (oldkernel) { + printf("Can't do that on this kernel\n"); + return; } - while (*ln != -1) { - p = get_locnames(*ln); - modify((char *)adjust(*p), l); - ln++; - l++; + lk = ln; + i = 0; + while (*lk != -1) { + lk++; + i++; } - modify("flags", &cd->cf_flags); + lk = ln; - if (share) { - if (bcmp(adjust((caddr_t)cd->cf_loc), j, - sizeof(int) * i)) { - cd->cf_loc = (int *)readjust((caddr_t)j); - *k = *k + i; - } + j = (int *)adjust((caddr_t)nl[I_NEXTRALOC].n_value); + k = (int *)adjust((caddr_t)nl[I_UEXTRALOC].n_value); + if ((i + *k) > *j) { + printf("Not enough space to change device.\n"); + return; } - printf("%3d ", devno); - pdevnam(devno); - printf(" changed\n"); - pdev(devno); + j = l = get_extraloc(*k); + bcopy(adjust((caddr_t)cd->cf_loc), + l, sizeof(int) * i); + } + + while (*ln != -1) { + p = get_locnames(*ln); + modify((char *)adjust(*p), l); + ln++; + l++; + } + modify("flags", &cd->cf_flags); + + if (share) { + if (bcmp(adjust((caddr_t)cd->cf_loc), j, + sizeof(int) * i)) { + cd->cf_loc = (int *)readjust((caddr_t)j); + *k = *k + i; + } } + + printf("%3d ", devno); + pdevnam(devno); + printf(" changed\n"); + pdev(devno); return; } @@ -480,11 +479,10 @@ change(int devno) void change_history(int devno, char *str) { - int i, share = 0, *j = NULL, *k = NULL, *l; + int i, share = 0, *j = NULL, *k = NULL, *l; struct cfdata *cd, *c; struct pdevinit *pi; short *ln, *lk; - caddr_t *p; ukc_mod_kernel = 1; @@ -535,7 +533,6 @@ change_history(int devno, char *str) } while (*ln != -1) { - p = get_locnames(*ln); *l = atoi(str); if (*str == '-') str++; @@ -727,7 +724,7 @@ show(void) } void -common_attr_val(short int attr, int *val, char routine) +common_attr_val(short attr, int *val, char routine) { int i = 0; struct cfdata *cd; @@ -827,7 +824,7 @@ show_attr(char *cmd) } void -common_dev(char *dev, int len, short int unit, short int state, char routine) +common_dev(char *dev, int len, short unit, short state, char routine) { struct cfdata *cd; struct cfdriver *cdrv; @@ -1005,7 +1002,7 @@ add_read(char *prompt, char field, char *dev, int len, int *val) } void -add(char *dev, int len, short int unit, short int state) +add(char *dev, int len, short unit, short state) { int i = 0, found = 0, *p; short *pv; @@ -1169,7 +1166,7 @@ add(char *dev, int len, short int unit, short int state) } void -add_history(int devno, short int unit, short int state, int newno) +add_history(int devno, short unit, short state, int newno) { int i = 0, *p; short *pv; |