From: Volker Lendecke Date: Wed, 2 Aug 2017 15:52:40 +0000 (+0200) Subject: lib: Pass blob instead of &blob to gencache_set_data_blob X-Git-Tag: talloc-2.1.11~325 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=089cb9e24c47ccff492865bae9f7b895b78c5d02 lib: Pass blob instead of &blob to gencache_set_data_blob Passing a whole DATA_BLOB is cheap enough to simplify the callers: A caller does not have to create a separate variable. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index e73d1c52a0e..ab12fc1c531 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -252,7 +252,7 @@ static int last_stabilize_parser(TDB_DATA key, TDB_DATA data, * @retval false on failure **/ -bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, +bool gencache_set_data_blob(const char *keystr, DATA_BLOB blob, time_t timeout) { int ret; @@ -268,7 +268,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, return false; } - if ((keystr == NULL) || (blob == NULL)) { + if ((keystr == NULL) || (blob.data == NULL)) { return false; } @@ -276,7 +276,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, return false; } - if ((timeout != 0) && gencache_have_val(keystr, blob, timeout)) { + if ((timeout != 0) && gencache_have_val(keystr, &blob, timeout)) { DEBUG(10, ("Did not store value for %s, we already got it\n", keystr)); return true; @@ -287,12 +287,12 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, if (hdr_len == -1) { return false; } - if ((blob->length + (size_t)hdr_len) < blob->length) { + if ((blob.length + (size_t)hdr_len) < blob.length) { return false; } dbufs[0] = (TDB_DATA) { .dptr = (uint8_t *)hdr, .dsize = hdr_len }; - dbufs[1] = (TDB_DATA) { .dptr = blob->data, .dsize = blob->length }; + dbufs[1] = (TDB_DATA) { .dptr = blob.data, .dsize = blob.length }; DEBUG(10, ("Adding cache entry with key=[%s] and timeout=" "[%s] (%d seconds %s)\n", keystr, @@ -784,7 +784,7 @@ bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value, bool gencache_set(const char *keystr, const char *value, time_t timeout) { DATA_BLOB blob = data_blob_const(value, strlen(value)+1); - return gencache_set_data_blob(keystr, &blob, timeout); + return gencache_set_data_blob(keystr, blob, timeout); } struct gencache_iterate_blobs_state { diff --git a/source3/lib/gencache.h b/source3/lib/gencache.h index 4371835599d..fa72a4aa466 100644 --- a/source3/lib/gencache.h +++ b/source3/lib/gencache.h @@ -40,7 +40,7 @@ bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx, DATA_BLOB *blob, time_t *timeout, bool *was_expired); bool gencache_stabilize(void); -bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, +bool gencache_set_data_blob(const char *keystr, DATA_BLOB blob, time_t timeout); void gencache_iterate_blobs(void (*fn)(const char *key, DATA_BLOB value, time_t timeout, void *private_data), diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index 92fc312c6a4..ce0cc89899c 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -154,7 +154,7 @@ static NTSTATUS dsgetdcname_cache_delete(TALLOC_CTX *mem_ctx, static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx, const char *domain_name, - const DATA_BLOB *blob) + DATA_BLOB blob) { time_t expire_time; char *key; @@ -200,7 +200,8 @@ static NTSTATUS store_cldap_reply(TALLOC_CTX *mem_ctx, } if (r->domain_name) { - status = dsgetdcname_cache_store(mem_ctx, r->domain_name, &blob); + status = dsgetdcname_cache_store(mem_ctx, r->domain_name, + blob); if (!NT_STATUS_IS_OK(status)) { goto done; } @@ -209,7 +210,7 @@ static NTSTATUS store_cldap_reply(TALLOC_CTX *mem_ctx, } } if (r->dns_domain) { - status = dsgetdcname_cache_store(mem_ctx, r->dns_domain, &blob); + status = dsgetdcname_cache_store(mem_ctx, r->dns_domain, blob); if (!NT_STATUS_IS_OK(status)) { goto done; } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 5a29f7969ad..f2363900b26 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -10034,7 +10034,7 @@ static bool run_local_gencache(int dummy) blob = data_blob_string_const_null("bar"); tm = time(NULL) + 60; - if (!gencache_set_data_blob("foo", &blob, tm)) { + if (!gencache_set_data_blob("foo", blob, tm)) { d_printf("%s: gencache_set_data_blob() failed\n", __location__); return False; } @@ -10073,7 +10073,7 @@ static bool run_local_gencache(int dummy) blob.data = (uint8_t *)&v; blob.length = sizeof(v); - if (!gencache_set_data_blob("blob", &blob, tm)) { + if (!gencache_set_data_blob("blob", blob, tm)) { d_printf("%s: gencache_set_data_blob() failed\n", __location__); return false; diff --git a/source3/winbindd/wb_dsgetdcname.c b/source3/winbindd/wb_dsgetdcname.c index 125e98ade74..8bd74198bcb 100644 --- a/source3/winbindd/wb_dsgetdcname.c +++ b/source3/winbindd/wb_dsgetdcname.c @@ -153,7 +153,7 @@ NTSTATUS wb_dsgetdcname_gencache_set(const char *domname, return status; } - ok = gencache_set_data_blob(key, &blob, time(NULL)+3600); + ok = gencache_set_data_blob(key, blob, time(NULL)+3600); if (!ok) { DBG_WARNING("gencache_set_data_blob for key %s failed\n", key);