libnet_join_set_machine_spn: improve style and make a bit room for indentation
authorIsaac Boukris <iboukris@gmail.com>
Wed, 18 Sep 2019 17:00:34 +0000 (20:00 +0300)
committerRalph Boehme <slow@samba.org>
Fri, 25 Oct 2019 09:21:44 +0000 (09:21 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14116

Signed-off-by: Isaac Boukris <iboukris@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/libnet/libnet_join.c

index 818b3039cb905dc907f7e775793e0beab72b871d..67ab50c68a8d78f7d68833de074db53c3befcd1a 100644 (file)
@@ -517,7 +517,7 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx,
        /* Windows only creates HOST/shortname & HOST/fqdn. */
 
        spn = talloc_asprintf(mem_ctx, "HOST/%s", r->in.machine_name);
-       if (!spn) {
+       if (spn == NULL) {
                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
        }
        if (!strupper_m(spn)) {
@@ -553,60 +553,59 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx,
                }
        }
 
-       netbios_aliases = lp_netbios_aliases();
-       if (netbios_aliases != NULL) {
-               for (; *netbios_aliases != NULL; netbios_aliases++) {
-                       /*
-                        * Add HOST/NETBIOSNAME
-                        */
-                       spn = talloc_asprintf(mem_ctx, "HOST/%s", *netbios_aliases);
-                       if (spn == NULL) {
-                               TALLOC_FREE(spn);
-                               return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
-                       }
-                       if (!strupper_m(spn)) {
-                               TALLOC_FREE(spn);
-                               return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
-                       }
+       for (netbios_aliases = lp_netbios_aliases();
+            netbios_aliases != NULL && *netbios_aliases != NULL;
+            netbios_aliases++) {
+               /*
+                * Add HOST/NETBIOSNAME
+                */
+               spn = talloc_asprintf(mem_ctx, "HOST/%s", *netbios_aliases);
+               if (spn == NULL) {
+                       TALLOC_FREE(spn);
+                       return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+               }
+               if (!strupper_m(spn)) {
+                       TALLOC_FREE(spn);
+                       return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+               }
 
-                       ok = ads_element_in_array(spn_array, num_spns, spn);
-                       if (ok) {
-                               TALLOC_FREE(spn);
-                               continue;
-                       }
-                       ok = add_string_to_array(spn_array, spn,
-                                                &spn_array, &num_spns);
-                       if (!ok) {
-                               TALLOC_FREE(spn);
-                               return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
-                       }
+               ok = ads_element_in_array(spn_array, num_spns, spn);
+               if (ok) {
+                       TALLOC_FREE(spn);
+                       continue;
+               }
+               ok = add_string_to_array(spn_array, spn,
+                                        &spn_array, &num_spns);
+               if (!ok) {
                        TALLOC_FREE(spn);
+                       return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+               }
+               TALLOC_FREE(spn);
 
-                       /*
-                        * Add HOST/netbiosname.domainname
-                        */
-                       fstr_sprintf(my_fqdn, "%s.%s",
-                                    *netbios_aliases,
-                                    lp_dnsdomain());
+               /*
+                * Add HOST/netbiosname.domainname
+                */
+               fstr_sprintf(my_fqdn, "%s.%s",
+                            *netbios_aliases,
+                            lp_dnsdomain());
 
-                       spn = talloc_asprintf(mem_ctx, "HOST/%s", my_fqdn);
-                       if (spn == NULL) {
-                               return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
-                       }
+               spn = talloc_asprintf(mem_ctx, "HOST/%s", my_fqdn);
+               if (spn == NULL) {
+                       return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+               }
 
-                       ok = ads_element_in_array(spn_array, num_spns, spn);
-                       if (ok) {
-                               TALLOC_FREE(spn);
-                               continue;
-                       }
-                       ok = add_string_to_array(spn_array, spn,
-                                                &spn_array, &num_spns);
-                       if (!ok) {
-                               TALLOC_FREE(spn);
-                               return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
-                       }
+               ok = ads_element_in_array(spn_array, num_spns, spn);
+               if (ok) {
+                       TALLOC_FREE(spn);
+                       continue;
+               }
+               ok = add_string_to_array(spn_array, spn,
+                                        &spn_array, &num_spns);
+               if (!ok) {
                        TALLOC_FREE(spn);
+                       return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
                }
+               TALLOC_FREE(spn);
        }
 
        /* make sure to NULL terminate the array */