Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/ntfs Make this more readable (KNF).



details:   https://anonhg.NetBSD.org/src/rev/932ded843f3c
branches:  trunk
changeset: 805307:932ded843f3c
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Dec 28 14:42:56 2014 +0000

description:
Make this more readable (KNF).

diffstat:

 sys/fs/ntfs/ntfs_subr.c |  448 +++++++++++++++++++----------------------------
 1 files changed, 182 insertions(+), 266 deletions(-)

diffs (truncated from 968 to 300 lines):

diff -r 06411b08f567 -r 932ded843f3c sys/fs/ntfs/ntfs_subr.c
--- a/sys/fs/ntfs/ntfs_subr.c   Sun Dec 28 14:13:56 2014 +0000
+++ b/sys/fs/ntfs/ntfs_subr.c   Sun Dec 28 14:42:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_subr.c,v 1.54 2014/11/13 16:51:53 hannken Exp $   */
+/*     $NetBSD: ntfs_subr.c,v 1.55 2014/12/28 14:42:56 maxv Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.54 2014/11/13 16:51:53 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.55 2014/12/28 14:42:56 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -95,17 +95,12 @@
   (aalp->al_type == type) && (aalp->al_namelen == namelen) &&          \
   !ntfs_uastrcmp(ntmp, aalp->al_name,aalp->al_namelen,name,namelen) )
 
-/*
- *
- */
 int
-ntfs_ntvattrrele(struct ntvattr * vap)
+ntfs_ntvattrrele(struct ntvattr *vap)
 {
        dprintf(("%s: ino: %llu, type: 0x%x\n", __func__,
            (unsigned long long)vap->va_ip->i_number, vap->va_type));
-
        ntfs_ntrele(vap->va_ip);
-
        return (0);
 }
 
@@ -113,12 +108,14 @@
  * find the attribute in the ntnode
  */
 static int
