r4508: - simplify the code and allocate only in one place
authorStefan Metzmacher <metze@samba.org>
Mon, 3 Jan 2005 14:45:17 +0000 (14:45 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:08:16 +0000 (13:08 -0500)
- the ZERO_STRUCT(r->out) is useless and wrong if we would have a [ref,out] parameter
  also note the r->out is already initialized by the pidl generated code

metze

source/rpc_server/dssetup/dcesrv_dssetup.c

index e3c33cc55343021d41297258e31d8110a7547df0..64f67b28f9183af3dc37798bf411bf675a54f8d7 100644 (file)
@@ -33,7 +33,10 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
                                                        TALLOC_CTX *mem_ctx,
                                                        struct dssetup_DsRoleGetPrimaryDomainInformation *r)
 {
-       ZERO_STRUCT(r->out);
+       union dssetup_DsRoleInfo *info;
+
+       info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
+       W_ERROR_HAVE_NO_MEMORY(info);
 
        switch (r->in.level) {
        case DS_ROLE_BASIC_INFORMATION:
@@ -42,7 +45,6 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
                const char * const attrs[] = { "dnsDomain", "nTMixedDomain", "objectGUID", "name", NULL };
                int ret;
                struct ldb_message **res;
-               union dssetup_DsRoleInfo *info;
                enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
                uint32 flags = 0;
                const char *domain = NULL;
@@ -52,9 +54,6 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
 
                ZERO_STRUCT(domain_guid);
 
-               info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
-               W_ERROR_HAVE_NO_MEMORY(info);
-
                switch (lp_server_role()) {
                case ROLE_STANDALONE:
                        role            = DS_ROLE_STANDALONE_SERVER;
@@ -120,11 +119,6 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
        }
        case DS_ROLE_UPGRADE_STATUS:
        {
-               union dssetup_DsRoleInfo *info;
-
-               info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
-               W_ERROR_HAVE_NO_MEMORY(info);
-
                info->upgrade.upgrading     = DS_ROLE_NOT_UPGRADING;
                info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
 
@@ -133,11 +127,6 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
        }
        case DS_ROLE_OP_STATUS:
        {
-               union dssetup_DsRoleInfo *info;
-
-               info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
-               W_ERROR_HAVE_NO_MEMORY(info);
-
                info->opstatus.status = DS_ROLE_OP_IDLE;
 
                r->out.info = info;