Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin more code deduplication



details:   https://anonhg.NetBSD.org/src/rev/bd2c93fa46b8
branches:  trunk
changeset: 762977:bd2c93fa46b8
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Mar 06 23:25:42 2011 +0000

description:
more code deduplication

diffstat:

 usr.sbin/quotacheck/quotacheck.c |  19 ++-----------------
 usr.sbin/repquota/repquota.c     |  21 +++------------------
 2 files changed, 5 insertions(+), 35 deletions(-)

diffs (103 lines):

diff -r 1815aace9010 -r bd2c93fa46b8 usr.sbin/quotacheck/quotacheck.c
--- a/usr.sbin/quotacheck/quotacheck.c  Sun Mar 06 23:24:33 2011 +0000
+++ b/usr.sbin/quotacheck/quotacheck.c  Sun Mar 06 23:25:42 2011 +0000
@@ -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
diff -r 1815aace9010 -r bd2c93fa46b8 usr.sbin/repquota/repquota.c
--- a/usr.sbin/repquota/repquota.c      Sun Mar 06 23:24:33 2011 +0000
+++ b/usr.sbin/repquota/repquota.c      Sun Mar 06 23:25:42 2011 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index