From: Volker Lendecke Date: Tue, 21 Aug 2018 19:22:42 +0000 (+0200) Subject: libads: Simplify parse_spn() X-Git-Tag: tdb-1.3.17~2095 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb81fb2d93be7fdf5081a057e4d70d9f53a72df3;p=thirdparty%2Fsamba.git libads: Simplify parse_spn() A few lines less and quite some bytes less .text Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Aug 22 03:59:51 CEST 2018 on sn-devel-144 --- diff --git a/source3/libads/util.c b/source3/libads/util.c index f387ca60bf7..354125b74fe 100644 --- a/source3/libads/util.c +++ b/source3/libads/util.c @@ -166,8 +166,7 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc) result->serviceclass = talloc_strdup(result, srvprinc); if (result->serviceclass == NULL) { DBG_ERR("Out of memory\n"); - TALLOC_FREE(result); - goto out; + goto fail; } result->port = -1; @@ -176,8 +175,7 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc) /* illegal */ DBG_ERR("Failed to parse spn %s, no host definition\n", srvprinc); - TALLOC_FREE(result); - goto out; + goto fail; } /* terminate service principal */ @@ -205,23 +203,20 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc) /* illegal */ DBG_ERR("Failed to parse spn %s, illegal host definition\n", srvprinc); - TALLOC_FREE(result); - goto out; + goto fail; } result->host = host_str; if (result->servicename != NULL && (strlen(result->servicename) == 0)) { DBG_ERR("Failed to parse spn %s, empty servicename " "definition\n", srvprinc); - TALLOC_FREE(result); - goto out; + goto fail; } if (port_str != NULL) { if (strlen(port_str) == 0) { DBG_ERR("Failed to parse spn %s, empty port " "definition\n", srvprinc); - TALLOC_FREE(result); - goto out; + goto fail; } result->port = (int32_t)strtol(port_str, NULL, 10); if (result->port <= 0 @@ -230,10 +225,11 @@ struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc) DBG_ERR("Failed to parse spn %s, port number " "convertion failed\n", srvprinc); errno = 0; - TALLOC_FREE(result); - goto out; + goto fail; } } -out: return result; +fail: + TALLOC_FREE(result); + return NULL; }