From 8a6cc1aebd7e9b2e6d6624fa1f8539888da25fe4 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 14 Mar 2014 09:43:11 -0400 Subject: [PATCH] misc: fix header complaints and resource leaks in e2fsprogs Fix a few minor bugs that cppcheck complained about. Signed-off-by: Darrick J. Wong Signed-off-by: "Theodore Ts'o" --- debugfs/debugfs.c | 1 + debugfs/util.c | 2 +- lib/ext2fs/icount.c | 3 ++- util/subst.c | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index a10446d0..72ab0406 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -657,6 +657,7 @@ static void dump_extents(FILE *f, const char *prefix, ext2_ino_t ino, } if (printed) fprintf(f, "\n"); + ext2fs_extent_free(handle); } static void dump_inline_data(FILE *out, const char *prefix, ext2_ino_t inode_num) diff --git a/debugfs/util.c b/debugfs/util.c index 9ddfe0ba..5cc4e22b 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/lib/ext2fs/icount.c b/lib/ext2fs/icount.c index a3b20f06..5e1f5c65 100644 --- a/lib/ext2fs/icount.c +++ b/lib/ext2fs/icount.c @@ -193,13 +193,14 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir, goto errout; uuid_unparse(fs->super->s_uuid, uuid); sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid); - icount->tdb_fn = fn; save_umask = umask(077); fd = mkstemp(fn); if (fd < 0) { retval = errno; + ext2fs_free_mem(&fn); goto errout; } + icount->tdb_fn = fn; umask(save_umask); /* * This is an overestimate of the size that we will need; the diff --git a/util/subst.c b/util/subst.c index 2ea16d9b..32d52932 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