Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/ufs/ffs/ffs_appleufs.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/ufs/ffs/ffs_appleufs.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.12 retrieving revision 1.13 diff -u -p -r1.12 -r1.13 --- src/sys/ufs/ffs/ffs_appleufs.c 2011/11/19 22:51:31 1.12 +++ src/sys/ufs/ffs/ffs_appleufs.c 2015/02/14 07:56:31 1.13 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_appleufs.c,v 1.12 2011/11/19 22:51:31 tls Exp $ */ +/* $NetBSD: ffs_appleufs.c,v 1.13 2015/02/14 07:56:31 maxv Exp $ */ /* * Copyright (c) 2002 Darrin B. Jewell @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_appleufs.c,v 1.12 2011/11/19 22:51:31 tls Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_appleufs.c,v 1.13 2015/02/14 07:56:31 maxv Exp $"); #include #include @@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_appleufs #endif /* - * this is the same calculation as in_cksum + * This is the same calculation as in_cksum. */ u_int16_t ffs_appleufs_cksum(const struct appleufslabel *appleufs) @@ -73,26 +73,28 @@ ffs_appleufs_cksum(const struct appleufs return (~res); } -/* copies o to n, validating and byteswapping along the way - * returns 0 if ok, EINVAL if not valid +/* + * Copies o to n, validating and byteswapping along the way. Returns 0 if ok, + * EINVAL if not valid. */ int ffs_appleufs_validate(const char *name, const struct appleufslabel *o, struct appleufslabel *n) { struct appleufslabel tmp; - if (!n) n = &tmp; - if (o->ul_magic != be32toh(APPLEUFS_LABEL_MAGIC)) { + if (!n) + n = &tmp; + if (o->ul_magic != be32toh(APPLEUFS_LABEL_MAGIC)) return EINVAL; - } + *n = *o; n->ul_checksum = 0; n->ul_checksum = ffs_appleufs_cksum(n); if (n->ul_checksum != o->ul_checksum) { #if defined(DIAGNOSTIC) || !defined(_KERNEL) printf("%s: invalid APPLE UFS checksum. found 0x%x, expecting 0x%x", - name,o->ul_checksum,n->ul_checksum); + name, o->ul_checksum, n->ul_checksum); #endif return EINVAL; } @@ -104,7 +106,7 @@ ffs_appleufs_validate(const char *name, if (n->ul_namelen > APPLEUFS_MAX_LABEL_NAME) { #if defined(DIAGNOSTIC) || !defined(_KERNEL) printf("%s: APPLE UFS label name too long, truncated.\n", - name); + name); #endif n->ul_namelen = APPLEUFS_MAX_LABEL_NAME; } @@ -112,8 +114,8 @@ ffs_appleufs_validate(const char *name, n->ul_name[n->ul_namelen - 1] = '\0'; #ifdef DEBUG - printf("%s: found APPLE UFS label v%d: \"%s\"\n", - name,n->ul_version,n->ul_name); + printf("%s: found APPLE UFS label v%d: \"%s\"\n", name, + n->ul_version, n->ul_name); #endif n->ul_uuid = be64toh(o->ul_uuid); @@ -125,7 +127,9 @@ ffs_appleufs_set(struct appleufslabel *a uint64_t uuid) { size_t namelen; - if (!name) name = "untitled"; + + if (!name) + name = "untitled"; if (t == ((time_t)-1)) { #if defined(_KERNEL) t = time_second; @@ -148,7 +152,7 @@ ffs_appleufs_set(struct appleufslabel *a appleufs->ul_version = htobe32(APPLEUFS_LABEL_VERSION); appleufs->ul_time = htobe32((u_int32_t)t); appleufs->ul_namelen = htobe16(namelen); - strncpy(appleufs->ul_name,name,namelen); + strncpy(appleufs->ul_name, name, namelen); appleufs->ul_uuid = htobe64(uuid); appleufs->ul_checksum = ffs_appleufs_cksum(appleufs); }