Skip to content

Commit

Permalink
Remove all uses of the NT_STATUS_NOT_OK_RETURN_AND_FREE macro from th…
Browse files Browse the repository at this point in the history
…e 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: I421e169275fe323e2b019c6cc5d386289aec07f7
Signed-off-by: Garming Sam <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
  • Loading branch information
GSam authored and cryptomilk committed Mar 5, 2014
1 parent 856c74e commit 0b8213a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
10 changes: 8 additions & 2 deletions source3/auth/auth_samba4.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,16 @@ static NTSTATUS check_samba4_security(const struct auth_context *auth_context,
NT_STATUS_NOT_OK_RETURN(nt_status);

nt_status = auth_context_set_challenge(auth4_context, auth_context->challenge.data, "auth_samba4");
NT_STATUS_NOT_OK_RETURN_AND_FREE(nt_status, auth4_context);
if (!NT_STATUS_IS_OK(nt_status)) {
TALLOC_FREE(auth4_context);
return nt_status;
}

nt_status = auth_check_password(auth4_context, auth4_context, user_info, &user_info_dc);
NT_STATUS_NOT_OK_RETURN_AND_FREE(nt_status, auth4_context);
if (!NT_STATUS_IS_OK(nt_status)) {
TALLOC_FREE(auth4_context);
return nt_status;
}

nt_status = auth_convert_user_info_dc_saminfo3(mem_ctx,
user_info_dc,
Expand Down
5 changes: 4 additions & 1 deletion source4/auth/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ _PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx,
sids,
session_info_flags,
&session_info->security_token);
NT_STATUS_NOT_OK_RETURN_AND_FREE(nt_status, tmp_ctx);
if (!NT_STATUS_IS_OK(nt_status)) {
TALLOC_FREE(tmp_ctx);
return nt_status;
}

session_info->credentials = NULL;

Expand Down
15 changes: 12 additions & 3 deletions source4/ntvfs/posix/pvfs_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,10 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
talloc_free(tmp_ctx);
return NT_STATUS_OK;
}
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
}

switch (acl->version) {
case 1:
Expand Down Expand Up @@ -979,7 +982,10 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
ids[1].status = ID_UNKNOWN;

status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
}

sd->owner_sid = talloc_steal(sd, ids[0].sid);
sd->group_sid = talloc_steal(sd, ids[1].sid);
Expand All @@ -988,7 +994,10 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,

/* fill in the aces from the parent */
status = pvfs_acl_inherit_aces(pvfs, parent_sd, sd, container);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
}

/* if there is nothing to inherit then we fallback to the
default acl */
Expand Down
5 changes: 4 additions & 1 deletion source4/rpc_server/lsa/dcesrv_lsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ static NTSTATUS dcesrv_build_lsa_sd(TALLOC_CTX *mem_ctx,
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);

status = dom_sid_split_rid(tmp_ctx, sid, &domain_sid, &rid);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
}

domain_admins_sid = dom_sid_add_rid(tmp_ctx, domain_sid, DOMAIN_RID_ADMINS);
if (domain_admins_sid == NULL) {
Expand Down
5 changes: 4 additions & 1 deletion source4/torture/util_smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,10 @@ NTSTATUS torture_check_privilege(struct smbcli_state *cli,
}

status = dom_sid_split_rid(tmp_ctx, sid, NULL, &rid);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
}

if (rid == DOMAIN_RID_ADMINISTRATOR) {
/* assume the administrator has them all */
Expand Down
5 changes: 4 additions & 1 deletion source4/wrepl_server/wrepl_in_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ static NTSTATUS wreplsrv_in_update(struct wreplsrv_in_call *call)
TALLOC_FREE(wrepl_in->send_queue);

status = wrepl_socket_donate_stream(wrepl_out->sock, &wrepl_in->tstream);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, update_state);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(update_state);
return status;
}

update_state->wrepl_in = wrepl_in;
update_state->wrepl_out = wrepl_out;
Expand Down

0 comments on commit 0b8213a

Please sign in to comment.