Source-Changes-HG archive

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

[src/trunk]: src Rename static inline "helper" functions:



details:   https://anonhg.NetBSD.org/src/rev/f87634642d11
branches:  trunk
changeset: 773207:f87634642d11
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 07:16:00 2012 +0000

description:
Rename static inline "helper" functions:
   ufsclass2qtype -> quota_idtype_to_ufs
   qtype2ufsclass -> quota_idtype_from_ufs

The reason for the direction of "ufs" changing is that the old names
were among the symbols using "ufs" to mean "fs-independent". So the
old names were for translating "ufsclass" (fs-independent quota id
type) to "qtype" (ufs-specific quota id type) and vice versa.

These functions are used in only two places, both of which are
inappropriate, so at some point they should probably be removed.
They're also identity transformations so not particularly helpful,
unless one were to make a careful and concerted effort to distinguish
the ufs quota code numbers from the fs-independent ones. This has not
been done and is probably impossible without support from a program
verifier, and maybe not even then.

They are static inline, so no compat concerns arise.

Also adjust the symbols they use to avoid <quota/quotaprop.h>.

diffstat:

 sys/compat/common/vfs_syscalls_50.c |  20 +++++++++++++-------
 sys/ufs/ufs/quota.h                 |  20 ++++++++++----------
 usr.sbin/edquota/edquota.c          |   6 +++---
 3 files changed, 26 insertions(+), 20 deletions(-)

diffs (154 lines):

diff -r 6e664cb35d91 -r f87634642d11 sys/compat/common/vfs_syscalls_50.c
--- a/sys/compat/common/vfs_syscalls_50.c       Sun Jan 29 07:14:38 2012 +0000
+++ b/sys/compat/common/vfs_syscalls_50.c       Sun Jan 29 07:16:00 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_50.c,v 1.12 2012/01/29 06:29:04 dholland Exp $    */
+/*     $NetBSD: vfs_syscalls_50.c,v 1.13 2012/01/29 07:16:00 dholland Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.12 2012/01/29 06:29:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.13 2012/01/29 07:16:00 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -338,6 +338,7 @@
        struct dqblk dqblk;
        struct quotaval qv[QUOTA_NLIMITS];
        uint64_t *values[QUOTA_NLIMITS];
+       int idtype;
 
        values[QUOTA_LIMIT_BLOCK] = &qv[QUOTA_LIMIT_BLOCK].qv_hardlimit;
        values[QUOTA_LIMIT_FILE] = &qv[QUOTA_LIMIT_FILE].qv_hardlimit;
@@ -376,16 +377,18 @@
                error = ENOMEM;
                if (!prop_array_add_and_rel(datas, data))
                        goto out_datas;
+               idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
                if (!quota_prop_add_command(cmds, "quotaon",
-                   ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+                   ufs_quota_class_names[idtype],
                    datas))
                        goto out_cmds;
                goto do_quotaonoff;
 
        case Q_QUOTAOFF:
                error = ENOMEM;
+               idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
                if (!quota_prop_add_command(cmds, "quotaoff",
-                   ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+                   ufs_quota_class_names[idtype],
                    datas))
                        goto out_cmds;
 do_quotaonoff:
@@ -417,8 +420,9 @@
                        goto out_data;
                if (!prop_array_add_and_rel(datas, data))
                        goto out_datas;
+               idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
                if (!quota_prop_add_command(cmds, "get",
-                   ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+                   ufs_quota_class_names[idtype],
                    datas))
                        goto out_cmds;
                if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
@@ -473,8 +477,9 @@
                        goto out_data;
                if (!prop_array_add_and_rel(datas, data))
                        goto out_datas;
+               idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
                if (!quota_prop_add_command(cmds, "set",
-                   ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+                   ufs_quota_class_names[idtype],
                    datas))
                        goto out_cmds;
                if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
@@ -502,8 +507,9 @@
                 * emulate with a "get version"
                 */
                error = ENOMEM;
+               idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
                if (!quota_prop_add_command(cmds, "get version",
-                   ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+                   ufs_quota_class_names[idtype],
                    datas))
                        goto out_cmds;
                if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
diff -r 6e664cb35d91 -r f87634642d11 sys/ufs/ufs/quota.h
--- a/sys/ufs/ufs/quota.h       Sun Jan 29 07:14:38 2012 +0000
+++ b/sys/ufs/ufs/quota.h       Sun Jan 29 07:16:00 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quota.h,v 1.28 2011/03/25 10:25:17 bouyer Exp $        */
+/*     $NetBSD: quota.h,v 1.29 2012/01/29 07:16:00 dholland Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -55,14 +55,14 @@
 
 
 #if !defined(HAVE_NBTOOL_CONFIG_H)
-#include <quota/quotaprop.h>
+#include <sys/quota.h>
 __inline static int __unused
-ufsclass2qtype(int class)
+quota_idtype_to_ufs(int idtype)
 {
-       switch(class) {
-       case QUOTA_CLASS_USER:
+       switch (idtype) {
+       case QUOTA_IDTYPE_USER:
                return USRQUOTA;
-       case QUOTA_CLASS_GROUP:
+       case QUOTA_IDTYPE_GROUP:
                return GRPQUOTA;
        default:
                return -1;
@@ -70,13 +70,13 @@
 }
 
 static __inline int __unused
-qtype2ufsclass(int type)
+quota_idtype_from_ufs(int ufstype)
 {
-       switch(type) {
+       switch (ufstype) {
        case USRQUOTA:
-               return QUOTA_CLASS_USER;
+               return QUOTA_IDTYPE_USER;
        case GRPQUOTA:
-               return QUOTA_CLASS_GROUP;
+               return QUOTA_IDTYPE_GROUP;
        default:
                return -1;
        }
diff -r 6e664cb35d91 -r f87634642d11 usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c        Sun Jan 29 07:14:38 2012 +0000
+++ b/usr.sbin/edquota/edquota.c        Sun Jan 29 07:16:00 2012 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: edquota.c,v 1.42 2012/01/29 06:23:20 dholland Exp $ */
+/*      $NetBSD: edquota.c,v 1.43 2012/01/29 07:16:00 dholland Exp $ */
 /*
  * Copyright (c) 1980, 1990, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "from: @(#)edquota.c    8.3 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: edquota.c,v 1.42 2012/01/29 06:23:20 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.43 2012/01/29 07:16:00 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -288,7 +288,7 @@
                return NULL;
 
        if (!hasquota(qfpathname, sizeof(qfpathname), fs,
-           ufsclass2qtype(idtype)))
+           quota_idtype_to_ufs(idtype)))
                return NULL;
 
        qup = quotause_create();



Home | Main Index | Thread Index | Old Index