]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
librpc: Simplify GUID_hexstring()
authorVolker Lendecke <vl@samba.org>
Wed, 18 Aug 2021 04:21:52 +0000 (06:21 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 24 Aug 2021 17:32:28 +0000 (17:32 +0000)
A temporary talloc context seems unnecessary to me.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
librpc/ndr/uuid.c

index f7753a85f1a8d0b54e96fb155e6744f92f95342e..6a8d31e065fe3a29eb467521ff40da319ab34206 100644 (file)
@@ -230,23 +230,15 @@ _PUBLIC_ char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid)
 
 _PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
 {
-       char *ret;
-       DATA_BLOB guid_blob;
-       TALLOC_CTX *tmp_mem;
+       char *ret = NULL;
+       DATA_BLOB guid_blob = { .data = NULL };
        NTSTATUS status;
 
-       tmp_mem = talloc_new(mem_ctx);
-       if (!tmp_mem) {
-               return NULL;
+       status = GUID_to_ndr_blob(guid, mem_ctx, &guid_blob);
+       if (NT_STATUS_IS_OK(status)) {
+               ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
        }
-       status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
-       if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(tmp_mem);
-               return NULL;
-       }
-
-       ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
-       talloc_free(tmp_mem);
+       TALLOC_FREE(guid_blob.data);
        return ret;
 }