FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 02-14-2008, 12:26 PM
Jim Meyering
 
Default Remove redundant if-before-free tests.

[as I just wrote to lvm-devel:
http://www.redhat.com/archives/lvm-devel/2008-February/msg00017.html ]

Jim Meyering <jim@meyering.net> wrote:
> Since "free (NULL);" is universally safe these days, I propose
> to remove all of lvm's redundant "if-before-free" tests.
> If no one objects, I'll commit it tonight.
>
> In case you need more justification than "POSIX requires it",
> (understandable, that :-), the following was enough for Wine
> development a year and a half ago:
>
> http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html
>
> Sure, the extra test is not a big deal, but removing it does make the
> code slightly smaller, and maybe even more readable (people won't wonder
> about the test of such a pointer, when they know that free can handle
> a NULL pointer).

Same for dm, but here there are only 3:

---
dmeventd/old/dmevent.c | 6 ++----
multilog/pthread_lock/pthread_lock.c | 3 +--
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/dmeventd/old/dmevent.c b/dmeventd/old/dmevent.c
index 6e9eb46..5d80410 100644
--- a/dmeventd/old/dmevent.c
+++ b/dmeventd/old/dmevent.c
@@ -220,10 +220,8 @@ int main(int argc, char **argv)
out:
multilog_del_type(standard);

- if (device)
- free(device);
- if (dso_name)
- free(dso_name);
+ free(device);
+ free(dso_name);

exit(ret);
}
diff --git a/multilog/pthread_lock/pthread_lock.c b/multilog/pthread_lock/pthread_lock.c
index b782301..c52050b 100644
--- a/multilog/pthread_lock/pthread_lock.c
+++ b/multilog/pthread_lock/pthread_lock.c
@@ -62,7 +62,6 @@ int unlock_fn(void *handle)
void destroy_locking(void *handle)
{
pthread_mutex_t *mutex = (pthread_mutex_t *)handle;
- if(mutex)
- free(mutex);
+ free(mutex);
}

--
1.5.4.1.98.gf3293

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 08:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org