summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-07-13 10:29:48 +0200
committerAnand Avati <avati@redhat.com>2012-07-13 14:03:42 -0700
commit7820b2c1f88b207a8b1270b8c3cb3b797b7563d2 (patch)
tree5a383d85eb18399cf7506a90cc7627c749ccf9b8 /libglusterfs/src
parent2dc0d32e5d8b205fa407073b209bb663d546dde8 (diff)
remove useless if-before-free (and free-like) functions
See comments in http://bugzilla.redhat.com/839925 for the code to perform this change. Signed-off-by: Jim Meyering <meyering@redhat.com> BUG: 839925 Change-Id: I10e4ecff16c3749fe17c2831c516737e08a3205a Reviewed-on: http://review.gluster.com/3661 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/call-stub.c27
-rw-r--r--libglusterfs/src/circ-buff.c3
-rw-r--r--libglusterfs/src/common-utils.c12
-rw-r--r--libglusterfs/src/compat.c21
-rw-r--r--libglusterfs/src/dict.c9
-rw-r--r--libglusterfs/src/event.c6
-rw-r--r--libglusterfs/src/fd.c4
-rw-r--r--libglusterfs/src/globals.c9
-rw-r--r--libglusterfs/src/inode.c20
-rw-r--r--libglusterfs/src/iobuf.c3
-rw-r--r--libglusterfs/src/logging.c29
-rw-r--r--libglusterfs/src/options.c6
-rw-r--r--libglusterfs/src/rbthash.c3
-rw-r--r--libglusterfs/src/syncop.c12
-rw-r--r--libglusterfs/src/trie.c6
-rw-r--r--libglusterfs/src/xlator.c12
16 files changed, 59 insertions, 123 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 85a1aaa7b5c..0ca5bf7f1e4 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -3712,8 +3712,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_GETXATTR:
{
- if (stub->args.getxattr.name)
- GF_FREE ((char *)stub->args.getxattr.name);
+ GF_FREE ((char *)stub->args.getxattr.name);
loc_wipe (&stub->args.getxattr.loc);
break;
}
@@ -3728,8 +3727,7 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_FGETXATTR:
{
- if (stub->args.fgetxattr.name)
- GF_FREE ((char *)stub->args.fgetxattr.name);
+ GF_FREE ((char *)stub->args.fgetxattr.name);
fd_unref (stub->args.fgetxattr.fd);
break;
}
@@ -3792,16 +3790,14 @@ call_stub_destroy_wind (call_stub_t *stub)
case GF_FOP_INODELK:
{
- if (stub->args.inodelk.volume)
- GF_FREE ((char *)stub->args.inodelk.volume);
+ GF_FREE ((char *)stub->args.inodelk.volume);
loc_wipe (&stub->args.inodelk.loc);
break;
}
case GF_FOP_FINODELK:
{
- if (stub->args.finodelk.volume)
- GF_FREE ((char *)stub->args.finodelk.volume);
+ GF_FREE ((char *)stub->args.finodelk.volume);
if (stub->args.finodelk.fd)
fd_unref (stub->args.finodelk.fd);
@@ -3809,21 +3805,17 @@ call_stub_destroy_wind (call_stub_t *stub)
}
case GF_FOP_ENTRYLK:
{
- if (stub->args.entrylk.volume)
- GF_FREE ((char *)stub->args.entrylk.volume);
+ GF_FREE ((char *)stub->args.entrylk.volume);
- if (stub->args.entrylk.name)
- GF_FREE ((char *)stub->args.entrylk.name);
+ GF_FREE ((char *)stub->args.entrylk.name);
loc_wipe (&stub->args.entrylk.loc);
break;
}
case GF_FOP_FENTRYLK:
{
- if (stub->args.fentrylk.volume)
- GF_FREE ((char *)stub->args.fentrylk.volume);
+ GF_FREE ((char *)stub->args.fentrylk.volume);
- if (stub->args.fentrylk.name)
- GF_FREE ((char *)stub->args.fentrylk.name);
+ GF_FREE ((char *)stub->args.fentrylk.name);
if (stub->args.fentrylk.fd)
fd_unref (stub->args.fentrylk.fd);
@@ -3922,8 +3914,7 @@ call_stub_destroy_unwind (call_stub_t *stub)
case GF_FOP_READLINK:
{
- if (stub->args.readlink_cbk.buf)
- GF_FREE ((char *)stub->args.readlink_cbk.buf);
+ GF_FREE ((char *)stub->args.readlink_cbk.buf);
}
break;
diff --git a/libglusterfs/src/circ-buff.c b/libglusterfs/src/circ-buff.c
index 6c7907a095c..65bbd5d45c7 100644
--- a/libglusterfs/src/circ-buff.c
+++ b/libglusterfs/src/circ-buff.c
@@ -158,8 +158,7 @@ cb_buffer_destroy (buffer_t *buffer)
if (buffer) {
if (buffer->cb) {
for (i = 0; i < buffer->used_len ; i++) {
- if (buffer->cb[i])
- GF_FREE (buffer->cb[i]);
+ GF_FREE (buffer->cb[i]);
}
GF_FREE (buffer->cb);
}
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 671a3e549dc..d09cafc6868 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -602,8 +602,7 @@ gf_strstr (const char *str, const char *delim, const char *match)
}
out:
- if (tmp_str)
- free (tmp_str);
+ free (tmp_str);
return ret;
@@ -1684,8 +1683,7 @@ valid_host_name (char *address, int length)
}
out:
- if (dup_addr)
- GF_FREE (dup_addr);
+ GF_FREE (dup_addr);
return ret;
}
@@ -1916,8 +1914,7 @@ gf_is_str_int (const char *value)
}
out:
- if (fptr)
- GF_FREE (fptr);
+ GF_FREE (fptr);
return flag;
}
@@ -2126,8 +2123,7 @@ gf_canonicalize_path (char *path)
gf_log ("common-utils", GF_LOG_ERROR,
"Path manipulation failed");
- if (tmppath)
- GF_FREE(tmppath);
+ GF_FREE(tmppath);
return ret;
}
diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c
index 99a0041a5cf..2f02eeac544 100644
--- a/libglusterfs/src/compat.c
+++ b/libglusterfs/src/compat.c
@@ -142,8 +142,7 @@ done:
*path = export_path;
}
out:
- if (freeptr)
- GF_FREE (freeptr);
+ GF_FREE (freeptr);
if (ret && export_path)
GF_FREE (export_path);
@@ -195,8 +194,7 @@ solaris_xattr_resolve_path (const char *real_path, char **path)
*path = gf_strdup (xattr_path);
}
out:
- if (export_path)
- GF_FREE (export_path);
+ GF_FREE (export_path);
if (*path)
return 0;
else
@@ -230,8 +228,7 @@ solaris_setxattr(const char *path, const char* key, const char *value,
path, errno);
ret = -1;
}
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return ret;
}
@@ -297,8 +294,7 @@ solaris_listxattr(const char *path, char *list, size_t size)
close (attrdirfd);
}
out:
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return len;
}
@@ -380,8 +376,7 @@ solaris_removexattr(const char *path, const char* key)
ret = -1;
}
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return ret;
}
@@ -421,8 +416,7 @@ solaris_getxattr(const char *path,
errno = ENODATA;
ret = -1;
}
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return ret;
}
@@ -494,8 +488,7 @@ int solaris_unlink (const char *path)
}
out:
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return unlink (path);
}
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 2e61a3f4e33..c290e0d6240 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -181,8 +181,7 @@ data_copy (data_t *old)
err_out:
- if (newdata->data)
- FREE (newdata->data);
+ FREE (newdata->data);
mem_put (newdata);
return NULL;
@@ -436,10 +435,8 @@ dict_destroy (dict_t *this)
mem_put (this->members);
}
- if (this->extra_free)
- GF_FREE (this->extra_free);
- if (this->extra_stdfree)
- free (this->extra_stdfree);
+ GF_FREE (this->extra_free);
+ free (this->extra_stdfree);
if (!this->is_static)
mem_put (this);
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
index 8f172fb24b8..00175bda49e 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -376,8 +376,7 @@ event_dispatch_poll_resize (struct event_pool *event_pool,
}
if (event_pool->used > event_pool->evcache_size) {
- if (event_pool->evcache)
- GF_FREE (event_pool->evcache);
+ GF_FREE (event_pool->evcache);
event_pool->evcache = ufds = NULL;
@@ -808,8 +807,7 @@ event_dispatch_epoll (struct event_pool *event_pool)
&event_pool->mutex);
if (event_pool->used > event_pool->evcache_size) {
- if (event_pool->evcache)
- GF_FREE (event_pool->evcache);
+ GF_FREE (event_pool->evcache);
event_pool->evcache = events = NULL;
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 3a7a592786c..fede42a7483 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -1057,9 +1057,7 @@ unlock:
}
out:
- if (fd_ctx != NULL) {
- GF_FREE (fd_ctx);
- }
+ GF_FREE (fd_ctx);
return;
}
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
index 11f62a5501f..703c5271d7e 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -126,8 +126,7 @@ static pthread_key_t this_xlator_key;
void
glusterfs_this_destroy (void *ptr)
{
- if (ptr)
- FREE (ptr);
+ FREE (ptr);
}
@@ -254,8 +253,7 @@ static char global_uuid_buf[GF_UUID_BUF_SIZE];
void
glusterfs_uuid_buf_destroy (void *ptr)
{
- if (ptr)
- FREE (ptr);
+ FREE (ptr);
}
int
@@ -291,8 +289,7 @@ static char global_lkowner_buf[GF_LKOWNER_BUF_SIZE];
void
glusterfs_lkowner_buf_destroy (void *ptr)
{
- if (ptr)
- FREE (ptr);
+ FREE (ptr);
}
int
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index a0088c03c55..2efcd89cc73 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -134,8 +134,7 @@ __dentry_unset (dentry_t *dentry)
list_del_init (&dentry->inode_list);
- if (dentry->name)
- GF_FREE (dentry->name);
+ GF_FREE (dentry->name);
if (dentry->parent) {
__inode_unref (dentry->parent);
@@ -1205,9 +1204,7 @@ __inode_path (inode_t *inode, const char *name, char **bufp)
out:
if (__is_root_gfid (inode->gfid) && !name) {
ret = 1;
- if (buf) {
- GF_FREE (buf);
- }
+ GF_FREE (buf);
buf = GF_CALLOC (ret + 1, sizeof (char), gf_common_mt_char);
if (buf) {
strcpy (buf, "/");
@@ -1385,10 +1382,8 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
out:
if (ret) {
if (new) {
- if (new->inode_hash)
- GF_FREE (new->inode_hash);
- if (new->name_hash)
- GF_FREE (new->name_hash);
+ GF_FREE (new->inode_hash);
+ GF_FREE (new->name_hash);
if (new->dentry_pool)
mem_pool_destroy (new->dentry_pool);
if (new->inode_pool)
@@ -1454,8 +1449,7 @@ inode_from_path (inode_table_t *itable, const char *path)
if (parent)
inode_unref (parent);
- if (pathname)
- GF_FREE (pathname);
+ GF_FREE (pathname);
out:
return inode;
@@ -1667,9 +1661,7 @@ unlock:
}
}
- if (inode_ctx != NULL) {
- GF_FREE (inode_ctx);
- }
+ GF_FREE (inode_ctx);
return;
}
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index f68c6c74879..86bf697e879 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -562,8 +562,7 @@ iobuf_get_from_stdalloc (struct iobuf_pool *iobuf_pool, size_t page_size)
ret = 0;
out:
if (ret && iobuf) {
- if (iobuf->free_ptr)
- GF_FREE (iobuf->free_ptr);
+ GF_FREE (iobuf->free_ptr);
GF_FREE (iobuf);
iobuf = NULL;
}
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 6071269e01c..c41d245f191 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -436,14 +436,11 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
pthread_mutex_unlock (&logfile_mutex);
out:
- if (msg)
- GF_FREE (msg);
+ GF_FREE (msg);
- if (str1)
- GF_FREE (str1);
+ GF_FREE (str1);
- if (str2)
- FREE (str2);
+ FREE (str2);
return ret;
}
@@ -581,15 +578,11 @@ log:
pthread_mutex_unlock (&logfile_mutex);
err:
- if (msg) {
- GF_FREE (msg);
- }
+ GF_FREE (msg);
- if (str1)
- GF_FREE (str1);
+ GF_FREE (str1);
- if (str2)
- FREE (str2);
+ FREE (str2);
out:
return (0);
@@ -702,15 +695,11 @@ gf_cmd_log (const char *domain, const char *fmt, ...)
fflush (cmdlogfile);
out:
- if (msg) {
- GF_FREE (msg);
- }
+ GF_FREE (msg);
- if (str1)
- GF_FREE (str1);
+ GF_FREE (str1);
- if (str2)
- FREE (str2);
+ FREE (str2);
return (0);
}
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c
index 76e581fddb7..dc119923533 100644
--- a/libglusterfs/src/options.c
+++ b/libglusterfs/src/options.c
@@ -522,8 +522,7 @@ xlator_option_validate_addr_list (xlator_t *xl, const char *key,
out:
if (op_errstr && ret)
*op_errstr = gf_strdup (errstr);
- if (dup_val)
- GF_FREE (dup_val);
+ GF_FREE (dup_val);
return ret;
}
@@ -605,8 +604,7 @@ validate_list_elements (const char *string, volume_option_t *opt,
substr_sav = NULL;
}
out:
- if (dup_string)
- GF_FREE (dup_string);
+ GF_FREE (dup_string);
gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
index 4f04fed9311..cced943a3ee 100644
--- a/libglusterfs/src/rbthash.c
+++ b/libglusterfs/src/rbthash.c
@@ -208,8 +208,7 @@ rbthash_deinit_entry (rbthash_table_t *tbl, rbthash_entry_t *entry)
if (!entry)
return;
- if (entry->key)
- GF_FREE (entry->key);
+ GF_FREE (entry->key);
if (tbl) {
if ((entry->data) && (tbl->dfunc))
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 4ef7d7aea52..491f6ae1598 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -133,8 +133,7 @@ synctask_destroy (struct synctask *task)
if (!task)
return;
- if (task->stack)
- FREE (task->stack);
+ FREE (task->stack);
if (task->opframe)
STACK_DESTROY (task->opframe->root);
@@ -243,8 +242,7 @@ synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk,
return ret;
err:
if (newtask) {
- if (newtask->stack)
- FREE (newtask->stack);
+ FREE (newtask->stack);
if (newtask->opframe)
STACK_DESTROY (newtask->opframe->root);
FREE (newtask);
@@ -983,8 +981,7 @@ syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
if (vector)
*vector = args.vector;
- else if (args.vector)
- GF_FREE (args.vector);
+ else GF_FREE (args.vector);
if (count)
*count = args.count;
@@ -1367,8 +1364,7 @@ syncop_readlink (xlator_t *subvol, loc_t *loc, char **buffer, size_t size)
if (buffer)
*buffer = args.buffer;
- else if (args.buffer)
- GF_FREE (args.buffer);
+ else GF_FREE (args.buffer);
errno = args.op_errno;
return args.op_ret;
diff --git a/libglusterfs/src/trie.c b/libglusterfs/src/trie.c
index b7c59784218..f96bbebf6d3 100644
--- a/libglusterfs/src/trie.c
+++ b/libglusterfs/src/trie.c
@@ -114,8 +114,7 @@ trienode_free (trienode_t *node)
trienode_free (trav);
}
- if (node->data)
- GF_FREE (node->data);
+ GF_FREE (node->data);
GF_FREE (node);
}
@@ -373,8 +372,7 @@ trie_measure_vec (trie_t *trie, const char *word, struct trienodevec *nodevec)
static int
trienode_reset (trienode_t *node, void *data)
{
- if (node->data)
- GF_FREE (node->data);
+ GF_FREE (node->data);
return 0;
}
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 7c081fa5568..2bac24f040f 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -168,8 +168,7 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle,
ret = 0;
out:
- if (name)
- GF_FREE (name);
+ GF_FREE (name);
gf_log ("xlator", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -272,8 +271,7 @@ xlator_dynload (xlator_t *xl)
ret = 0;
out:
- if (name)
- GF_FREE (name);
+ GF_FREE (name);
return ret;
}
@@ -647,10 +645,8 @@ xlator_destroy (xlator_t *xl)
if (!xl)
return 0;
- if (xl->name)
- GF_FREE (xl->name);
- if (xl->type)
- GF_FREE (xl->type);
+ GF_FREE (xl->name);
+ GF_FREE (xl->type);
if (xl->dlhandle)
dlclose (xl->dlhandle);
if (xl->options)