Module Name: src Committed By: christos Date: Sun Mar 6 23:25:43 UTC 2011
Modified Files: src/usr.sbin/quotacheck: quotacheck.c src/usr.sbin/repquota: repquota.c Log Message: more code deduplication To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/quotacheck/quotacheck.c cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/repquota/repquota.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/quotacheck/quotacheck.c diff -u src/usr.sbin/quotacheck/quotacheck.c:1.43 src/usr.sbin/quotacheck/quotacheck.c:1.44 --- src/usr.sbin/quotacheck/quotacheck.c:1.43 Sun Mar 6 18:13:22 2011 +++ src/usr.sbin/quotacheck/quotacheck.c Sun Mar 6 18:25:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: quotacheck.c,v 1.43 2011/03/06 23:13:22 christos Exp $ */ +/* $NetBSD: quotacheck.c,v 1.44 2011/03/06 23:25:42 christos Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)quotacheck.c 8.6 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: quotacheck.c,v 1.43 2011/03/06 23:13:22 christos Exp $"); +__RCSID("$NetBSD: quotacheck.c,v 1.44 2011/03/06 23:25:42 christos Exp $"); #endif #endif /* not lint */ @@ -153,7 +153,6 @@ static int chkquota(const char *, const char *, const char *, void *, pid_t *); static int update(const char *, const char *, int); static uint32_t skipforward(uint32_t, uint32_t, FILE *); -static int oneof(const char *, char *[], int); static int getquotagid(void); static struct fileusage *lookup(uint32_t, int); static struct fileusage *addid(uint32_t, int, const char *); @@ -627,20 +626,6 @@ } /* - * Check to see if target appears in list of size cnt. - */ -static int -oneof(const char *target, char *list[], int cnt) -{ - int i; - - for (i = 0; i < cnt; i++) - if (strcmp(target, list[i]) == 0) - return (i); - return (-1); -} - -/* * Determine the group identifier for quota files. */ static int Index: src/usr.sbin/repquota/repquota.c diff -u src/usr.sbin/repquota/repquota.c:1.27 src/usr.sbin/repquota/repquota.c:1.28 --- src/usr.sbin/repquota/repquota.c:1.27 Sun Mar 6 17:33:55 2011 +++ src/usr.sbin/repquota/repquota.c Sun Mar 6 18:25:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: repquota.c,v 1.27 2011/03/06 22:33:55 christos Exp $ */ +/* $NetBSD: repquota.c,v 1.28 2011/03/06 23:25:42 christos Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)repquota.c 8.2 (Berkeley) 11/22/94"; #else -__RCSID("$NetBSD: repquota.c,v 1.27 2011/03/06 22:33:55 christos Exp $"); +__RCSID("$NetBSD: repquota.c,v 1.28 2011/03/06 23:25:42 christos Exp $"); #endif #endif /* not lint */ @@ -95,7 +95,6 @@ static struct fileusage *addid(uint32_t, int, const char *); static struct fileusage *lookup(uint32_t, int); static struct fileusage *qremove(uint32_t, int); -static int oneof(const char *, char **, int); static int repquota(const struct statvfs *, int); static int repquota2(const struct statvfs *, int); static int repquota1(const struct statvfs *, int); @@ -525,20 +524,6 @@ } /* - * Check to see if target appears in list of size cnt. - */ -static int -oneof(const char *target, char *list[], int cnt) -{ - int i; - - for (i = 0; i < cnt; i++) - if (strcmp(target, list[i]) == 0) - return i; - return -1; -} - -/* * Routines to manage the file usage table. * * Lookup an id of a specific type. @@ -619,7 +604,7 @@ if (name) { memmove(fup->fu_name, name, len + 1); } else { - snprintf(fup->fu_name, sizeof(fup->fu_name), "%u", id); + snprintf(fup->fu_name, len + 1, "%u", id); } fup->fu_q2e = defaultq2e[type]; return fup;