summaryrefslogtreecommitdiffstats
path: root/source4
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2014-02-13 18:08:56 +1300
committerAndreas Schneider <asn@cryptomilk.org>2014-03-05 16:33:21 +0100
commitd2beff59ecd50ef2e77684bd0043c3d943a3b245 (patch)
treeba1c9f49b8ec8af484f2a3139c849f3e6280d2a1 /source4
parent952bc3cad05467959ba5aa08682d754bd80d543b (diff)
downloadsamba-d2beff59ecd50ef2e77684bd0043c3d943a3b245.tar.gz
samba-d2beff59ecd50ef2e77684bd0043c3d943a3b245.tar.xz
samba-d2beff59ecd50ef2e77684bd0043c3d943a3b245.zip
Remove the remaining uses of the macro NT_STATUS_HAVE_NO_MEMORY_AND_FREE in 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: Id1b540cde127395a7b27385a7c0fe79f3a145c73 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 'source4')
-rw-r--r--source4/auth/sam.c42
-rw-r--r--source4/dsdb/kcc/kcc_topology.c18
2 files changed, 40 insertions, 20 deletions
diff --git a/source4/auth/sam.c b/source4/auth/sam.c
index 1b563ee115..ac1986230a 100644
--- a/source4/auth/sam.c
+++ b/source4/auth/sam.c
@@ -390,8 +390,10 @@ _PUBLIC_ NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx,
ldb_msg_find_attr_as_string(msg, "sAMAccountName", NULL));
info->domain_name = talloc_strdup(info, domain_name);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(info->domain_name,
- user_info_dc);
+ if (info->domain_name == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
str = ldb_msg_find_attr_as_string(msg, "displayName", "");
info->full_name = talloc_strdup(info, str);
@@ -402,18 +404,24 @@ _PUBLIC_ NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx,
str = ldb_msg_find_attr_as_string(msg, "scriptPath", "");
info->logon_script = talloc_strdup(info, str);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(info->logon_script,
- user_info_dc);
+ if (info->logon_script == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
str = ldb_msg_find_attr_as_string(msg, "profilePath", "");
info->profile_path = talloc_strdup(info, str);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(info->profile_path,
- user_info_dc);
+ if (info->profile_path == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
str = ldb_msg_find_attr_as_string(msg, "homeDirectory", "");
info->home_directory = talloc_strdup(info, str);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(info->home_directory,
- user_info_dc);
+ if (info->home_directory == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
str = ldb_msg_find_attr_as_string(msg, "homeDrive", "");
info->home_drive = talloc_strdup(info, str);
@@ -423,8 +431,10 @@ _PUBLIC_ NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx,
}
info->logon_server = talloc_strdup(info, netbios_name);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(info->logon_server,
- user_info_dc);
+ if (info->logon_server == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
info->last_logon = samdb_result_nttime(msg, "lastLogon", 0);
info->last_logoff = samdb_result_last_logoff(msg);
@@ -448,15 +458,19 @@ _PUBLIC_ NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx,
user_sess_key.data,
user_sess_key.length);
if (user_sess_key.data) {
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(user_info_dc->user_session_key.data,
- user_info_dc);
+ if (user_info_dc->user_session_key.data == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
}
user_info_dc->lm_session_key = data_blob_talloc(user_info_dc,
lm_sess_key.data,
lm_sess_key.length);
if (lm_sess_key.data) {
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(user_info_dc->lm_session_key.data,
- user_info_dc);
+ if (user_info_dc->lm_session_key.data == NULL) {
+ TALLOC_FREE(user_info_dc);
+ return NT_STATUS_NO_MEMORY;
+ }
}
if (info->acct_flags & ACB_SVRTRUST) {
diff --git a/source4/dsdb/kcc/kcc_topology.c b/source4/dsdb/kcc/kcc_topology.c
index 258b73610c..2836199a69 100644
--- a/source4/dsdb/kcc/kcc_topology.c
+++ b/source4/dsdb/kcc/kcc_topology.c
@@ -1003,8 +1003,10 @@ static NTSTATUS kcctpl_setup_graph(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
graph->edge_sets.data,
struct kcctpl_multi_edge_set,
graph->edge_sets.count + 1);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data,
- tmp_ctx);
+ if (new_data == NULL) {
+ TALLOC_FREE(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
new_data[graph->edge_sets.count] = *edge_set;
graph->edge_sets.data = new_data;
graph->edge_sets.count++;
@@ -2655,8 +2657,10 @@ static NTSTATUS kcctpl_get_spanning_tree_edges(struct kccsrv_service *service,
vertex->edge_ids.data,
struct GUID,
vertex->edge_ids.count + 1);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data,
- tmp_ctx);
+ if (new_data == NULL) {
+ TALLOC_FREE(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
new_data[vertex->edge_ids.count] = edge->id;
vertex->edge_ids.data = new_data;
vertex->edge_ids.count++;
@@ -3136,8 +3140,10 @@ static NTSTATUS kcctpl_create_connection(struct kccsrv_service *service,
keep_connections.data,
struct GUID,
keep_connections.count + 1);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(new_data,
- tmp_ctx);
+ if (new_data == NULL) {
+ TALLOC_FREE(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
new_data[keep_connections.count] = conn_guid;
keep_connections.data = new_data;
keep_connections.count++;