From 29c655c0a6affc0359e499162e8308663eb4d04f Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 11 Mar 2015 17:41:01 +0100 Subject: Bug #149: Deletion of unnecessary checks before calls of the function "free" The function "free" is documented in the way that no action shall occur for a passed null pointer. It is therefore not needed that a function caller repeats a corresponding check. http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first This issue was fixed by using the software Coccinelle 1.0.0-rc24. Signed-off-by: Markus Elfring --- tests/libtest/lib539.c | 3 +-- tests/libtest/lib568.c | 3 +-- tests/libtest/lib569.c | 4 +--- tests/libtest/lib570.c | 4 +--- tests/libtest/lib571.c | 4 +--- tests/libtest/lib572.c | 3 +-- tests/libtest/lib582.c | 6 ++---- 7 files changed, 8 insertions(+), 19 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index 923893fb2..053d29806 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -83,8 +83,7 @@ int test(char *URL) test_cleanup: curl_slist_free_all(slist); - if(newURL) - free(newURL); + free(newURL); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 12fc5e5d9..b6f5ab7ca 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -159,8 +159,7 @@ test_cleanup: if(sdpf) fclose(sdpf); - if(stream_uri) - free(stream_uri); + free(stream_uri); if(custom_headers) curl_slist_free_all(custom_headers); diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 222f1e024..bc4887276 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -115,9 +115,7 @@ test_cleanup: if(idfile) fclose(idfile); - if(stream_uri) - free(stream_uri); - + free(stream_uri); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 93ccab8ea..178f58f96 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -102,9 +102,7 @@ int test(char *URL) } test_cleanup: - - if(stream_uri) - free(stream_uri); + free(stream_uri); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 3270300de..d8dad396b 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -195,9 +195,7 @@ int test(char *URL) } test_cleanup: - - if(stream_uri) - free(stream_uri); + free(stream_uri); if(protofile) fclose(protofile); diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 9b23c01a2..fd547b8b3 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -165,8 +165,7 @@ test_cleanup: if(paramsf) fclose(paramsf); - if(stream_uri) - free(stream_uri); + free(stream_uri); if(custom_headers) curl_slist_free_all(custom_headers); diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 952efb4ed..4c3ea6f60 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -357,10 +357,8 @@ test_cleanup: fclose(hd_src); /* free local memory */ - if(sockets.read.sockets) - free(sockets.read.sockets); - if(sockets.write.sockets) - free(sockets.write.sockets); + free(sockets.read.sockets); + free(sockets.write.sockets); return res; } -- cgit v1.2.3