summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2009-02-23 18:07:50 +0100
committerTheodore Ts'o <tytso@mit.edu>2009-03-08 20:37:12 -0400
commit45e338f5332a54295893dba2e32cc093d1316f60 (patch)
treef20a569662c01e9330b33ea9fd8baa83c7601473 /misc
parenta6d4aa147415acf875300176c5ca98ca72594bec (diff)
downloade2fsprogs-45e338f5332a54295893dba2e32cc093d1316f60.tar.gz
remove useless if-before-free tests
In case you're wondering about whether this change is safe from a portability standpoint, fear not. This has been beaten to death in other forums. Here are a few threads: http://thread.gmane.org/gmane.comp.version-control.git/74187 http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712 http://thread.gmane.org/gmane.emacs.devel/98144 http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092 There has been debate about whether it's a good idea from a performance standpoint, too, but imho you'll have a hard time finding an instance where this sort of change induces a measurable performance penalty. If you do, please let me know. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc')
-rw-r--r--misc/badblocks.c3
-rw-r--r--misc/blkid.c6
-rw-r--r--misc/e2initrd_helper.c3
-rw-r--r--misc/fsck.c12
-rw-r--r--misc/mke2fs.c12
-rw-r--r--misc/tune2fs.c3
6 files changed, 13 insertions, 26 deletions
diff --git a/misc/badblocks.c b/misc/badblocks.c
index f7d67a77..528bc223 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -1237,8 +1237,7 @@ int main (int argc, char ** argv)
close (dev);
if (out != stdout)
fclose (out);
- if (t_patts)
- free(t_patts);
+ free(t_patts);
return 0;
}
diff --git a/misc/blkid.c b/misc/blkid.c
index 4bbf9fbf..0c34d614 100644
--- a/misc/blkid.c
+++ b/misc/blkid.c
@@ -420,10 +420,8 @@ int main(int argc, char **argv)
}
exit:
- if (search_type)
- free(search_type);
- if (search_value)
- free(search_value);
+ free(search_type);
+ free(search_value);
blkid_put_cache(cache);
return err;
}
diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c
index c4e2e46a..eaf9ce60 100644
--- a/misc/e2initrd_helper.c
+++ b/misc/e2initrd_helper.c
@@ -274,8 +274,7 @@ static int parse_fstab_line(char *line, struct fs_info *fs)
fs->flags = 0;
fs->next = NULL;
- if (dev)
- free(dev);
+ free(dev);
return 0;
}
diff --git a/misc/fsck.c b/misc/fsck.c
index ea8f0e2d..fe9426e0 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -233,12 +233,9 @@ static void parse_escape(char *word)
static void free_instance(struct fsck_instance *i)
{
- if (i->prog)
- free(i->prog);
- if (i->device)
- free(i->device);
- if (i->base_device)
- free(i->base_device);
+ free(i->prog);
+ free(i->device);
+ free(i->base_device);
free(i);
return;
}
@@ -310,8 +307,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs)
fs = create_fs_device(device, mntpnt, type ? type : "auto", opts,
freq ? atoi(freq) : -1,
passno ? atoi(passno) : -1);
- if (dev)
- free(dev);
+ free(dev);
if (!fs)
return -1;
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 15948e09..e69e5cea 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1024,8 +1024,7 @@ static char **parse_fs_type(const char *fs_type,
}
}
free(parse_str);
- if (profile_type)
- free(profile_type);
+ free(profile_type);
if (is_hurd)
push_string(&list, "hurd");
return (list.list);
@@ -1523,16 +1522,14 @@ got_size:
"features", "", &tmp);
if (tmp && *tmp)
edit_feature(tmp, &fs_param.s_feature_compat);
- if (tmp)
- free(tmp);
+ free(tmp);
}
tmp = get_string_from_profile(fs_types, "default_features",
"");
}
edit_feature(fs_features ? fs_features : tmp,
&fs_param.s_feature_compat);
- if (tmp)
- free(tmp);
+ free(tmp);
if (fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
fs_types[0] = strdup("journal");
@@ -1646,8 +1643,7 @@ got_size:
profile_get_string(profile, "fs_types", *cpp, "options", "", &tmp);
if (tmp && *tmp)
parse_extended_opts(&fs_param, tmp);
- if (tmp)
- free(tmp);
+ free(tmp);
}
if (extended_opts)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index d7796119..9692443e 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -529,8 +529,7 @@ static void add_journal(ext2_filsys fs)
return;
err:
- if (journal_device)
- free(journal_device);
+ free(journal_device);
exit(1);
}