]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libndr: Use TALLOC_FREE instead of talloc_free
authorVolker Lendecke <vl@samba.org>
Thu, 12 Sep 2024 14:18:57 +0000 (16:18 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 20 Sep 2024 17:13:37 +0000 (17:13 +0000)
All the existing calls are right before returns, so they don't really
matter. But you never know when the code will change, and any compiler
will wipe the NULL assignment.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
librpc/ndr/libndr.h
librpc/ndr/ndr.c
librpc/ndr/ndr_cab.c
librpc/ndr/ndr_compression.c
librpc/ndr/ndr_drsblobs.c
librpc/ndr/ndr_drsuapi.c
librpc/ndr/ndr_sec_helper.c
librpc/ndr/ndr_spoolss_buf.c
librpc/ndr/ndr_string.c

index 61e660550eb47cc895e272d2b62c2950b08d30ef..21c71f1a022919496ad6e2f94fcdd9244b1db531 100644 (file)
@@ -478,7 +478,7 @@ enum ndr_compression_alg {
        enum ndr_err_code _status; \
        _status = call; \
        if (unlikely(!NDR_ERR_CODE_IS_SUCCESS(_status))) {      \
-               talloc_free(ndr);                \
+               TALLOC_FREE(ndr);                \
                return _status; \
        } \
 } while (0)
index d3494c54e71cb2f2010d4afd44e3a9cda9593562..1916b6db7b84400585a342f9951fa4e3f6890973 100644 (file)
@@ -238,7 +238,7 @@ _PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
        ndr->alloc_size = NDR_BASE_MARSHALL_SIZE;
        ndr->data = talloc_array(ndr, uint8_t, ndr->alloc_size);
        if (!ndr->data) {
-               talloc_free(ndr);
+               TALLOC_FREE(ndr);
                return NULL;
        }
 
@@ -425,7 +425,7 @@ _PUBLIC_ void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *na
 #endif
 
        fn(ndr, name, ptr);
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
 }
 
 /*
@@ -461,7 +461,7 @@ _PUBLIC_ bool ndr_print_debug(int level,
 
        ret = true;
 fail:
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return ret;
 }
 
@@ -487,7 +487,7 @@ _PUBLIC_ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_
 
        ndr_print_set_switch_value(ndr, ptr, level);
        fn(ndr, name, ptr);
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
 }
 
 /*
@@ -511,7 +511,7 @@ _PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name
 #endif
 
        fn(ndr, name, flags, ptr);
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
 }
 
 /*
@@ -535,7 +535,7 @@ _PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, c
        fn(ndr, name, ptr);
        ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
 failed:
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return ret;
 }
 
@@ -560,7 +560,7 @@ _PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, co
        fn(ndr, name, ptr);
        ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
 failed:
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return ret;
 }
 
@@ -586,7 +586,7 @@ _PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
        fn(ndr, name, flags, ptr);
        ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
 failed:
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return ret;
 }
 
@@ -901,7 +901,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr,
 
                status = ndr_push_zero(subndr, size_is);
                if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
-                       talloc_free(subndr);
+                       TALLOC_FREE(subndr);
                        return status;
                }
                subndr->offset = 0;
@@ -1337,7 +1337,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CT
        ndr = ndr_pull_init_blob(blob, mem_ctx);
        NDR_ERR_HAVE_NO_MEMORY(ndr);
        NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return NDR_ERR_SUCCESS;
 }
 
@@ -1362,10 +1362,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
                ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
                                     "not all bytes consumed ofs[%"PRIu32"] size[%"PRIu32"]",
                                     highest_ofs, ndr->data_size);
-               talloc_free(ndr);
+               TALLOC_FREE(ndr);
                return ret;
        }
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return NDR_ERR_SUCCESS;
 }
 
@@ -1446,7 +1446,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX
        NDR_ERR_HAVE_NO_MEMORY(ndr);
        NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
        NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return NDR_ERR_SUCCESS;
 }
 
@@ -1474,10 +1474,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC
                ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
                                     "not all bytes consumed ofs[%"PRIu32"] size[%"PRIu32"]",
                                     highest_ofs, ndr->data_size);
-               talloc_free(ndr);
+               TALLOC_FREE(ndr);
                return ret;
        }
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return NDR_ERR_SUCCESS;
 }
 
@@ -1494,7 +1494,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem
 
        *blob = ndr_push_blob(ndr);
        talloc_steal(mem_ctx, blob->data);
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
 
        return NDR_ERR_SUCCESS;
 }
@@ -1543,7 +1543,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_
 
        *blob = ndr_push_blob(ndr);
        talloc_steal(mem_ctx, blob->data);
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
 
        return NDR_ERR_SUCCESS;
 }
@@ -1570,11 +1570,11 @@ _PUBLIC_ size_t ndr_size_struct(const void *p, libndr_flags flags, ndr_push_flag
        ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE;
        status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p));
        if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
-               talloc_free(ndr);
+               TALLOC_FREE(ndr);
                return 0;
        }
        ret = ndr->offset;
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return ret;
 }
 
@@ -1601,16 +1601,16 @@ _PUBLIC_ size_t ndr_size_union(const void *p, libndr_flags flags, uint32_t level
 
        status = ndr_push_set_switch_value(ndr, p, level);
        if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
-               talloc_free(ndr);
+               TALLOC_FREE(ndr);
                return 0;
        }
        status = push(ndr, NDR_SCALARS|NDR_BUFFERS, p);
        if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
-               talloc_free(ndr);
+               TALLOC_FREE(ndr);
                return 0;
        }
        ret = ndr->offset;
-       talloc_free(ndr);
+       TALLOC_FREE(ndr);
        return ret;
 }
 
index ae3353bc25c61ef7d32d6d4962dce40c21fb527a..7b78a7df6c26c9dc388fc26e1fba4883ae3261c4 100644 (file)
@@ -36,7 +36,7 @@ _PUBLIC_ void ndr_print_cf_time(struct ndr_print *ndr, const char *name, const s
        s = talloc_asprintf(ndr, "%02d:%02d:%02d", hour, minute, seconds);
        if (s == NULL) { return; }
        ndr_print_string(ndr, "time", s);
-       talloc_free(s);
+       TALLOC_FREE(s);
 }
 
 _PUBLIC_ void ndr_print_cf_date(struct ndr_print *ndr, const char *name, const struct cf_date *r)
@@ -52,7 +52,7 @@ _PUBLIC_ void ndr_print_cf_date(struct ndr_print *ndr, const char *name, const s
        s = talloc_asprintf(ndr, "%02"PRIu8"/%02"PRIu8"/%04"PRIu16, day, month, year);
        if (s == NULL) { return; }
        ndr_print_string(ndr, "date", s);
-       talloc_free(s);
+       TALLOC_FREE(s);
 }
 
 uint32_t ndr_count_cfdata(const struct cab_file *r)
index 04d810a5cb313ae533147941c48d94da61c5a7f8..fb52bc81e88484faaa55aae4bf5bddba907e2856 100644 (file)
@@ -48,7 +48,7 @@ static voidpf ndr_zlib_alloc(voidpf opaque, uInt items, uInt size)
 
 static void  ndr_zlib_free(voidpf opaque, voidpf address)
 {
-       talloc_free(address);
+       TALLOC_FREE(address);
 }
 
 static enum ndr_err_code ndr_pull_compression_mszip_cab_chunk(struct ndr_pull *ndrpull,
@@ -974,7 +974,7 @@ enum ndr_err_code ndr_push_compression_end(struct ndr_push *subndr,
                                      compression_alg);
        }
 
-       talloc_free(uncomndr);
+       TALLOC_FREE(uncomndr);
        return NDR_ERR_SUCCESS;
 }
 
index b6eea1757d06acfb62362f014d19f9afe61e6692..ad4af4f338ddf1c88b0f5b6cb18cfaf46dd9fb57 100644 (file)
@@ -142,8 +142,8 @@ _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const c
                        ndr->depth++;
                        ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
                        ndr->depth--;
-                       talloc_free(hex_str);
-                       talloc_free(partial_oid);
+                       TALLOC_FREE(hex_str);
+                       TALLOC_FREE(partial_oid);
                }
                ndr->depth--;
                ndr->flags = _flags_save_STRUCT;
index 63d1d74b6e8c7813a800e463bd3c383a021dd2e8..787347fbf4d20620ec3b729ea49815379f15f698 100644 (file)
@@ -81,8 +81,8 @@ _PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *
                ndr->depth++;
                ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
                ndr->depth--;
-               talloc_free(hex_str);
-               talloc_free(partial_oid);
+               TALLOC_FREE(hex_str);
+               TALLOC_FREE(partial_oid);
        }
        ndr->depth--;
 }
@@ -125,7 +125,7 @@ static void _print_drsuapi_DsAttributeValue_str(struct ndr_print *ndr, const cha
        } else {
                char *str = (char *)p;
                ndr_print_string(ndr, "string", str);
-               talloc_free(str);
+               TALLOC_FREE(str);
        }
        ndr->depth--;
 }
@@ -223,7 +223,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr,
                                        NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed));
                                }
                                compressed_length = _ndr_ts->offset;
-                               talloc_free(_ndr_ts);
+                               TALLOC_FREE(_ndr_ts);
                        }
                }
                NDR_CHECK(ndr_push_align(ndr, 4));
@@ -268,7 +268,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr,
                                        NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed));
                                }
                                compressed_length = _ndr_ts->offset;
-                               talloc_free(_ndr_ts);
+                               TALLOC_FREE(_ndr_ts);
                        }
                }
                NDR_CHECK(ndr_push_align(ndr, 4));
@@ -313,7 +313,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesWIN2K3_LZ77_DIRECT2Ctr1(struct
                                        NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed));
                                }
                                compressed_length = _ndr_ts->offset;
-                               talloc_free(_ndr_ts);
+                               TALLOC_FREE(_ndr_ts);
                        }
                }
                NDR_CHECK(ndr_push_align(ndr, 4));
@@ -358,7 +358,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesWIN2K3_LZ77_DIRECT2Ctr6(struct
                                        NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed));
                                }
                                compressed_length = _ndr_ts->offset;
-                               talloc_free(_ndr_ts);
+                               TALLOC_FREE(_ndr_ts);
                        }
                }
                NDR_CHECK(ndr_push_align(ndr, 4));
index 028d11c2a83ea22a1585713362c55445e16ceeb1..7f95f1423d78f71b3ef9e0bb33dcb87ef50f4109 100644 (file)
@@ -336,7 +336,7 @@ enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, ndr_flags_type ndr_fl
 
        status = ndr_pull_advance(ndr, 28);
        if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
-               talloc_free(subndr);
+               TALLOC_FREE(subndr);
                return status;
        }
 
@@ -348,7 +348,7 @@ enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, ndr_flags_type ndr_fl
                ZERO_STRUCT(sid->sub_auths);
        }
 
-       talloc_free(subndr);
+       TALLOC_FREE(subndr);
        return NDR_ERR_SUCCESS;
 }
 
index abeb8847f3745812fc775519fabd40505158dbc4..60579893c4afcdb59b062e5f1460461dab68d59e 100644 (file)
@@ -1579,7 +1579,7 @@ _PUBLIC_ void ndr_print_spoolss_Time(struct ndr_print *ndr, const char *name, co
        ndr->depth++;
        ndr_print_string(ndr, "", str);
        ndr->depth--;
-       talloc_free(str);
+       TALLOC_FREE(str);
 }
 
 _PUBLIC_ libndr_flags ndr_spoolss_PrinterEnumValues_align(enum winreg_Type type)
index 323886b2fe5cbad4a9e3549cbdb0f60c295d7b1e..96272d679c00e53ce6f73162c20c29b3a16ac123 100644 (file)
@@ -419,7 +419,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, ndr_flags_type
        }
 
 out:
-       talloc_free(dest_to_free);
+       TALLOC_FREE(dest_to_free);
        return ndr_err;
 }