Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 May 2012 14:58:14 +0000
From:      gpf@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r236204 - soc2012/gpf/pefs_kmod/sbin/pefs
Message-ID:  <20120523145814.7D9A31065674@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120523145814.7D9A31065674>