Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/hfs KNF
details: https://anonhg.NetBSD.org/src/rev/6818502f3e05
branches: trunk
changeset: 338992:6818502f3e05
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Jun 21 13:40:25 2015 +0000
description:
KNF
diffstat:
sys/fs/hfs/hfs_subr.c | 54 +-
sys/fs/hfs/libhfs.c | 1167 ++++++++++++++++++++++--------------------------
2 files changed, 569 insertions(+), 652 deletions(-)
diffs (truncated from 2555 to 300 lines):
diff -r 9ccf1cec738f -r 6818502f3e05 sys/fs/hfs/hfs_subr.c
--- a/sys/fs/hfs/hfs_subr.c Sun Jun 21 12:54:33 2015 +0000
+++ b/sys/fs/hfs/hfs_subr.c Sun Jun 21 13:40:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs_subr.c,v 1.18 2015/03/28 19:24:05 maxv Exp $ */
+/* $NetBSD: hfs_subr.c,v 1.19 2015/06/21 13:43:58 maxv Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_subr.c,v 1.18 2015/03/28 19:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_subr.c,v 1.19 2015/06/21 13:43:58 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -173,9 +173,9 @@
goto error;
}
vol->cbdata = cbdata;
-
+
cbdata->devvp = NULL;
-
+
/* Open the device node. */
mode = vol->readonly ? FREAD : FREAD|FWRITE;
vn_lock(args->devvp, LK_EXCLUSIVE | LK_RETRY);
@@ -200,7 +200,7 @@
cbdata->devblksz = DEV_BSIZE;
else
cbdata->devblksz = secsize;
-
+
return 0;
error:
@@ -222,10 +222,10 @@
hfs_libcb_closedev(hfs_volume* in_vol, hfs_callback_args* cbargs)
{
struct vnode *devvp;
-
+
if (in_vol == NULL)
return;
-
+
if (in_vol->cbdata != NULL) {
devvp = ((hfs_libcb_data*)in_vol->cbdata)->devvp;
if (devvp != NULL) {
@@ -252,10 +252,10 @@
hfs_libcb_argsread* argsread;
kauth_cred_t cred;
uint64_t physoffset; /* physical offset from start of device(?) */
-
+
if (vol == NULL || outbytes == NULL)
return -1;
-
+
cbdata = (hfs_libcb_data*)vol->cbdata;
if (cbargs != NULL
@@ -264,7 +264,7 @@
cred = argsread->cred;
else
cred = NOCRED;
-
+
/*
* Since bread() only reads data in terms of integral blocks, it may have
* read some data before and/or after our desired offset & length. So when
@@ -293,13 +293,13 @@
uint64_t curoff; /* relative to 'start' variable */
uint64_t start;
int error;
-
+
if (vp == NULL || buf == NULL)
return EINVAL;
-
+
if (len == 0)
return 0;
-
+
curoff = 0;
error = 0;
@@ -324,12 +324,12 @@
if (error == 0)
memcpy((uint8_t*)buf + curoff, (uint8_t*)bp->b_data +
(off - start), min(len - curoff, MAXBSIZE - (off - start)));
-
+
if (bp != NULL)
brelse(bp, 0);
if (error != 0)
return error;
-
+
curoff += MAXBSIZE;
}
#undef ABSZ
@@ -352,12 +352,12 @@
* precisely a 66 year difference between them, which is equal to
* 2,082,844,800 seconds. No, I didn't count them by hand.
*/
-
+
if (hfstime < 2082844800)
unixtime->tv_sec = 0; /* dates before 1970 are bs anyway, so use epoch*/
else
unixtime->tv_sec = hfstime - 2082844800;
-
+
unixtime->tv_nsec = 0; /* we don't have nanosecond resolution */
}
@@ -368,21 +368,20 @@
uint16_t be16tohp(void** inout_ptr)
{
uint16_t result;
-
- if(inout_ptr == NULL)
+
+ if (inout_ptr == NULL)
return 0;
-
+
memcpy(&result, *inout_ptr, sizeof(result));
*inout_ptr = (char *)*inout_ptr + sizeof(result);
-
return be16toh(result);
}
uint32_t be32tohp(void** inout_ptr)
{
uint32_t result;
-
- if(inout_ptr == NULL)
+
+ if (inout_ptr == NULL)
return 0;
memcpy(&result, *inout_ptr, sizeof(result));
@@ -393,8 +392,8 @@
uint64_t be64tohp(void** inout_ptr)
{
uint64_t result;
-
- if(inout_ptr == NULL)
+
+ if (inout_ptr == NULL)
return 0;
memcpy(&result, *inout_ptr, sizeof(result));
@@ -405,7 +404,7 @@
enum vtype
hfs_catalog_keyed_record_vtype(const hfs_catalog_keyed_record_t *rec)
{
- if (rec->type == HFS_REC_FILE) {
+ if (rec->type == HFS_REC_FILE) {
uint32_t mode;
mode = ((const hfs_file_record_t *)rec)->bsd.file_mode;
@@ -413,7 +412,6 @@
return IFTOVT(mode);
else
return VREG;
- }
- else
+ } else
return VDIR;
}
diff -r 9ccf1cec738f -r 6818502f3e05 sys/fs/hfs/libhfs.c
--- a/sys/fs/hfs/libhfs.c Sun Jun 21 12:54:33 2015 +0000
+++ b/sys/fs/hfs/libhfs.c Sun Jun 21 13:40:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libhfs.c,v 1.13 2014/12/29 17:02:39 maxv Exp $ */
+/* $NetBSD: libhfs.c,v 1.14 2015/06/21 13:40:25 maxv Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.13 2014/12/29 17:02:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.14 2015/06/21 13:40:25 maxv Exp $");
#include "libhfs.h"
@@ -359,7 +359,7 @@
error:
if (result != 0 && isopen)
hfslib_close_volume(out_vol, cbargs);
- if(buffer!=NULL)
+ if (buffer != NULL)
hfslib_free(buffer, cbargs);
return result;
}
@@ -425,36 +425,35 @@
memcpy(path + path_offset, parent_thread.name.unicode,
parent_thread.name.length*2);
-
- /* Add a forward slash. The unicode string was specified in big endian
- * format, so convert to core format if necessary. */
- path[512]=0x00;
- path[513]=0x2F;
+
+ /* Add a forward slash. The unicode string was specified in big endian
+ * format, so convert to core format if necessary. */
+ path[512] = 0x00;
+ path[513] = 0x2F;
ptr = (uint16_t*)path + 256;
uchar = be16tohp((void*)&ptr);
*(ptr-1) = uchar;
total_path_length += parent_thread.name.length + 1;
-
child_cnid = parent_cnid;
}
-
+
/*
- * At this point, 'path' holds a sequence of unicode characters which
- * represent the absolute path to the given cnid. This string is missing
- * a terminating null char and an initial forward slash that represents
- * the root of the filesystem. It most likely also has extra space in
- * the beginning, due to the fact that we reserve 512 bytes for each path
- * component and won't usually use all that space. So, we allocate the
- * final string based on the actual length of the absolute path, plus four
- * additional bytes (two unichars) for the forward slash and the null char.
+ * At this point, 'path' holds a sequence of unicode characters which
+ * represent the absolute path to the given cnid. This string is missing
+ * a terminating null char and an initial forward slash that represents
+ * the root of the filesystem. It most likely also has extra space in
+ * the beginning, due to the fact that we reserve 512 bytes for each path
+ * component and won't usually use all that space. So, we allocate the
+ * final string based on the actual length of the absolute path, plus four
+ * additional bytes (two unichars) for the forward slash and the null char.
*/
-
+
*out_unicode = hfslib_malloc((total_path_length+2)*2, cbargs);
- if(*out_unicode == NULL)
+ if (*out_unicode == NULL)
goto exit;
-
+
/* copy only the bytes that are actually used */
memcpy(*out_unicode + 2, path + path_offset, total_path_length*2);
@@ -465,15 +464,14 @@
/* insert null char at end */
(*out_unicode)[total_path_length*2+2] = 0x00;
(*out_unicode)[total_path_length*2+3] = 0x00;
-
+
*out_length = total_path_length + 1 /* extra for forward slash */ ;
result = 0;
-
+
exit:
- if(path!=NULL)
+ if (path != NULL)
hfslib_free(path, cbargs);
-
return result;
}
@@ -486,16 +484,16 @@
{
hfs_catalog_key_t childkey;
- if(in_vol==NULL || in_child==0 || out_thread==NULL)
+ if (in_vol == NULL || in_child == 0 || out_thread == NULL)
return 0;
-
- if(hfslib_make_catalog_key(in_child, 0, NULL, &childkey)==0)
+
+ if (hfslib_make_catalog_key(in_child, 0, NULL, &childkey) == 0)
return 0;
-
- if(hfslib_find_catalog_record_with_key(in_vol, &childkey,
- (hfs_catalog_keyed_record_t*)out_thread, cbargs)!=0)
+
+ if (hfslib_find_catalog_record_with_key(in_vol, &childkey,
+ (hfs_catalog_keyed_record_t*)out_thread, cbargs) != 0)
return 0;
-
+
return out_thread->parent_cnid;
}
Home |
Main Index |
Thread Index |
Old Index