-ntfs_findvattr(struct ntfsmount *ntmp, struct ntnode *ip, struct ntvattr **lvapp, struct ntvattr **vapp, u_int32_t type, const char *name, size_t namelen, cn_t vcn)
+ntfs_findvattr(struct ntfsmount *ntmp, struct ntnode *ip, struct ntvattr **lvapp,
+    struct ntvattr **vapp, u_int32_t type, const char *name, size_t namelen,
+    cn_t vcn)
 {
        int error;
        struct ntvattr *vap;
 
-       if((ip->i_flag & IN_LOADED) == 0) {
+       if ((ip->i_flag & IN_LOADED) == 0) {
                dprintf(("%s: node not loaded, ino: %llu\n", __func__,
                    (unsigned long long)ip->i_number));
                error = ntfs_loadntnode(ntmp,ip);
@@ -133,8 +130,8 @@
        *vapp = NULL;
        for (vap = ip->i_valist.lh_first; vap; vap = vap->va_list.le_next) {
                ddprintf(("%s: type: 0x%x, vcn: %qu - %qu\n", __func__,
-                         vap->va_type, (long long) vap->va_vcnstart,
-                         (long long) vap->va_vcnend));
+                   vap->va_type, (long long) vap->va_vcnstart,
+                   (long long) vap->va_vcnend));
                if ((vap->va_type == type) &&
                    (vap->va_vcnstart <= vcn) && (vap->va_vcnend >= vcn) &&
                    (vap->va_namelen == namelen) &&
@@ -158,22 +155,17 @@
  * ntnode should be locked
  */
 int
-ntfs_ntvattrget(
-               struct ntfsmount * ntmp,
-               struct ntnode * ip,
-               u_int32_t type,
-               const char *name,
-               cn_t vcn,
-               struct ntvattr ** vapp)
+ntfs_ntvattrget(struct ntfsmount *ntmp, struct ntnode *ip, u_int32_t type,
+    const char *name, cn_t vcn, struct ntvattr **vapp)
 {
        struct ntvattr *lvap = NULL;
        struct attr_attrlist *aalp;
        struct attr_attrlist *nextaalp;
-       struct vnode   *newvp;
-       struct ntnode  *newip;
-       void *        alpool;
-       size_t          namelen, len;
-       int             error;
+       struct vnode *newvp;
+       struct ntnode *newip;
+       void *alpool;
+       size_t namelen, len;
+       int error;
 
        *vapp = NULL;
 
@@ -211,7 +203,7 @@
        aalp = (struct attr_attrlist *) alpool;
        nextaalp = NULL;
 
-       for(; len > 0; aalp = nextaalp) {
+       for (; len > 0; aalp = nextaalp) {
                KASSERT(aalp != NULL);
                dprintf(("%s: attrlist: ino: %d, attr: 0x%x, vcn: %qu\n",
                    __func__, aalp->al_inumber, aalp->al_type,
@@ -236,7 +228,7 @@
                                NTFS_A_DATA, "", LK_EXCLUSIVE, &newvp);
                if (error) {
                        printf("%s: CAN'T VGET INO: %d\n", __func__,
-                              aalp->al_inumber);
+                           aalp->al_inumber);
                        goto out;
                }
                newip = VTONT(newvp);
@@ -266,13 +258,11 @@
  * ntnode should be locked
  */
 int
-ntfs_loadntnode(
-             struct ntfsmount * ntmp,
-             struct ntnode * ip)
+ntfs_loadntnode(struct ntfsmount *ntmp, struct ntnode *ip)
 {
-       struct filerec  *mfrp;
-       int             error,off;
-       struct attr    *ap;
+       struct filerec *mfrp;
+       int error, off;
+       struct attr *ap;
        struct ntvattr *nvap;
 
        dprintf(("%s: loading ino: %llu\n", __func__,
@@ -281,9 +271,9 @@
        mfrp = malloc(ntfs_bntob(ntmp->ntm_bpmftrec), M_TEMP, M_WAITOK);
 
        if (ip->i_number < NTFS_SYSNODESNUM) {
-               struct buf     *bp;
-               daddr_t         bn;
-               off_t           boff;
+               struct buf *bp;
+               daddr_t bn;
+               off_t boff;
 
                dprintf(("%s: read system node\n", __func__));
 
@@ -297,7 +287,7 @@
                off = ntfs_btocnoff(boff);
 
                error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
-                             NOCRED, 0, &bp);
+                   NOCRED, 0, &bp);
                if (error) {
                        printf("%s: BREAD FAILED\n", __func__);
                        goto out;
@@ -310,8 +300,8 @@
 
                vp = ntmp->ntm_sysvn[NTFS_MFTINO];
                error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
-                              ip->i_number * ntfs_bntob(ntmp->ntm_bpmftrec),
-                              ntfs_bntob(ntmp->ntm_bpmftrec), mfrp, NULL);
+                   ip->i_number * ntfs_bntob(ntmp->ntm_bpmftrec),
+                   ntfs_bntob(ntmp->ntm_bpmftrec), mfrp, NULL);
                if (error) {
                        printf("%s: ntfs_readattr failed\n", __func__);
                        goto out;
@@ -323,7 +313,7 @@
                                ntfs_bntob(ntmp->ntm_bpmftrec));
        if (error) {
                printf("%s: BAD MFT RECORD %d\n", __func__,
-                      (u_int32_t) ip->i_number);
+                   (u_int32_t) ip->i_number);
                goto out;
        }
 
@@ -391,12 +381,9 @@
  * ntnode returned locked
  */
 int
-ntfs_ntlookup(
-          struct ntfsmount * ntmp,
-          ino_t ino,
-          struct ntnode ** ipp)
+ntfs_ntlookup(struct ntfsmount *ntmp, ino_t ino, struct ntnode **ipp)
 {
-       struct ntnode  *ip;
+       struct ntnode *ip;
 
        dprintf(("%s: looking for ntnode %llu\n", __func__,
            (unsigned long long)ino));
@@ -502,7 +489,6 @@
 
        dprintf(("%s: ino %llu, usecount: %d\n", __func__,
            (unsigned long long)ip->i_number, ip->i_usecount));
-
 }
 
 /*
@@ -527,7 +513,7 @@
  * Deallocate all memory allocated for ntvattr
  */
 void
-ntfs_freentvattr(struct ntvattr * vap)
+ntfs_freentvattr(struct ntvattr *vap)
 {
        if (vap->va_flag & NTFS_AF_INRUN) {
                if (vap->va_vruncn)
@@ -546,12 +532,10 @@
  * runs are expanded also.
  */
 int
-ntfs_attrtontvattr(
-                  struct ntfsmount * ntmp,
-                  struct ntvattr ** rvapp,
-                  struct attr * rap)
+ntfs_attrtontvattr(struct ntfsmount *ntmp, struct ntvattr **rvapp,
+   struct attr *rap)
 {
-       int             error, i;
+       int error, i;
        struct ntvattr *vap;
 
        error = 0;
@@ -585,8 +569,8 @@
                vap->va_vcnend = rap->a_nr.a_vcnend;
                vap->va_compressalg = rap->a_nr.a_compressalg;
                error = ntfs_runtovrun(&(vap->va_vruncn), &(vap->va_vruncl),
-                                      &(vap->va_vruncnt),
-                                      (u_int8_t *) rap + rap->a_nr.a_dataoff);
+                   &(vap->va_vruncnt),
+                   (u_int8_t *) rap + rap->a_nr.a_dataoff);
        } else {
                vap->va_compressalg = 0;
                ddprintf((", res."));
@@ -596,7 +580,7 @@
                vap->va_vcnend = ntfs_btocn(vap->va_allocated);
                vap->va_datap = malloc(vap->va_datalen, M_NTFSRDATA, M_WAITOK);
                memcpy(vap->va_datap, (char *)rap + rap->a_r.a_dataoff,
-                      rap->a_r.a_datalen);
+                   rap->a_r.a_datalen);
        }
        ddprintf((", len: %qu", (long long)vap->va_datalen));
 
@@ -614,19 +598,12 @@
  * Expand run into more utilizable and more memory eating format.
  */
 int
-ntfs_runtovrun(
-              cn_t ** rcnp,
-              cn_t ** rclp,
-              u_long * rcntp,
-              u_int8_t * run)
+ntfs_runtovrun(cn_t **rcnp, cn_t **rclp, u_long *rcntp, u_int8_t *run)
 {
-       u_int32_t       off;
-       u_int32_t       sz, i;
-       cn_t           *cn;
-       cn_t           *cl;
-       u_long          cnt;
-       cn_t            prev;
-       cn_t            tmp;
+       u_int32_t off, sz, i;
+       cn_t *cn, *cl;
+       u_long cnt;
+       cn_t prev, tmp;
 
        off = 0;
        cnt = 0;
@@ -642,7 +619,6 @@
        cnt = 0;
        prev = 0;
        while (run[off]) {
-
                sz = run[off++];
                cl[cnt] = 0;
 
@@ -676,9 +652,10 @@
  * Compare unicode and ascii string case insens.
  */
 static int
-ntfs_uastricmp(struct ntfsmount *ntmp, const wchar *ustr, size_t ustrlen, const char *astr, size_t astrlen)
+ntfs_uastricmp(struct ntfsmount *ntmp, const wchar *ustr, size_t ustrlen,
+    const char *astr, size_t astrlen)
 {
-       size_t  i;
+       size_t i;
        int res;
 
        for (i = 0; i < ustrlen && astrlen > 0; i++) {
@@ -700,14 +677,15 @@
  * Compare unicode and ascii string case sens.
  */
 static int
-ntfs_uastrcmp(struct ntfsmount *ntmp, const wchar *ustr, size_t ustrlen, const char *astr, size_t astrlen)
+ntfs_uastrcmp(struct ntfsmount *ntmp, const wchar *ustr, size_t ustrlen,
+    const char *astr, size_t astrlen)
 {
        size_t i;
        int res;
 
        for (i = 0; (i < ustrlen) && astrlen > 0; i++) {
                res = (*ntmp->ntm_wcmp)(ustr[i],



Home | Main Index | Thread Index | Old Index