socsvn commit: r236204 - soc2012/gpf/pefs_kmod/sbin/pefs

gpf at FreeBSD.org gpf at FreeBSD.org
Wed May 23 14:58:15 UTC 2012


Author: gpf
Date: Wed May 23 14:58:13 2012
New Revision: 236204
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236204

Log:
  code refactoring
  

Modified:
  soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c

Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c
==============================================================================
--- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c	Wed May 23 14:50:24 2012	(r236203)
+++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c	Wed May 23 14:58:13 2012	(r236204)
@@ -381,13 +381,9 @@
 			return error;
 	}
 
-	/* error during pefs_next_file() */
-	if (error != 0)
-		return error;
-
 	pefs_print_hash_table(checksum_hash_tablep, hash_len);
 
-	return (0);
+	return (error);
 }
 
 int
@@ -519,7 +515,6 @@
 	/*
 	 * XXXgpf: [TODO] deal with other types of files
 	 */
-
 	if (S_ISREG(sb.st_mode) == 0) {
 		pefs_warn("filename: %s is not a regular file", enc_path);
 		return (PEFS_ERR_INVALID);
@@ -527,6 +522,7 @@
 
 	strlcpy(fhp->path, enc_path, sizeof(fhp->path));
 	strlcat(fhp->path, "\n", sizeof(fhp->path));
+
 	return (0);
 }
 
@@ -559,6 +555,8 @@
 	struct file_header *fhp;
 	int error;
 
+	error = 0;
+
 	if (statfs(fsroot, &fs) == -1) {
 		pefs_warn("statfs failed: %s: %s", fsroot, strerror(errno));
 		return (PEFS_ERR_SYS);
@@ -567,22 +565,22 @@
 	while((fhp = pefs_next_file(fpin, &error)) != NULL) {
 		error = pefs_file_semantic_checks(fhp, &fs);
 		if (error != 0)
-			return error;
+			goto out;
 
 		error = pefs_get_enc_path(fhp, fsroot, fromfsroot);
 		if (error != 0)
-			return error;
+			goto out;
 
 		error = pefs_write_to_checklist(fdout, fhp);
 		if (error != 0)
-			return error;
+			goto out;
 
 		free(fhp);
 	}
 
-	/* error during pefs_next_file() */
-	if (error != 0)
-		return error;
+out:
+	if (fhp != NULL)
+		free(fhp);
 
-	return (0);
+	return (error);
 }


More information about the svn-soc-all mailing list