From: Sascha Wildner Date: Fri, 27 Mar 2009 20:57:11 +0000 (+0100) Subject: mknetid(8): Raise WARNS to 6 and fix warnings (also -Wold-style-definition). X-Git-Tag: v2.3.1~186 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/06a0ed233a21beb5ae9be7c9ac623cdcee4077e3 mknetid(8): Raise WARNS to 6 and fix warnings (also -Wold-style-definition). --- diff --git a/libexec/mknetid/Makefile b/libexec/mknetid/Makefile index 30647afbf8..0c873d5472 100644 --- a/libexec/mknetid/Makefile +++ b/libexec/mknetid/Makefile @@ -3,6 +3,7 @@ PROG= mknetid SRCS= mknetid.c hash.c parse_group.c +WARNS?= 6 MAN= netid.5 mknetid.8 diff --git a/libexec/mknetid/hash.c b/libexec/mknetid/hash.c index 04c003e5f3..d7c8d6e91c 100644 --- a/libexec/mknetid/hash.c +++ b/libexec/mknetid/hash.c @@ -48,14 +48,12 @@ /* * OZ's original sdbm hash */ -u_int32_t -hash(keyarg, len) - const void *keyarg; - register size_t len; +static u_int32_t +hash(const void *keyarg, size_t len) { - register const u_char *key; - register size_t loop; - register u_int32_t h; + const u_char *key; + size_t loop; + u_int32_t h; #define HASHC h = *key++ + 65599 * h @@ -100,8 +98,8 @@ hash(keyarg, len) * We mask off all but the lower 8 bits since our table array * can only hole 256 elements. */ -u_int32_t hashkey(key) - char *key; +static u_int32_t +hashkey(char *key) { if (key == NULL) @@ -110,9 +108,8 @@ u_int32_t hashkey(key) } /* Find an entry in the hash table (may be hanging off a linked list). */ -struct grouplist *lookup(table, key) - struct member_entry *table[]; - char *key; +struct grouplist * +lookup(struct member_entry *table[], char *key) { struct member_entry *cur; @@ -132,14 +129,11 @@ struct grouplist dummy = { 99999, NULL }; /* * Store an group member entry and/or update its grouplist. */ -void mstore (table, key, gid, dup) - struct member_entry *table[]; - char *key; - int gid; - int dup; +void +mstore(struct member_entry *table[], char *key, int gid, int dup) { struct member_entry *cur, *new; - struct grouplist *tmp; + struct grouplist *tmp = NULL; u_int32_t i; i = hashkey(key); diff --git a/libexec/mknetid/mknetid.c b/libexec/mknetid/mknetid.c index d37e659e19..c9b86f0d97 100644 --- a/libexec/mknetid/mknetid.c +++ b/libexec/mknetid/mknetid.c @@ -60,13 +60,13 @@ #define OPSYS "unix" /* Default location of group file. */ -char *groupfile = _PATH_GROUP; +const char *groupfile = _PATH_GROUP; /* Default location of master.passwd file. */ -char *passfile = _PATH_PASSWD; +const char *passfile = _PATH_PASSWD; /* Default location of hosts file. */ -char *hostsfile = _PATH_HOSTS; +const char *hostsfile = _PATH_HOSTS; /* Default location of netid file */ -char *netidfile = "/etc/netid"; +const char *netidfile = "/etc/netid"; /* * Stored hash table of 'reverse' group member database @@ -85,7 +85,7 @@ extern int _setgrent ( void ); extern void _endgrent ( void ); static void -usage() +usage(void) { fprintf (stderr, "%s\n%s\n", "usage: mknetid [-q] [-g group_file] [-p passwd_file] [-h hosts_file]", @@ -96,9 +96,7 @@ usage() extern FILE *_gr_fp; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { FILE *gfp, *pfp, *hfp, *nfp; char readbuf[LINSIZ]; diff --git a/libexec/mknetid/parse_group.c b/libexec/mknetid/parse_group.c index 8482b0be2d..4e90f6a062 100644 --- a/libexec/mknetid/parse_group.c +++ b/libexec/mknetid/parse_group.c @@ -46,10 +46,14 @@ #include #include +struct group *_getgrent(void); +int _setgrent(void); +void _endgrent(void); FILE *_gr_fp; + static struct group _gr_group; static int _gr_stayopen; -static int grscan(), start_gr(); +static int grscan(int, gid_t, char *), start_gr(void); #define MAXGRP 200 static char *members[MAXGRP]; @@ -57,7 +61,7 @@ static char *members[MAXGRP]; static char line[MAXLINELENGTH]; struct group * -_getgrent() +_getgrent(void) { if (!_gr_fp && !start_gr()) { return NULL; @@ -70,14 +74,13 @@ _getgrent() } static int -start_gr() +start_gr(void) { return 1; } -int -_setgroupent(stayopen) - int stayopen; +static int +_setgroupent(int stayopen) { if (!start_gr()) return(0); @@ -86,13 +89,13 @@ _setgroupent(stayopen) } int -_setgrent() +_setgrent(void) { return(_setgroupent(0)); } void -_endgrent() +_endgrent(void) { if (_gr_fp) { (void)fclose(_gr_fp); @@ -101,11 +104,9 @@ _endgrent() } static int -grscan(search, gid, name) - register int search, gid; - register char *name; +grscan(int search, gid_t gid, char *name) { - register char *cp, **m; + char *cp, **m; char *bp; for (;;) { if (!fgets(line, sizeof(line), _gr_fp))