From: deraadt Date: Thu, 12 Dec 1996 20:32:17 +0000 (+0000) Subject: fix a typical use; -Wall X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9f9bbac1c464b7ff073ede67ecfe7cd4e85d1abd;p=openbsd fix a typical use; -Wall --- diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c index ab086a1a254..e3fcdb3d51f 100644 --- a/usr.sbin/repquota/repquota.c +++ b/usr.sbin/repquota/repquota.c @@ -42,7 +42,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)repquota.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: repquota.c,v 1.7 1996/05/04 12:30:21 deraadt Exp $"; +static char *rcsid = "$Id: repquota.c,v 1.8 1996/12/12 20:32:17 deraadt Exp $"; #endif /* not lint */ /* @@ -55,6 +55,7 @@ static char *rcsid = "$Id: repquota.c,v 1.7 1996/05/04 12:30:21 deraadt Exp $"; #include #include #include +#include #include #include @@ -64,7 +65,7 @@ char *qfextension[] = INITQFNAMES; struct fileusage { struct fileusage *fu_next; struct dqblk fu_dqblk; - u_long fu_id; + uid_t fu_id; char fu_name[1]; /* actually bigger */ }; @@ -72,11 +73,17 @@ struct fileusage { struct fileusage *fuhead[MAXQUOTAS][FUHASH]; struct fileusage *lookup(); struct fileusage *addid(); -u_long highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */ +uid_t highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */ int vflag; /* verbose */ int aflag; /* all file systems */ +void usage __P((void)); +int repquota __P((struct fstab *, int, char *)); +int hasquota __P((struct fstab *, int, char **)); +int oneof __P((char *, char *[], int)); + +int main(argc, argv) int argc; char **argv; @@ -121,13 +128,13 @@ main(argc, argv) if (gflag) { setgrent(); while ((gr = getgrent()) != 0) - (void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name); + (void) addid((uid_t)gr->gr_gid, GRPQUOTA, gr->gr_name); endgrent(); } if (uflag) { setpwent(); while ((pw = getpwent()) != 0) - (void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name); + (void) addid(pw->pw_uid, USRQUOTA, pw->pw_name); endpwent(); } setfsent(); @@ -146,9 +153,9 @@ main(argc, argv) if ((argnum = oneof(fs->fs_file, argv, argc)) >= 0 || (argnum = oneof(fs->fs_spec, argv, argc)) >= 0) { done |= 1 << argnum; - if (gflag) + if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) errs += repquota(fs, GRPQUOTA, qfnp); - if (uflag) + if (uflag && hasquota(fs, GRPQUOTA, &qfnp)) errs += repquota(fs, USRQUOTA, qfnp); } } @@ -159,6 +166,7 @@ main(argc, argv) exit(errs); } +void usage() { fprintf(stderr, "Usage:\n\t%s\n\t%s\n", @@ -167,6 +175,7 @@ usage() exit(1); } +int repquota(fs, type, qfpathname) register struct fstab *fs; int type; @@ -174,7 +183,7 @@ repquota(fs, type, qfpathname) { register struct fileusage *fup; FILE *qf; - u_long id; + uid_t id; struct dqblk dqbuf; char *timeprt(); static struct dqblk zerodqblk; @@ -248,6 +257,7 @@ repquota(fs, type, qfpathname) /* * Check to see if target appears in list of size cnt. */ +int oneof(target, list, cnt) register char *target, *list[]; int cnt; @@ -263,6 +273,7 @@ oneof(target, list, cnt) /* * Check to see if a particular quota is to be enabled. */ +int hasquota(fs, type, qfnamep) register struct fstab *fs; int type; @@ -280,7 +291,7 @@ hasquota(fs, type, qfnamep) } strcpy(buf, fs->fs_mntops); for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { - if (cp = index(opt, '=')) + if ((cp = index(opt, '='))) *cp++ = '\0'; if (type == USRQUOTA && strcmp(opt, usrname) == 0) break; @@ -305,7 +316,7 @@ hasquota(fs, type, qfnamep) */ struct fileusage * lookup(id, type) - u_long id; + uid_t id; int type; { register struct fileusage *fup; @@ -321,7 +332,7 @@ lookup(id, type) */ struct fileusage * addid(id, type, name) - u_long id; + uid_t id; int type; char *name; { @@ -329,7 +340,7 @@ addid(id, type, name) int len; extern char *calloc(); - if (fup = lookup(id, type)) + if ((fup = lookup(id, type))) return (fup); if (name) len = strlen(name); @@ -360,7 +371,7 @@ char * timeprt(seconds) time_t seconds; { - time_t hours, minutes; + int hours, minutes; static char buf[20]; static time_t now;