Module Name: src Committed By: joerg Date: Tue Jul 2 11:59:47 UTC 2013
Modified Files: src/usr.sbin/eeprom: defs.h eehandlers.c main.c ofhandlers.c ophandlers.c prephandlers.c Log Message: Finish ANSIfication. Drop extra spaces from __P removal. Add more static. Add more const. Use __dead for usage(). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/eeprom/defs.h cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/eeprom/eehandlers.c cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/eeprom/main.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/eeprom/ofhandlers.c cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/eeprom/ophandlers.c cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/eeprom/prephandlers.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/eeprom/defs.h diff -u src/usr.sbin/eeprom/defs.h:1.14 src/usr.sbin/eeprom/defs.h:1.15 --- src/usr.sbin/eeprom/defs.h:1.14 Fri Mar 15 20:22:44 2013 +++ src/usr.sbin/eeprom/defs.h Tue Jul 2 11:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.14 2013/03/15 20:22:44 nakayama Exp $ */ +/* $NetBSD: defs.h,v 1.15 2013/07/02 11:59:46 joerg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ struct keytabent { const char *kt_keyword; /* keyword for this entry */ u_int kt_offset; /* offset into prom of value */ - void (*kt_handler) (struct keytabent *, char *); + void (*kt_handler) (const struct keytabent *, char *); /* handler function for this entry */ }; @@ -84,7 +84,7 @@ struct opiocdesc; */ struct extabent { const char *ex_keyword; /* keyword for this entry */ - void (*ex_handler) (struct extabent *, + void (*ex_handler) (const struct extabent *, struct opiocdesc *, char *); /* handler function for this entry */ }; @@ -93,7 +93,7 @@ struct extabent { #ifdef USE_OPENFIRM struct extabent { const char *ex_keyword; /* keyword for this entry */ - void (*ex_handler) (struct extabent *, + void (*ex_handler) (const struct extabent *, struct ofiocdesc *, char *); /* handler function for this entry */ }; @@ -102,7 +102,7 @@ struct extabent { #ifdef USE_PREPNVRAM struct extabent { const char *ex_keyword; /* keyword for this entry */ - void (*ex_handler) (struct extabent *, + void (*ex_handler) (const struct extabent *, struct pnviocdesc *, char *); /* handler function for this entry */ }; @@ -110,37 +110,25 @@ struct extabent { /* Sun 3/4 EEPROM handlers. */ -void ee_action (char *, char *); -void ee_dump (void); -void ee_hwupdate (struct keytabent *, char *); -void ee_num8 (struct keytabent *, char *); -void ee_num16 (struct keytabent *, char *); -void ee_screensize (struct keytabent *, char *); -void ee_truefalse (struct keytabent *, char *); -void ee_bootdev (struct keytabent *, char *); -void ee_kbdtype (struct keytabent *, char *); -void ee_constype (struct keytabent *, char *); -void ee_diagpath (struct keytabent *, char *); -void ee_banner (struct keytabent *, char *); -void ee_notsupp (struct keytabent *, char *); +void ee_action(char *, char *); +void ee_dump(void); /* Sun 3/4 EEPROM checksum routines. */ -u_char ee_checksum (u_char *, size_t); -void ee_updatechecksums (void); -void ee_verifychecksums (void); +void ee_updatechecksums(void); +void ee_verifychecksums(void); /* Sparc Openprom handlers. */ -char *op_handler (char *, char *); -void op_action (char *, char *); -void op_dump (void); -int check_for_openprom (void); +char *op_handler(char *, char *); +void op_action(char *, char *); +void op_dump(void); +int check_for_openprom(void); /* OpenFirmware handlers. */ -char *of_handler (char *, char *); -void of_action (char *, char *); -void of_dump (void); +char *of_handler(char *, char *); +void of_action(char *, char *); +void of_dump(void); /* PReP nvram handlers. */ -char *prep_handler (char *, char *); -void prep_action (char *, char *); -void prep_dump (void); +char *prep_handler(char *, char *); +void prep_action(char *, char *); +void prep_dump(void); Index: src/usr.sbin/eeprom/eehandlers.c diff -u src/usr.sbin/eeprom/eehandlers.c:1.17 src/usr.sbin/eeprom/eehandlers.c:1.18 --- src/usr.sbin/eeprom/eehandlers.c:1.17 Fri Mar 15 20:22:44 2013 +++ src/usr.sbin/eeprom/eehandlers.c Tue Jul 2 11:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: eehandlers.c,v 1.17 2013/03/15 20:22:44 nakayama Exp $ */ +/* $NetBSD: eehandlers.c,v 1.18 2013/07/02 11:59:46 joerg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -56,10 +56,23 @@ extern u_short writecount; static char err_str[BUFSIZE]; -static void badval (struct keytabent *, char *); -static int doio (struct keytabent *, u_char *, ssize_t, int); +static void badval(const struct keytabent *, char *); +static int doio(const struct keytabent *, u_char *, ssize_t, int); -struct keytabent eekeytab[] = { +static u_char ee_checksum(u_char *, size_t); +static void ee_hwupdate(const struct keytabent *, char *); +static void ee_num8(const struct keytabent *, char *); +static void ee_num16(const struct keytabent *, char *); +static void ee_screensize(const struct keytabent *, char *); +static void ee_truefalse(const struct keytabent *, char *); +static void ee_bootdev(const struct keytabent *, char *); +static void ee_kbdtype(const struct keytabent *, char *); +static void ee_constype(const struct keytabent *, char *); +static void ee_diagpath(const struct keytabent *, char *); +static void ee_banner(const struct keytabent *, char *); +static void ee_notsupp(const struct keytabent *, char *); + +static const struct keytabent eekeytab[] = { { "hwupdate", 0x10, ee_hwupdate }, { "memsize", 0x14, ee_num8 }, { "memtest", 0x15, ee_num8 }, @@ -108,10 +121,9 @@ struct keytabent eekeytab[] = { } void -ee_action(keyword, arg) - char *keyword, *arg; +ee_action(char *keyword, char *arg) { - struct keytabent *ktent; + const struct keytabent *ktent; for (ktent = eekeytab; ktent->kt_keyword != NULL; ++ktent) { if (strcmp(ktent->kt_keyword, keyword) == 0) { @@ -125,18 +137,16 @@ ee_action(keyword, arg) } void -ee_dump() +ee_dump(void) { - struct keytabent *ktent; + const struct keytabent *ktent; for (ktent = eekeytab; ktent->kt_keyword != NULL; ++ktent) (*ktent->kt_handler)(ktent, NULL); } -void -ee_hwupdate(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_hwupdate(const struct keytabent *ktent, char *arg) { uint32_t hwtime; time_t t; @@ -175,10 +185,8 @@ ee_hwupdate(ktent, arg) printf("\n"); } -void -ee_num8(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_num8(const struct keytabent *ktent, char *arg) { u_char num8 = 0; u_int num32; @@ -201,10 +209,8 @@ ee_num8(ktent, arg) printf("%s=%d\n", ktent->kt_keyword, num8); } -void -ee_num16(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_num16(const struct keytabent *ktent, char *arg) { u_int16_t num16 = 0; u_int num32; @@ -227,7 +233,7 @@ ee_num16(ktent, arg) printf("%s=%d\n", ktent->kt_keyword, num16); } -static struct strvaltabent scrsizetab[] = { +static const struct strvaltabent scrsizetab[] = { { "1152x900", EE_SCR_1152X900 }, { "1024x1024", EE_SCR_1024X1024 }, { "1600x1280", EE_SCR_1600X1280 }, @@ -235,12 +241,10 @@ static struct strvaltabent scrsizetab[] { NULL, 0 }, }; -void -ee_screensize(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_screensize(const struct keytabent *ktent, char *arg) { - struct strvaltabent *svp; + const struct strvaltabent *svp; u_char scsize; if (arg) { @@ -269,18 +273,16 @@ ee_screensize(ktent, arg) printf("%s=%s\n", ktent->kt_keyword, svp->sv_str); } -static struct strvaltabent truthtab[] = { +static const struct strvaltabent truthtab[] = { { "true", EE_TRUE }, { "false", EE_FALSE }, { NULL, 0 }, }; -void -ee_truefalse(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_truefalse(const struct keytabent *ktent, char *arg) { - struct strvaltabent *svp; + const struct strvaltabent *svp; u_char truth; if (arg) { @@ -309,10 +311,8 @@ ee_truefalse(ktent, arg) printf("%s=%s\n", ktent->kt_keyword, svp->sv_str); } -void -ee_bootdev(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_bootdev(const struct keytabent *ktent, char *arg) { u_char dev[5]; int i; @@ -381,10 +381,8 @@ ee_bootdev(ktent, arg) dev[1], dev[2], dev[3], dev[4]); } -void -ee_kbdtype(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_kbdtype(const struct keytabent *ktent, char *arg) { u_char kbd = 0; u_int kbd2; @@ -407,7 +405,7 @@ ee_kbdtype(ktent, arg) printf("%s=%d (%s)\n", ktent->kt_keyword, kbd, kbd ? "other" : "Sun"); } -static struct strvaltabent constab[] = { +static const struct strvaltabent constab[] = { { "b&w", EE_CONS_BW }, { "ttya", EE_CONS_TTYA }, { "ttyb", EE_CONS_TTYB }, @@ -416,12 +414,10 @@ static struct strvaltabent constab[] = { { NULL, 0 }, }; -void -ee_constype(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_constype(const struct keytabent *ktent, char *arg) { - struct strvaltabent *svp; + const struct strvaltabent *svp; u_char cons; if (arg) { @@ -451,10 +447,8 @@ ee_constype(ktent, arg) } -void -ee_diagpath(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_diagpath(const struct keytabent *ktent, char *arg) { char path[40]; @@ -472,10 +466,8 @@ ee_diagpath(ktent, arg) printf("%s=%s\n", ktent->kt_keyword, path); } -void -ee_banner(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_banner(const struct keytabent *ktent, char *arg) { char string[80]; u_char enable; @@ -515,19 +507,15 @@ ee_banner(ktent, arg) } /* ARGSUSED */ -void -ee_notsupp(ktent, arg) - struct keytabent *ktent; - char *arg; +static void +ee_notsupp(const struct keytabent *ktent, char *arg) { warnx("field `%s' not yet supported", ktent->kt_keyword); } static void -badval(ktent, arg) - struct keytabent *ktent; - char *arg; +badval(const struct keytabent *ktent, char *arg) { warnx("inappropriate value `%s' for field `%s'", arg, @@ -535,11 +523,7 @@ badval(ktent, arg) } static int -doio(ktent, buf, len, wr) - struct keytabent *ktent; - u_char *buf; - ssize_t len; - int wr; +doio(const struct keytabent *ktent, u_char *buf, ssize_t len, int wr) { int fd, rval = 0; u_char *buf2; @@ -605,7 +589,7 @@ doio(ktent, buf, len, wr) * of it sequentially starting at eeWriteCount[0]. */ void -ee_updatechecksums() +ee_updatechecksums(void) { struct keytabent kt; u_char checkme[EE_SIZE - EE_HWUPDATE_LOC]; @@ -644,7 +628,7 @@ ee_updatechecksums() } void -ee_verifychecksums() +ee_verifychecksums(void) { struct keytabent kt; u_char checkme[EE_SIZE - EE_HWUPDATE_LOC]; @@ -728,10 +712,8 @@ ee_verifychecksums() ee_updatechecksums(); } -u_char -ee_checksum(area, len) - u_char *area; - size_t len; +static u_char +ee_checksum(u_char *area, size_t len) { u_char sum = 0; Index: src/usr.sbin/eeprom/main.c diff -u src/usr.sbin/eeprom/main.c:1.22 src/usr.sbin/eeprom/main.c:1.23 --- src/usr.sbin/eeprom/main.c:1.22 Fri Mar 15 20:22:44 2013 +++ src/usr.sbin/eeprom/main.c Tue Jul 2 11:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.22 2013/03/15 20:22:44 nakayama Exp $ */ +/* $NetBSD: main.c,v 1.23 2013/07/02 11:59:46 joerg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1996\ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: main.c,v 1.22 2013/03/15 20:22:44 nakayama Exp $"); +__RCSID("$NetBSD: main.c,v 1.23 2013/07/02 11:59:46 joerg Exp $"); #endif #include <sys/param.h> @@ -59,10 +59,9 @@ __RCSID("$NetBSD: main.c,v 1.22 2013/03/ # endif #endif -int main (int, char *[]); -static void action (char *); -static void dump_prom (void); -static void usage (void); +static void action(char *); +static void dump_prom(void); +static void usage(void) __dead; const char *path_eeprom = _PATH_EEPROM; const char *path_openprom = _PATH_OPENPROM; @@ -83,9 +82,7 @@ int verbose=0; #endif int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int ch, do_stdin = 0; char *cp, line[BUFSIZE]; @@ -182,8 +179,7 @@ main(argc, argv) * the table, and call the corresponding handler function. */ static void -action(line) - char *line; +action(char *line) { char *keyword, *arg; @@ -214,7 +210,7 @@ action(line) * Dump the contents of the prom corresponding to all known keywords. */ static void -dump_prom() +dump_prom(void) { #ifdef USE_PREPNVRAM @@ -239,8 +235,8 @@ dump_prom() #endif /* USE_PREPNVRAM */ } -static void -usage() +__dead static void +usage(void) { #if defined(USE_OPENPROM) || defined(USE_OPENFIRM) || defined(USE_PREPNVRAM) Index: src/usr.sbin/eeprom/ofhandlers.c diff -u src/usr.sbin/eeprom/ofhandlers.c:1.5 src/usr.sbin/eeprom/ofhandlers.c:1.6 --- src/usr.sbin/eeprom/ofhandlers.c:1.5 Tue Jan 4 09:25:21 2011 +++ src/usr.sbin/eeprom/ofhandlers.c Tue Jul 2 11:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ofhandlers.c,v 1.5 2011/01/04 09:25:21 wiz Exp $ */ +/* $NetBSD: ofhandlers.c,v 1.6 2013/07/02 11:59:46 joerg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -48,15 +48,15 @@ extern int verbose; static char err_str[BUFSIZE]; -static void of_notsupp (struct extabent *, struct ofiocdesc *, char *); -static void of_uint32h (struct extabent *, struct ofiocdesc *, char *); -static void of_uint32d (struct extabent *, struct ofiocdesc *, char *); +static void of_notsupp(const struct extabent *, struct ofiocdesc *, char *); +static void of_uint32h(const struct extabent *, struct ofiocdesc *, char *); +static void of_uint32d(const struct extabent *, struct ofiocdesc *, char *); /* * There are several known fields that I either don't know how to * deal with or require special treatment. */ -static struct extabent ofextab[] = { +static const struct extabent ofextab[] = { { "security-password", of_notsupp }, { "security-mode", of_notsupp }, { "oem-logo", of_notsupp }, @@ -79,8 +79,7 @@ static struct extabent ofextab[] = { }; void -of_action(keyword, arg) - char *keyword, *arg; +of_action(char *keyword, char *arg) { char *cp; @@ -90,11 +89,10 @@ of_action(keyword, arg) } char * -of_handler(keyword, arg) - char *keyword, *arg; +of_handler(char *keyword, char *arg) { struct ofiocdesc ofio; - struct extabent *ex; + const struct extabent *ex; char ofio_buf[BUFSIZE]; int fd, optnode; @@ -184,30 +182,21 @@ of_handler(keyword, arg) /* ARGSUSED */ static void -of_notsupp(exent, ofiop, arg) - struct extabent *exent; - struct ofiocdesc *ofiop; - char *arg; +of_notsupp(const struct extabent *exent, struct ofiocdesc *ofiop, char *arg) { warnx("property `%s' not yet supported", exent->ex_keyword); } static void -of_uint32h(exent, ofiop, arg) - struct extabent *exent; - struct ofiocdesc *ofiop; - char *arg; +of_uint32h(const struct extabent *exent, struct ofiocdesc *ofiop, char *arg) { printf("%s=0x%08x\n", exent->ex_keyword, *(uint32_t *)ofiop->of_buf); } static void -of_uint32d(exent, ofiop, arg) - struct extabent *exent; - struct ofiocdesc *ofiop; - char *arg; +of_uint32d(const struct extabent *exent, struct ofiocdesc *ofiop, char *arg) { printf("%s=%d\n", exent->ex_keyword, *(uint32_t *)ofiop->of_buf); @@ -218,10 +207,10 @@ of_uint32d(exent, ofiop, arg) * (Really! This is the only way I could get it to work!) */ void -of_dump() +of_dump(void) { struct ofiocdesc ofio1, ofio2; - struct extabent *ex; + const struct extabent *ex; char buf1[BUFSIZE], buf2[BUFSIZE], buf3[BUFSIZE], buf4[BUFSIZE]; int fd, optnode; Index: src/usr.sbin/eeprom/ophandlers.c diff -u src/usr.sbin/eeprom/ophandlers.c:1.12 src/usr.sbin/eeprom/ophandlers.c:1.13 --- src/usr.sbin/eeprom/ophandlers.c:1.12 Fri Mar 15 20:22:44 2013 +++ src/usr.sbin/eeprom/ophandlers.c Tue Jul 2 11:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ophandlers.c,v 1.12 2013/03/15 20:22:44 nakayama Exp $ */ +/* $NetBSD: ophandlers.c,v 1.13 2013/07/02 11:59:46 joerg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -49,13 +49,13 @@ extern int verbose; static char err_str[BUFSIZE]; -static void op_notsupp (struct extabent *, struct opiocdesc *, char *); +static void op_notsupp (const struct extabent *, struct opiocdesc *, char *); /* * There are several known fields that I either don't know how to * deal with or require special treatment. */ -static struct extabent opextab[] = { +static const struct extabent opextab[] = { { "security-password", op_notsupp }, { "security-mode", op_notsupp }, { "oem-logo", op_notsupp }, @@ -69,8 +69,7 @@ static struct extabent opextab[] = { }; void -op_action(keyword, arg) - char *keyword, *arg; +op_action(char *keyword, char *arg) { char *cp; @@ -80,7 +79,7 @@ op_action(keyword, arg) } int -check_for_openprom() +check_for_openprom(void) { int fd, rv, optnode; @@ -96,11 +95,10 @@ check_for_openprom() } char * -op_handler(keyword, arg) - char *keyword, *arg; +op_handler(char *keyword, char *arg) { struct opiocdesc opio; - struct extabent *ex; + const struct extabent *ex; char opio_buf[BUFSIZE]; int fd, optnode; @@ -190,10 +188,7 @@ op_handler(keyword, arg) /* ARGSUSED */ static void -op_notsupp(exent, opiop, arg) - struct extabent *exent; - struct opiocdesc *opiop; - char *arg; +op_notsupp(const struct extabent *exent, struct opiocdesc *opiop, char *arg) { warnx("property `%s' not yet supported", exent->ex_keyword); @@ -204,10 +199,10 @@ op_notsupp(exent, opiop, arg) * (Really! This is the only way I could get it to work!) */ void -op_dump() +op_dump(void) { struct opiocdesc opio1, opio2; - struct extabent *ex; + const struct extabent *ex; char buf1[BUFSIZE], buf2[BUFSIZE], buf3[BUFSIZE], buf4[BUFSIZE]; int fd, optnode; Index: src/usr.sbin/eeprom/prephandlers.c diff -u src/usr.sbin/eeprom/prephandlers.c:1.3 src/usr.sbin/eeprom/prephandlers.c:1.4 --- src/usr.sbin/eeprom/prephandlers.c:1.3 Tue Jan 4 09:25:21 2011 +++ src/usr.sbin/eeprom/prephandlers.c Tue Jul 2 11:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: prephandlers.c,v 1.3 2011/01/04 09:25:21 wiz Exp $ */ +/* $NetBSD: prephandlers.c,v 1.4 2013/07/02 11:59:46 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -49,7 +49,7 @@ extern int verbose; static char err_str[BUFSIZE]; -static void prep_notsupp(struct extabent *, struct pnviocdesc *, char *); +static void prep_notsupp(const struct extabent *, struct pnviocdesc *, char *); /* * XXX @@ -65,7 +65,7 @@ static void prep_notsupp(struct extabent * There are several known fields that I either don't know how to * deal with or require special treatment. */ -static struct extabent prepextab[] = { +static const struct extabent prepextab[] = { {NULL, prep_notsupp}, }; #define BARF(str1, str2) { \ @@ -88,7 +88,7 @@ char * prep_handler(char *keyword, char *arg) { struct pnviocdesc nvio; - struct extabent *ex; + const struct extabent *ex; char nvio_buf[BUFSIZE]; int fd; @@ -169,7 +169,7 @@ out: } /* ARGSUSED */ static void -prep_notsupp(struct extabent * exent, struct pnviocdesc * nviop, char *arg) +prep_notsupp(const struct extabent * exent, struct pnviocdesc * nviop, char *arg) { warnx("property `%s' not yet supported", exent->ex_keyword); @@ -180,7 +180,7 @@ prep_notsupp(struct extabent * exent, st */ void -prep_dump() +prep_dump(void) { struct pnviocdesc nvio1, nvio2; char buf1[BUFSIZE], buf2[BUFSIZE], buf3[BUFSIZE], buf4[BUFSIZE];