From: Isaac Boukris Date: Wed, 18 Sep 2019 17:00:34 +0000 (+0300) Subject: libnet_join_set_machine_spn: improve style and make a bit room for indentation X-Git-Tag: talloc-2.3.1~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cbad1eb46896bbd74c5b19dbb0a8937ffde90c2;p=thirdparty%2Fsamba.git libnet_join_set_machine_spn: improve style and make a bit room for indentation BUG: https://bugzilla.samba.org/show_bug.cgi?id=14116 Signed-off-by: Isaac Boukris Reviewed-by: Ralph Boehme Reviewed-by: Alexander Bokovoy --- diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 818b3039cb9..67ab50c68a8 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -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 */