summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasatake YAMATO <yamato@redhat.com>2021-08-21 06:10:51 +0900
committerDmitry V. Levin <ldv@strace.io>2023-02-21 08:00:00 +0000
commitf6ceaed5d5717924d69725d7fa36d5daadb2fcf4 (patch)
tree3923cbdce0b3769f9b13f550953c01242e0e8d14
parent2268bd05318f7170ecc2da60271eeb8f63d214dc (diff)
downloadstrace-f6ceaed5d5717924d69725d7fa36d5daadb2fcf4.tar.gz
dyxlat: make the type of the xlat created by dyxlat_alloc customizable
* src/defs.h (dyxlat_alloc): Add xlat_type argument. * src/dyxlat.c (dyxlat_alloc): Likewise. * src/socketutils.c (genl_families_xlat): Pass XT_NORMAL to dyxlat_alloc invocation. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
-rw-r--r--src/defs.h2
-rw-r--r--src/dyxlat.c4
-rw-r--r--src/socketutils.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/defs.h b/src/defs.h
index e74948529..6c93d8460 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -843,7 +843,7 @@ extern const char *xlookup(const struct xlat *, const uint64_t);
extern const char *xlookup_le(const struct xlat *, uint64_t *);
struct dyxlat;
-struct dyxlat *dyxlat_alloc(size_t nmemb);
+struct dyxlat *dyxlat_alloc(size_t nmemb, enum xlat_type type);
void dyxlat_free(struct dyxlat *);
const struct xlat *dyxlat_get(const struct dyxlat *);
void dyxlat_add_pair(struct dyxlat *, uint64_t val, const char *str, size_t len);
diff --git a/src/dyxlat.c b/src/dyxlat.c
index 399a8b5ae..bc175ed11 100644
--- a/src/dyxlat.c
+++ b/src/dyxlat.c
@@ -13,11 +13,11 @@ struct dyxlat {
};
struct dyxlat *
-dyxlat_alloc(const size_t nmemb)
+dyxlat_alloc(const size_t nmemb, enum xlat_type type)
{
struct dyxlat *const dyxlat = xmalloc(sizeof(*dyxlat));
- dyxlat->xlat.type = XT_NORMAL;
+ dyxlat->xlat.type = type;
dyxlat->xlat.size = 0;
dyxlat->allocated = nmemb;
dyxlat->xlat.data = dyxlat->data = xgrowarray(NULL, &dyxlat->allocated,
diff --git a/src/socketutils.c b/src/socketutils.c
index 4994cd6d9..d3a3b9283 100644
--- a/src/socketutils.c
+++ b/src/socketutils.c
@@ -629,7 +629,7 @@ genl_families_xlat(struct tcb *tcp)
static struct dyxlat *dyxlat;
if (!dyxlat) {
- dyxlat = dyxlat_alloc(32);
+ dyxlat = dyxlat_alloc(32, XT_NORMAL);
int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
if (fd < 0)