diff options
author | Garming Sam <garming@catalyst.net.nz> | 2014-02-13 17:51:11 +1300 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2014-03-05 16:33:21 +0100 |
commit | 952bc3cad05467959ba5aa08682d754bd80d543b (patch) | |
tree | ec59adb15fc07fbc6c50b9eeeeb17a7dada26905 /dfs_server | |
parent | 1f60aa8ec2e685517235aadbc11324d3b4a1a74d (diff) | |
download | samba-952bc3cad05467959ba5aa08682d754bd80d543b.tar.gz samba-952bc3cad05467959ba5aa08682d754bd80d543b.tar.xz samba-952bc3cad05467959ba5aa08682d754bd80d543b.zip |
Remove a number of NT_STATUS_HAVE_NO_MEMORY_AND_FREE macros from the codebase.
Following the current coding guidelines, it is considered bad practice to return from
within a macro and change control flow as they look like normal function calls.
Change-Id: I133eb5a699757ae57b87d3bd3ebbcf5b556b0268
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'dfs_server')
-rw-r--r-- | dfs_server/dfs_server_ad.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c index 062eb495ec..504ab799ba 100644 --- a/dfs_server/dfs_server_ad.c +++ b/dfs_server/dfs_server_ad.c @@ -198,11 +198,17 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb, * Search all the object of class server in this site */ dc_list = talloc_array(r, const char *, r->count); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(dc_list, r); + if (dc_list == NULL) { + TALLOC_FREE(r); + return NT_STATUS_NO_MEMORY; + } /* TODO put some random here in the order */ list->names = talloc_realloc(list, list->names, const char *, list->count + r->count); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(list->names, r); + if (list->names == NULL) { + TALLOC_FREE(r); + return NT_STATUS_NO_MEMORY; + } for (i = 0; i<r->count; i++) { struct ldb_dn *dn; @@ -230,7 +236,10 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb, } list->names[list->count] = talloc_strdup(list->names, dns); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(list->names[list->count], r); + if (list->names[list->count] == NULL) { + TALLOC_FREE(r); + return NT_STATUS_NO_MEMORY; + } } else { char *tmp; const char *aname = ldb_msg_find_attr_as_string(msg, "sAMAccountName", NULL); @@ -242,7 +251,10 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb, } tmp = talloc_strdup(list->names, aname); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(tmp, r); + if (tmp == NULL) { + TALLOC_FREE(r); + return NT_STATUS_NO_MEMORY; + } /* Netbios name is also the sAMAccountName for computer but without the final $ */ @@ -335,10 +347,16 @@ static NTSTATUS get_dcs(TALLOC_CTX *ctx, struct ldb_context *ldb, sitedn = r->msgs[0]->dn; set_list = talloc_realloc(subctx, set_list, struct dc_set *, current_pos+1); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(set_list, subctx); + if (set_list == NULL) { + TALLOC_FREE(subctx); + return NT_STATUS_NO_MEMORY; + } set_list[current_pos] = talloc(set_list, struct dc_set); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(set_list[current_pos], subctx); + if (set_list[current_pos] == NULL) { + TALLOC_FREE(subctx); + return NT_STATUS_NO_MEMORY; + } set_list[current_pos]->names = NULL; set_list[current_pos]->count = 0; @@ -384,10 +402,16 @@ static NTSTATUS get_dcs(TALLOC_CTX *ctx, struct ldb_context *ldb, */ set_list = talloc_realloc(subctx, set_list, struct dc_set *, current_pos+2); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(set_list, subctx); + if (set_list == NULL) { + TALLOC_FREE(subctx); + return NT_STATUS_NO_MEMORY; + } set_list[current_pos] = talloc(ctx, struct dc_set); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(set_list[current_pos], subctx); + if (set_list[current_pos] == NULL) { + TALLOC_FREE(subctx); + return NT_STATUS_NO_MEMORY; + } set_list[current_pos]->names = NULL; set_list[current_pos]->count = 0; |