summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-08-21 21:22:42 +0200
committerJeremy Allison <jra@samba.org>2018-08-22 03:59:51 +0200
commitfb81fb2d93be7fdf5081a057e4d70d9f53a72df3 (patch)
treed8ca720770d1fe60d892b3bc239d64f7897efeed /source3/libads
parent75ced0d15514b2d4707eb1813c461f135d9d20bf (diff)
downloadsamba-fb81fb2d93be7fdf5081a057e4d70d9f53a72df3.tar.gz
libads: Simplify parse_spn()
A few lines less and quite some bytes less .text Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Aug 22 03:59:51 CEST 2018 on sn-devel-144
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/util.c22
1 files changed, 9 insertions, 13 deletions
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;
}