From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Darrick J. Wong" Subject: [PATCH 04/32] misc: fix header complaints and resource leaks in e2fsprogs Date: Sat, 01 Mar 2014 23:17:04 -0800 Message-ID: <20140302071704.28217.3469.stgit@birch.djwong.org> References: <20140302071639.28217.57302.stgit@birch.djwong.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: linux-ext4@vger.kernel.org To: tytso@mit.edu, darrick.wong@oracle.com Return-path: Received: from userp1040.oracle.com ([156.151.31.81]:17433 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284AbaCBHRI (ORCPT ); Sun, 2 Mar 2014 02:17:08 -0500 In-Reply-To: <20140302071639.28217.57302.stgit@birch.djwong.org> Sender: linux-ext4-owner@vger.kernel.org List-ID: Fix a few minor bugs that cppcheck complained about. Signed-off-by: Darrick J. Wong --- debugfs/debugfs.c | 1 + debugfs/util.c | 2 +- e2fsck/unix.c | 1 + lib/ext2fs/icount.c | 2 ++ util/subst.c | 3 +++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index bc435b8..f0c5373 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -669,6 +669,7 @@ static void dump_extents(FILE *f, const char *prefix, ext2_ino_t ino, } if (printed) fprintf(f, "\n"); + ext2fs_extent_free(handle); } void internal_dump_inode(FILE *out, const char *prefix, diff --git a/debugfs/util.c b/debugfs/util.c index 9ddfe0b..5cc4e22 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -201,7 +201,7 @@ char *time_to_string(__u32 cl) tz = ss_safe_getenv("TZ"); if (!tz) tz = ""; - do_gmt = !strcmp(tz, "GMT") | !strcmp(tz, "GMT0"); + do_gmt = !strcmp(tz, "GMT") || !strcmp(tz, "GMT0"); } return asctime((do_gmt) ? gmtime(&t) : localtime(&t)); diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 429f1cd..f73a252 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1016,6 +1016,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) strcat(newpath, oldpath); } putenv(newpath); + free(newpath); } #ifdef CONFIG_JBD_DEBUG jbd_debug = getenv("E2FSCK_JBD_DEBUG"); diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c index a3b20f0..7d1b3d5 100644 --- a/lib/ext2fs/icount.c +++ b/lib/ext2fs/icount.c @@ -198,6 +198,7 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir, fd = mkstemp(fn); if (fd < 0) { retval = errno; + ext2fs_free_mem(&fn); goto errout; } umask(save_umask); @@ -216,6 +217,7 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir, close(fd); if (icount->tdb == NULL) { retval = errno; + ext2fs_free_mem(&fn); goto errout; } *ret = icount; diff --git a/util/subst.c b/util/subst.c index 6a5eab1..602546c 100644 --- a/util/subst.c +++ b/util/subst.c @@ -17,6 +17,9 @@ #include #include #include +#ifdef HAVE_SYS_TIME_H +#include +#endif #ifdef HAVE_GETOPT_H #include