diff --git a/src/modules/kvs/cache.c b/src/modules/kvs/cache.c index 8a48f4508b1a..74dd281b6402 100644 --- a/src/modules/kvs/cache.c +++ b/src/modules/kvs/cache.c @@ -199,28 +199,6 @@ const json_t *cache_entry_get_treeobj (struct cache_entry *hp) return hp->o; } -int cache_entry_set_treeobj (struct cache_entry *hp, const json_t *o) -{ - char *s = NULL; - int saved_errno; - int rc = -1; - - if (!hp || !o || treeobj_validate (o) < 0) { - errno = EINVAL; - goto done; - } - if (!(s = treeobj_encode (o))) - goto done; - if (cache_entry_set_raw (hp, s, strlen (s)) < 0) - goto done; - rc = 0; -done: - saved_errno = errno; - free (s); - errno = saved_errno; - return rc; -} - void cache_entry_destroy (void *arg) { struct cache_entry *hp = arg; diff --git a/src/modules/kvs/cache.h b/src/modules/kvs/cache.h index 7902d9ca1b5a..75ca0ff09dea 100644 --- a/src/modules/kvs/cache.h +++ b/src/modules/kvs/cache.h @@ -13,7 +13,7 @@ struct cache; /* Create/destroy cache entry. * * cache_entry_create() creates an empty cache entry. Data can be set - * in an entry via cache_entry_set_raw() or cache_entry_set_treeobj(). + * in an entry via cache_entry_set_raw(). */ struct cache_entry *cache_entry_create (void); void cache_entry_destroy (void *arg); @@ -55,12 +55,6 @@ int cache_entry_force_clear_dirty (struct cache_entry *hp); * if it is non-NULL. If 'data' is non-NULL, 'len' must be > 0. If * 'data' is NULL, 'len' must be zero. * - * treeobj set accessor is a convenience function that will take a treeobj - * object and extract the raw data string from it and store that in - * the cache entry. The treeobj object 'o' is also cached internally for - * later retrieval. The create transfers ownership of 'o' to the - * cache entry. 'o' must be non-NULL. - * * treeobj get accessor is a convenience function that will return the * treeobj object equivalent of the raw data stored internally. If the * internal raw data is not a valid treeobj object (i.e. improperly @@ -72,15 +66,14 @@ int cache_entry_force_clear_dirty (struct cache_entry *hp); * Generally speaking, a cache entry can only be set once. An attempt * to set new data in a cache entry will silently succeed. * - * cache_entry_set_raw() & cache_entry_set_treeobj() & - * cache_entry_clear_data() returns -1 on error, 0 on success + * cache_entry_set_raw() & cache_entry_clear_data() + * return -1 on error, 0 on success */ int cache_entry_get_raw (struct cache_entry *hp, const void **data, int *len); int cache_entry_set_raw (struct cache_entry *hp, const void *data, int len); const json_t *cache_entry_get_treeobj (struct cache_entry *hp); -int cache_entry_set_treeobj (struct cache_entry *hp, const json_t *o); /* Arrange for message handler represented by 'wait' to be restarted * once cache entry becomes valid or not dirty at completion of a diff --git a/src/modules/kvs/test/cache.c b/src/modules/kvs/test/cache.c index f820ad33ef04..089d94eb71d9 100644 --- a/src/modules/kvs/test/cache.c +++ b/src/modules/kvs/test/cache.c @@ -10,6 +10,28 @@ #include "src/modules/kvs/waitqueue.h" #include "src/modules/kvs/cache.h" +static int cache_entry_set_treeobj (struct cache_entry *hp, const json_t *o) +{ + char *s = NULL; + int saved_errno; + int rc = -1; + + if (!hp || !o || treeobj_validate (o) < 0) { + errno = EINVAL; + goto done; + } + if (!(s = treeobj_encode (o))) + goto done; + if (cache_entry_set_raw (hp, s, strlen (s)) < 0) + goto done; + rc = 0; +done: + saved_errno = errno; + free (s); + errno = saved_errno; + return rc; +} + void wait_cb (void *arg) { int *count = arg; diff --git a/src/modules/kvs/test/commit.c b/src/modules/kvs/test/commit.c index 8f785e25894d..aecf81d1aa35 100644 --- a/src/modules/kvs/test/commit.c +++ b/src/modules/kvs/test/commit.c @@ -18,6 +18,28 @@ static int test_global = 5; +static int cache_entry_set_treeobj (struct cache_entry *hp, const json_t *o) +{ + char *s = NULL; + int saved_errno; + int rc = -1; + + if (!hp || !o || treeobj_validate (o) < 0) { + errno = EINVAL; + goto done; + } + if (!(s = treeobj_encode (o))) + goto done; + if (cache_entry_set_raw (hp, s, strlen (s)) < 0) + goto done; + rc = 0; +done: + saved_errno = errno; + free (s); + errno = saved_errno; + return rc; +} + /* convenience function */ static struct cache_entry *create_cache_entry_raw (void *data, int len) { diff --git a/src/modules/kvs/test/lookup.c b/src/modules/kvs/test/lookup.c index 1c3229086f2d..66ac256020ad 100644 --- a/src/modules/kvs/test/lookup.c +++ b/src/modules/kvs/test/lookup.c @@ -20,6 +20,28 @@ struct lookup_ref_data int count; }; +static int cache_entry_set_treeobj (struct cache_entry *hp, const json_t *o) +{ + char *s = NULL; + int saved_errno; + int rc = -1; + + if (!hp || !o || treeobj_validate (o) < 0) { + errno = EINVAL; + goto done; + } + if (!(s = treeobj_encode (o))) + goto done; + if (cache_entry_set_raw (hp, s, strlen (s)) < 0) + goto done; + rc = 0; +done: + saved_errno = errno; + free (s); + errno = saved_errno; + return rc; +} + /* convenience function */ static struct cache_entry *create_cache_entry_raw (void *data, int len) {