From owner-svn-soc-all@FreeBSD.ORG Wed May 23 14:58:15 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7D9A31065674 for ; Wed, 23 May 2012 14:58:14 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 23 May 2012 14:58:14 +0000 Date: Wed, 23 May 2012 14:58:14 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120523145814.7D9A31065674@hub.freebsd.org> Cc: Subject: socsvn commit: r236204 - soc2012/gpf/pefs_kmod/sbin/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2012 14:58:15 -0000 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); }