Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/hfs Small cleanup:
details: https://anonhg.NetBSD.org/src/rev/8b6142123f1a
branches: trunk
changeset: 335191:8b6142123f1a
user: maxv <maxv%NetBSD.org@localhost>
date: Mon Dec 29 17:17:54 2014 +0000
description:
Small cleanup:
- KNF
- malloc + memset -> malloc(|M_ZERO)
- no need to check data == NULL
diffstat:
sys/fs/hfs/hfs_vfsops.c | 104 ++++++++++++++++++++---------------------------
1 files changed, 44 insertions(+), 60 deletions(-)
diffs (truncated from 377 to 300 lines):
diff -r 42024e3108e7 -r 8b6142123f1a sys/fs/hfs/hfs_vfsops.c
--- a/sys/fs/hfs/hfs_vfsops.c Mon Dec 29 17:02:39 2014 +0000
+++ b/sys/fs/hfs/hfs_vfsops.c Mon Dec 29 17:17:54 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken Exp $ */
+/* $NetBSD: hfs_vfsops.c,v 1.33 2014/12/29 17:17:54 maxv Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.33 2014/12/29 17:17:54 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -174,13 +174,12 @@
};
static const struct genfs_ops hfs_genfsops = {
- .gop_size = genfs_size,
+ .gop_size = genfs_size,
};
static int
hfs_modcmd(modcmd_t cmd, void *arg)
{
-
switch (cmd) {
case MODULE_CMD_INIT:
return vfs_attach(&hfs_vfsops);
@@ -207,10 +206,10 @@
if (*data_len < sizeof *args)
return EINVAL;
-#ifdef HFS_DEBUG
+#ifdef HFS_DEBUG
printf("vfsop = hfs_mount()\n");
#endif /* HFS_DEBUG */
-
+
if (mp->mnt_flag & MNT_GETARGS) {
hmp = VFSTOHFS(mp);
if (hmp == NULL)
@@ -220,9 +219,6 @@
return 0;
}
- if (data == NULL)
- return EINVAL;
-
/* FIXME: For development ONLY - disallow remounting for now */
#if 0
update = mp->mnt_flag & MNT_UPDATE;
@@ -239,7 +235,7 @@
NSM_FOLLOW_NOEMULROOT, &devvp);
if (error != 0)
return error;
-
+
if (!update) {
/*
* Be sure this is a valid block device
@@ -269,7 +265,6 @@
}
}
-
/*
* If mount by non-root, then verify that user has necessary
* permissions on the device.
@@ -302,14 +297,14 @@
if ((error = hfs_mountfs(devvp, mp, l, args->fspec)) != 0)
goto error;
-
+
error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
mp->mnt_op->vfs_name, mp, l);
#ifdef HFS_DEBUG
if(!update) {
char* volname;
-
+
hmp = VFSTOHFS(mp);
volname = malloc(hmp->hm_vol.name.length + 1, M_TEMP, M_WAITOK);
if (volname == NULL)
@@ -324,9 +319,9 @@
}
}
#endif /* HFS_DEBUG */
-
+
return error;
-
+
error:
vrele(devvp);
return error;
@@ -335,8 +330,7 @@
int
hfs_start(struct mount *mp, int flags)
{
-
-#ifdef HFS_DEBUG
+#ifdef HFS_DEBUG
printf("vfsop = hfs_start()\n");
#endif /* HFS_DEBUG */
@@ -353,20 +347,18 @@
struct hfsmount *hmp;
kauth_cred_t cred;
int error;
-
+
cred = l ? l->l_cred : NOCRED;
error = 0;
hmp = NULL;
/* Create mounted volume structure. */
- hmp = (struct hfsmount*)malloc(sizeof(struct hfsmount),
- M_HFSMNT, M_WAITOK);
+ hmp = malloc(sizeof(struct hfsmount), M_HFSMNT, M_WAITOK|M_ZERO);
if (hmp == NULL) {
error = ENOMEM;
goto error;
}
- memset(hmp, 0, sizeof(struct hfsmount));
-
+
mp->mnt_data = hmp;
mp->mnt_flag |= MNT_LOCAL;
vfs_getnewfsid(mp);
@@ -374,12 +366,12 @@
hmp->hm_mountp = mp;
hmp->hm_dev = devvp->v_rdev;
hmp->hm_devvp = devvp;
-
+
/*
* Use libhfs to open the volume and read the volume header and other
* useful information.
*/
-
+
hfslib_init_cbargs(&cbargs);
argsopen.cred = argsread.cred = cred;
argsopen.l = argsread.l = l;
@@ -390,7 +382,7 @@
if ((error = hfslib_open_volume(devpath, mp->mnt_flag & MNT_RDONLY,
&hmp->hm_vol, &cbargs)) != 0)
goto error;
-
+
/* Make sure this is not a journaled volume whose journal is dirty. */
if (!hfslib_is_journal_clean(&hmp->hm_vol)) {
printf("volume journal is dirty; not mounting\n");
@@ -399,16 +391,15 @@
}
mp->mnt_fs_bshift = 0;
- while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size)
+ while ((1 << mp->mnt_fs_bshift) < hmp->hm_vol.vh.block_size)
mp->mnt_fs_bshift++;
mp->mnt_dev_bshift = DEV_BSHIFT;
return 0;
-
+
error:
if (hmp != NULL)
free(hmp, M_HFSMNT);
-
return error;
}
@@ -420,17 +411,17 @@
struct hfsmount* hmp;
int error;
int flags;
-
-#ifdef HFS_DEBUG
+
+#ifdef HFS_DEBUG
printf("vfsop = hfs_unmount()\n");
#endif /* HFS_DEBUG */
hmp = VFSTOHFS(mp);
-
+
flags = 0;
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
-
+
if ((error = vflush(mp, NULLVP, flags)) != 0)
return error;
@@ -438,13 +429,13 @@
argsclose.l = curlwp;
cbargs.closevol = (void*)&argsclose;
hfslib_close_volume(&hmp->hm_vol, &cbargs);
-
+
vrele(hmp->hm_devvp);
free(hmp, M_HFSMNT);
mp->mnt_data = NULL;
mp->mnt_flag &= ~MNT_LOCAL;
-
+
return error;
}
@@ -454,14 +445,14 @@
struct vnode *nvp;
int error;
-#ifdef HFS_DEBUG
+#ifdef HFS_DEBUG
printf("vfsop = hfs_root()\n");
#endif /* HFS_DEBUG */
-
+
if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, &nvp)) != 0)
return error;
*vpp = nvp;
-
+
return 0;
}
@@ -469,13 +460,13 @@
hfs_statvfs(struct mount *mp, struct statvfs *sbp)
{
hfs_volume_header_t *vh;
-
-#ifdef HFS_DEBUG
+
+#ifdef HFS_DEBUG
printf("vfsop = hfs_statvfs()\n");
#endif /* HFS_DEBUG */
vh = &VFSTOHFS(mp)->hm_vol.vh;
-
+
sbp->f_bsize = vh->block_size;
sbp->f_frsize = sbp->f_bsize;
sbp->f_iosize = 4096;/* mac os x uses a 4 kb io size, so do the same */
@@ -486,15 +477,14 @@
sbp->f_files = vh->file_count; /* total files */
sbp->f_ffree = (1<<31) - vh->file_count; /* free file nodes */
copy_statvfs_info(sbp, mp);
-
+
return 0;
}
int
hfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
{
-
-#ifdef HFS_DEBUG
+#ifdef HFS_DEBUG
printf("vfsop = hfs_sync()\n");
#endif /* HFS_DEBUG */
@@ -550,7 +540,7 @@
hfs_catalog_key_t cat_key; /* the search key used to find this file on disk */
dev_t dev;
-#ifdef HFS_DEBUG
+#ifdef HFS_DEBUG
printf("vfsop = hfs_loadvnode()\n");
#endif /* HFS_DEBUG */
@@ -574,13 +564,13 @@
* Read catalog record from disk.
*/
hfslib_init_cbargs(&cbargs);
-
+
if (hfslib_find_catalog_record_with_cnid(&hmp->hm_vol, hfskey.hnk_cnid,
&rec, &cat_key, &cbargs) != 0) {
pool_put(&hfs_node_pool, hnode);
return EBADF;
}
-
+
memcpy(&hnode->h_rec, &rec, sizeof(hnode->h_rec));
hnode->h_parent = cat_key.parent_cnid;
@@ -594,7 +584,7 @@
vp->v_tag = VT_HFS;
vp->v_op = hfs_vnodeop_p;
- vp->v_vflag |= VV_LOCKSWORK;
Home |
Main Index |
Thread Index |
Old Index