Hello,

this patch removes unnecessary double checks for isc_mem, which are scattered through the code.


This problem was mentioned yesterday (another) patch review:
https://www.redhat.com/archives/freeipa-devel/2012-March/msg00073.html

On 03/05/2012 12:32 PM, Adam Tkac wrote:
>> >  +        REQUIRE(mctx != NULL);
> REQUIRE(mctx != NULL); is not needed, every isc_mem_* function checks mctx
> validity.

I checked each REQUIRE(mctx != NULL) and reference to "mctx" and Adam is right :-D

--
Petr^2 Spacek
>From 15305dc1707dfa64dba993d33dfb7714b45d8362 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Tue, 6 Mar 2012 13:30:05 +0100
Subject: [PATCH] Remove unnecessary mctx double checks. Signed-off-by: Petr
 Spacek <pspa...@redhat.com>

---
 src/ldap_convert.c  |    1 -
 src/ldap_driver.c   |    3 ---
 src/ldap_helper.c   |    4 ----
 src/rdlist.c        |    3 ---
 src/str.c           |    1 -
 src/zone_manager.c  |    1 -
 src/zone_register.c |    4 ----
 7 files changed, 0 insertions(+), 17 deletions(-)

diff --git a/src/ldap_convert.c b/src/ldap_convert.c
index 71d930d..6405a98 100644
--- a/src/ldap_convert.c
+++ b/src/ldap_convert.c
@@ -77,7 +77,6 @@ dn_to_dnsname(isc_mem_t *mctx, const char *dn, dns_name_t *target,
 	ld_string_t *ostr = NULL;
 	isc_buffer_t buffer;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(dn != NULL);
 
 	INIT_BUFFERED_NAME(name);
diff --git a/src/ldap_driver.c b/src/ldap_driver.c
index 02d1cee..9e4522e 100644
--- a/src/ldap_driver.c
+++ b/src/ldap_driver.c
@@ -205,8 +205,6 @@ clone_rdatalist_to_rdataset(isc_mem_t *mctx, dns_rdatalist_t *rdlist,
 	isc_result_t result;
 	dns_rdatalist_t *new_rdlist = NULL;
 
-	REQUIRE(mctx != NULL);
-
 	CHECK(rdatalist_clone(mctx, rdlist, &new_rdlist));
 
 	CHECK(dns_rdatalist_tordataset(new_rdlist, rdataset));
@@ -1295,7 +1293,6 @@ dynamic_driver_init(isc_mem_t *mctx, const char *name, const char * const *argv,
 {
 	isc_result_t result;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(name != NULL);
 	REQUIRE(argv != NULL);
 	REQUIRE(dyndb_args != NULL);
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index 21c3690..2cb4dab 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -341,7 +341,6 @@ new_ldap_instance(isc_mem_t *mctx, const char *db_name,
 		end_of_settings
 	};
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(ldap_instp != NULL && *ldap_instp == NULL);
 
 	ldap_inst = isc_mem_get(mctx, sizeof(ldap_instance_t));
@@ -1339,7 +1338,6 @@ ldapdb_nodelist_get(isc_mem_t *mctx, ldap_instance_t *ldap_inst, dns_name_t *nam
 	ldapdb_node_t *node;
 	dns_name_t node_name;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(ldap_inst != NULL);
 	REQUIRE(name != NULL);
 	REQUIRE(nodelist != NULL);
@@ -1408,7 +1406,6 @@ ldapdb_rdatalist_get(isc_mem_t *mctx, ldap_instance_t *ldap_inst, dns_name_t *na
 	ld_string_t *string = NULL;
 	ldap_cache_t *cache;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(ldap_inst != NULL);
 	REQUIRE(name != NULL);
 	REQUIRE(rdatalist != NULL);
@@ -1505,7 +1502,6 @@ parse_rdata(isc_mem_t *mctx, ldap_connection_t *ldap_conn,
 	isc_region_t rdatamem;
 	dns_rdata_t *rdata;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(ldap_conn != NULL);
 	REQUIRE(rdata_text != NULL);
 	REQUIRE(rdatap != NULL);
diff --git a/src/rdlist.c b/src/rdlist.c
index 71ca752..903c948 100644
--- a/src/rdlist.c
+++ b/src/rdlist.c
@@ -40,7 +40,6 @@ rdata_clone(isc_mem_t *mctx, dns_rdata_t *source, dns_rdata_t **targetp)
 	dns_rdata_t *target = NULL;
 	isc_region_t target_region, source_region;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(source != NULL);
 	REQUIRE(targetp != NULL && *targetp == NULL);
 
@@ -76,7 +75,6 @@ rdatalist_clone(isc_mem_t *mctx, dns_rdatalist_t *source,
 	dns_rdata_t *target_rdata;
 	isc_result_t result;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(source != NULL);
 	REQUIRE(targetp != NULL && *targetp == NULL);
 
@@ -116,7 +114,6 @@ ldap_rdatalist_copy(isc_mem_t *mctx, ldapdb_rdatalist_t source,
 	dns_rdatalist_t *new_rdlist;
 	isc_result_t result;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(target != NULL);
 
 	INIT_LIST(*target);
diff --git a/src/str.c b/src/str.c
index 56faa12..0096536 100644
--- a/src/str.c
+++ b/src/str.c
@@ -145,7 +145,6 @@ str__new(isc_mem_t *mctx, ld_string_t **new_str _STR_MEM_FLARG)
 {
 	ld_string_t *str;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(new_str != NULL && *new_str == NULL);
 
 #if ISC_MEM_TRACKLINES
diff --git a/src/zone_manager.c b/src/zone_manager.c
index c8a144f..eb761aa 100644
--- a/src/zone_manager.c
+++ b/src/zone_manager.c
@@ -124,7 +124,6 @@ manager_create_db_instance(isc_mem_t *mctx, const char *name,
 		end_of_settings
 	};
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(name != NULL);
 	REQUIRE(dyndb_args != NULL);
 
diff --git a/src/zone_register.c b/src/zone_register.c
index adbe934..fc6dc07 100644
--- a/src/zone_register.c
+++ b/src/zone_register.c
@@ -70,7 +70,6 @@ zr_create(isc_mem_t *mctx, zone_register_t **zrp)
 	isc_result_t result;
 	zone_register_t *zr = NULL;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(zrp != NULL && *zrp == NULL);
 
 	CHECKED_MEM_GET_PTR(mctx, zr);
@@ -124,7 +123,6 @@ create_zone_info(isc_mem_t *mctx, dns_zone_t *zone, const char *dn,
 	isc_result_t result;
 	zone_info_t *zinfo;
 
-	REQUIRE(mctx != NULL);
 	REQUIRE(zone != NULL);
 	REQUIRE(dn != NULL);
 	REQUIRE(zinfop != NULL && *zinfop == NULL);
@@ -152,8 +150,6 @@ delete_zone_info(void *arg1, void *arg2)
 	zone_info_t *zinfo = arg1;
 	isc_mem_t *mctx = arg2;
 
-	REQUIRE(mctx != NULL);
-
 	if (zinfo == NULL)
 		return;
 
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to