summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-05-29 06:38:12 +0100
committerColin Watson <cjwatson@debian.org>2018-05-29 06:38:12 +0100
commit103c463506c773e4e8327c5d67ae9309bb9f1152 (patch)
treed3f99410ee869271b5eb6a8165f831f40da0032e
parentc150786d1ff2966406bd052c48ccca874f6749d5 (diff)
Remove useless if-before-free tests
* lib/hashtable.c (plain_hashtable_free): Remove; this is precisely equivalent to free. * lib/hashtable.h (plain_hashtable_free): Remove. * lib/orderfiles.c (order_files): Use free rather than plain_hashtable_free. * libdb/db_btree.c (btree_findkey): Likewise. * lib/pathsearch.c (pathsearch, directory_on_path): Remove useless if-before-free. * libdb/db_lookup.c (free_mandata_elements): Likewise. * src/check_mandirs.c (test_manfile, count_glob_matches): Likewise. * src/descriptions.c (free_descriptions): Likewise. * src/lexgrog_test.c (main): Likewise. * src/man.c (display_filesystem, display_database, get_section_list): Likewise. * src/manp.c (add_system_manpath): Likewise. * src/straycats.c (check_for_stray, straycats): Likewise. * src/ult_src.c (ult_src): Likewise.
-rw-r--r--lib/hashtable.c6
-rw-r--r--lib/hashtable.h1
-rw-r--r--lib/orderfiles.c2
-rw-r--r--lib/pathsearch.c6
-rw-r--r--libdb/db_btree.c2
-rw-r--r--libdb/db_lookup.c3
-rw-r--r--src/check_mandirs.c6
-rw-r--r--src/descriptions.c3
-rw-r--r--src/lexgrog_test.c3
-rw-r--r--src/man.c12
-rw-r--r--src/manp.c3
-rw-r--r--src/straycats.c6
-rw-r--r--src/ult_src.c3
13 files changed, 17 insertions, 39 deletions
diff --git a/lib/hashtable.c b/lib/hashtable.c
index a57d13d5..85fbb04d 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -67,12 +67,6 @@ void null_hashtable_free (void *defn ATTRIBUTE_UNUSED)
{
}
-void plain_hashtable_free (void *defn)
-{
- if (defn)
- free (defn);
-}
-
/* Create a hashtable. */
struct hashtable *hashtable_create (hashtable_free_ptr free_defn)
{
diff --git a/lib/hashtable.h b/lib/hashtable.h
index 00863a5a..3924518c 100644
--- a/lib/hashtable.h
+++ b/lib/hashtable.h
@@ -44,7 +44,6 @@ struct nlist {
struct hashtable_iter;
extern void null_hashtable_free (void *defn);
-extern void plain_hashtable_free (void *defn);
extern struct hashtable *hashtable_create (hashtable_free_ptr free_defn);
extern struct nlist *hashtable_lookup_structure (const struct hashtable *ht,
diff --git a/lib/orderfiles.c b/lib/orderfiles.c
index 1ad955df..d67f4d8f 100644
--- a/lib/orderfiles.c
+++ b/lib/orderfiles.c
@@ -96,7 +96,7 @@ void order_files (const char *dir, char **basenames, size_t n_basenames)
* a small number of contiguous blocks, which seems a reasonable
* assumption for manual pages.
*/
- physical_offsets = hashtable_create (plain_hashtable_free);
+ physical_offsets = hashtable_create (&free);
for (i = 0; i < n_basenames; ++i) {
struct {
struct fiemap fiemap;
diff --git a/lib/pathsearch.c b/lib/pathsearch.c
index 5be35f8d..402f7d1a 100644
--- a/lib/pathsearch.c
+++ b/lib/pathsearch.c
@@ -87,8 +87,7 @@ static int pathsearch (const char *name, const mode_t bits)
}
free (path);
- if (cwd)
- free (cwd);
+ free (cwd);
return ret;
}
@@ -126,7 +125,6 @@ int directory_on_path (const char *dir)
}
free (path);
- if (cwd)
- free (cwd);
+ free (cwd);
return ret;
}
diff --git a/libdb/db_btree.c b/libdb/db_btree.c
index fa9d86b6..fdd9b150 100644
--- a/libdb/db_btree.c
+++ b/libdb/db_btree.c
@@ -192,7 +192,7 @@ static datum btree_findkey (DB *db, u_int flags)
}
}
if (!loop_check_hash)
- loop_check_hash = hashtable_create (&plain_hashtable_free);
+ loop_check_hash = hashtable_create (&free);
if (((db->seq) (db, (DBT *) &key, (DBT *) &data, flags))) {
memset (&key, 0, sizeof key);
diff --git a/libdb/db_lookup.c b/libdb/db_lookup.c
index a59d7a44..140a5050 100644
--- a/libdb/db_lookup.c
+++ b/libdb/db_lookup.c
@@ -142,8 +142,7 @@ void free_mandata_elements (struct mandata *pinfo)
* caller; why do we free it here?
*/
free (pinfo->addr); /* free the 'content' */
- if (pinfo->name)
- free (pinfo->name); /* free the real name */
+ free (pinfo->name); /* free the real name */
}
/* Go through the linked list of structures, free()ing the 'content' and the
diff --git a/src/check_mandirs.c b/src/check_mandirs.c
index 0c616582..3a6cecc8 100644
--- a/src/check_mandirs.c
+++ b/src/check_mandirs.c
@@ -302,8 +302,7 @@ void test_manfile (MYDBM_FILE dbf, const char *file, const char *path)
}
free (manpage);
- if (lg.whatis)
- free (lg.whatis);
+ free (lg.whatis);
}
static void add_dir_entries (MYDBM_FILE dbf, const char *path, char *infile)
@@ -800,8 +799,7 @@ static int count_glob_matches (const char *name, const char *ext,
if (buf) {
if (STREQ (ext, info.ext))
++count;
- if (info.name)
- free (info.name);
+ free (info.name);
free (buf);
}
}
diff --git a/src/descriptions.c b/src/descriptions.c
index 3f90fdd4..009a50ba 100644
--- a/src/descriptions.c
+++ b/src/descriptions.c
@@ -153,8 +153,7 @@ void free_descriptions (struct page_description *head)
while (desc) {
free (desc->name);
- if (desc->whatis)
- free (desc->whatis);
+ free (desc->whatis);
prev = desc;
desc = desc->next;
free (prev);
diff --git a/src/lexgrog_test.c b/src/lexgrog_test.c
index 4a0bffc7..c310aa0c 100644
--- a/src/lexgrog_test.c
+++ b/src/lexgrog_test.c
@@ -201,8 +201,7 @@ int main (int argc, char **argv)
file = ult_src (files[i], path ? path : ".",
&statbuf, SO_LINK, NULL);
- if (path)
- free (path);
+ free (path);
}
if (file && find_name (file, "-", &lg, encoding)) {
diff --git a/src/man.c b/src/man.c
index d226bd2a..34945bca 100644
--- a/src/man.c
+++ b/src/man.c
@@ -3187,8 +3187,7 @@ static int display_filesystem (struct candidate *candp)
cat_file = find_cat_file (candp->path, filename, man_file);
found = display (candp->path, man_file, cat_file, title, NULL);
- if (cat_file)
- free (cat_file);
+ free (cat_file);
free (lang);
lang = NULL;
}
@@ -3268,8 +3267,7 @@ static int display_database (struct candidate *candp)
cat_file = find_cat_file (candp->path, file, man_file);
found += display (candp->path, man_file, cat_file,
title, in->filter);
- if (cat_file)
- free (cat_file);
+ free (cat_file);
free (lang);
lang = NULL;
free (file);
@@ -3316,8 +3314,7 @@ static int display_database (struct candidate *candp)
return found; /* zero */
}
} else {
- if (catpath)
- free (catpath);
+ free (catpath);
free (title);
return found; /* zero */
}
@@ -3994,8 +3991,7 @@ static const char **get_section_list (void)
sections[i] = NULL;
return sections;
} else {
- if (sections)
- free (sections);
+ free (sections);
return config_sections;
}
}
diff --git a/src/manp.c b/src/manp.c
index 7b880bc0..fcbaaec5 100644
--- a/src/manp.c
+++ b/src/manp.c
@@ -626,8 +626,7 @@ static char *add_system_manpath (const char *systems, const char *manpathlist)
/* reset newdir */
*newdir = '\0';
}
- if (newdir)
- free (newdir);
+ free (newdir);
} else
manpath = pathappend (manpath, manpathlist);
}
diff --git a/src/straycats.c b/src/straycats.c
index 721cb292..9f1f4d59 100644
--- a/src/straycats.c
+++ b/src/straycats.c
@@ -287,8 +287,7 @@ static int check_for_stray (MYDBM_FILE dbf)
free (catdir_base);
}
- if (lg.whatis)
- free (lg.whatis);
+ free (lg.whatis);
pipeline_free (decomp);
next_exists:
free_mandata_struct (exists);
@@ -385,8 +384,7 @@ int straycats (const char *manpath)
free (mandir);
free (catdir);
- if (catpath)
- free (catpath);
+ free (catpath);
MYDBM_CLOSE (dbf);
return strays;
diff --git a/src/ult_src.c b/src/ult_src.c
index 2b4b0e65..f0de35c0 100644
--- a/src/ult_src.c
+++ b/src/ult_src.c
@@ -273,8 +273,7 @@ const char *ult_src (const char *name, const char *path,
if (recurse == 0) {
struct stat new_buf;
- if (base)
- free (base);
+ free (base);
base = xstrdup (name);
debug ("\nult_src: File %s in mantree %s\n", name, path);