s3:param: remove the double initialization in add_a_service
authorGarming Sam <garming@catalyst.net.nz>
Tue, 18 Feb 2014 01:38:10 +0000 (14:38 +1300)
committerJeremy Allison <jra@samba.org>
Wed, 7 May 2014 17:49:15 +0000 (19:49 +0200)
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/param/loadparm.c

index 49fc21a26684e05966d85d81ca445c7fa07c2b1d..7ba68a68297d1e255b4ebf30e82770314b452dce 100644 (file)
@@ -1539,12 +1539,9 @@ static void free_service_byindex(int idx)
 static int add_a_service(const struct loadparm_service *pservice, const char *name)
 {
        int i;
-       struct loadparm_service tservice;
        int num_to_alloc = iNumServices + 1;
        struct loadparm_service **tsp = NULL;
 
-       tservice = *pservice;
-
        /* it might already exist */
        if (name) {
                i = getservicebyname(name, NULL);
@@ -1561,7 +1558,7 @@ static int add_a_service(const struct loadparm_service *pservice, const char *na
                return (-1);
        }
        ServicePtrs = tsp;
-       ServicePtrs[iNumServices] = talloc(NULL, struct loadparm_service);
+       ServicePtrs[iNumServices] = talloc_zero(NULL, struct loadparm_service);
        if (!ServicePtrs[iNumServices]) {
                DEBUG(0,("add_a_service: out of memory!\n"));
                return (-1);
@@ -1570,8 +1567,7 @@ static int add_a_service(const struct loadparm_service *pservice, const char *na
 
        ServicePtrs[i]->valid = true;
 
-       init_service(ServicePtrs[i]);
-       copy_service(ServicePtrs[i], &tservice, NULL);
+       copy_service(ServicePtrs[i], pservice, NULL);
        if (name)
                string_set(ServicePtrs[i], &ServicePtrs[i]->szService, name);