PERFORCE change 145848 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Jul 24 21:12:14 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=145848

Change 145848 by trasz at trasz_traszkan on 2008/07/24 21:11:35

	Style change - replace ifs with switch.  No functional change.
	
	Fever is not good for coding.  ;-/

Affected files ...

.. //depot/projects/soc2008/trasz_nfs4acl/TODO#14 edit
.. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/vfs_acl.c#5 edit

Differences ...

==== //depot/projects/soc2008/trasz_nfs4acl/TODO#14 (text+ko) ====

@@ -48,8 +48,6 @@
 
 - Make 'struct acl' variable size.
 
-- Use switch() in vfs_acl.c:copyin_acl() instead of ifs.
-
 - Check if Linux has acl_to_text_np; make sure we don't end up with something incompatible.
   (acl_to_any_text()?)
 

==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/vfs_acl.c#5 (text+ko) ====

@@ -129,17 +129,19 @@
 	int error;
 	struct oldacl old;
 
-	/* Is it the new "struct acl"? */
-	if (type != ACL_TYPE_ACCESS_OLD && type != ACL_TYPE_DEFAULT_OLD)
-		return (copyin(user_acl, kernel_acl, sizeof(struct acl)));
+	switch (type) {
+	case ACL_TYPE_ACCESS_OLD:
+	case ACL_TYPE_DEFAULT_OLD:
+		error = copyin(user_acl, &old, sizeof(struct oldacl));
+		if (error)
+			break;
+		error = acl_copy_oldacl_into_acl(&old, kernel_acl);
+		break;
 
-	/* Nope, it's a "struct oldacl". */
-	error = copyin(user_acl, &old, sizeof(struct oldacl));
-	if (error)
-		return (error);
+	default:
+		error = copyin(user_acl, kernel_acl, sizeof(struct acl));
+	}
 
-	error = acl_copy_oldacl_into_acl(&old, kernel_acl);
-
 	return (error);
 }
 
@@ -149,14 +151,19 @@
 	int error;
 	struct oldacl old;
 
-	if (type != ACL_TYPE_ACCESS_OLD && type != ACL_TYPE_DEFAULT_OLD)
-		return (copyout(kernel_acl, user_acl, sizeof(struct acl)));
+	switch (type) {
+	case ACL_TYPE_ACCESS_OLD:
+	case ACL_TYPE_DEFAULT_OLD:
+		error = acl_copy_acl_into_oldacl(kernel_acl, &old);
+		if (error)
+			break;
 
-	error = acl_copy_acl_into_oldacl(kernel_acl, &old);
-	if (error)
-		return (error);
+		error = copyout(&old, user_acl, sizeof(struct oldacl));
+		break;
 
-	error = copyout(&old, user_acl, sizeof(struct oldacl));
+	default:
+		error = copyout(kernel_acl, user_acl, sizeof(struct acl));
+	}
 
 	return (error);
 }
@@ -164,13 +171,16 @@
 static int
 type_unold(int type)
 {
-	if (type == ACL_TYPE_ACCESS_OLD)
+	switch (type) {
+	case ACL_TYPE_ACCESS_OLD:
 		return (ACL_TYPE_ACCESS);
 
-	if (type == ACL_TYPE_DEFAULT_OLD)
+	case ACL_TYPE_DEFAULT_OLD:
 		return (ACL_TYPE_DEFAULT);
 
-	return (type);
+	default:
+		return (type);
+	}
 }
 
 /*


More information about the p4-projects mailing list