From: Juergen Gross Date: Tue, 15 Dec 2020 16:35:40 +0000 (+0100) Subject: tools/xenstore: make set_tdb_key() non-static X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1264 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2474e53726bda64fac9d604fbc2128df88b54cfb;p=xen.git tools/xenstore: make set_tdb_key() non-static set_tdb_key() can be used by destroy_node(), too. So remove the static attribute and move it to xenstored_core.c. Signed-off-by: Juergen Gross Reviewed-by: Paul Durrant --- diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 3082a36d3a..ab1c7835b8 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -352,6 +352,16 @@ static void initialize_fds(int *p_sock_pollfd_idx, int *ptimeout) } } +void set_tdb_key(const char *name, TDB_DATA *key) +{ + /* + * Dropping const is fine here, as the key will never be modified + * by TDB. + */ + key->dptr = (char *)name; + key->dsize = strlen(name); +} + /* * If it fails, returns NULL and sets errno. * Temporary memory allocations will be done with ctx. @@ -985,9 +995,7 @@ static int destroy_node(void *_node) if (streq(node->name, "/")) corrupt(NULL, "Destroying root node!"); - key.dptr = (void *)node->name; - key.dsize = strlen(node->name); - + set_tdb_key(node->name, &key); tdb_delete(tdb_ctx, key); domain_entry_dec(talloc_parent(node), node); diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index 4c6c3d6f20..fb59d862a2 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -220,6 +220,8 @@ extern xengnttab_handle **xgt_handle; int remember_string(struct hashtable *hash, const char *str); +void set_tdb_key(const char *name, TDB_DATA *key); + #endif /* _XENSTORED_CORE_H */ /* diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xenstored_transaction.c index 2881f3b2e4..52355f4ed8 100644 --- a/tools/xenstore/xenstored_transaction.c +++ b/tools/xenstore/xenstored_transaction.c @@ -168,12 +168,6 @@ struct transaction extern int quota_max_transaction; uint64_t generation; -static void set_tdb_key(const char *name, TDB_DATA *key) -{ - key->dptr = (char *)name; - key->dsize = strlen(name); -} - static struct accessed_node *find_accessed_node(struct transaction *trans, const char *name) {