diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-09-18 22:41:09 +0200 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-10-12 00:35:30 +0200 |
commit | 056fc46e38cdecf4e8ef38dc959cea2698f9ba75 (patch) | |
tree | 70751f5541afb2e3e0c7005b3e05fb2395b3f48f | |
parent | 941792d08da6917c63243775be35429a21c2b36c (diff) | |
download | strace-056fc46e38cdecf4e8ef38dc959cea2698f9ba75.tar.gz |
xlat: no longer interpret NULL xlat as continuation
This feature, originally introduced by commit v4.23~52 "xlat.c:
handle NULL xlat in lookup routines as incremental search", was
poorly documented, was of limited use (the only use case was in
print_array_ex, introduced in commit v4.23~91 "print_array: add
support for printing array indices" (which means that between
the two aforementioned commits printing xlats in indices was
broken)), of limited value (it was actually useful only for sorted
xlats, which are lg2(N) anyway, and even there an iteration
from the saved cursor position is preferable for search continuation
rather than bsearch), and ultimately was rendered non-operational
by commit v5.3~105 "Add xlat description structure".
* src/util.c (print_array_ex): Do not pass NULL as xlat in printxval_ex
call.
* src/xlat.c (xlookup): Remove x local static variable; remove static
qualifier from idx and init it to 0; remove x, idx initialisation when
xlat in non-NULL; remove xlat argument to x.
(printxvals_ex): Remove the last local static variable and related
logic.
Reverts: v4.23~52 "xlat.c: handle NULL xlat in lookup routines as incremental search"
-rw-r--r-- | src/util.c | 4 | ||||
-rw-r--r-- | src/xlat.c | 17 |
2 files changed, 4 insertions, 17 deletions
diff --git a/src/util.c b/src/util.c index e7712bd83..6a685b8f2 100644 --- a/src/util.c +++ b/src/util.c @@ -1650,8 +1650,8 @@ print_array_ex(struct tcb *const tcp, if (!index_xlat) { print_xlat_ex(idx, NULL, xlat_style); } else { - printxval_ex(idx ? NULL : index_xlat, idx, - index_dflt, xlat_style); + printxval_ex(index_xlat, idx, index_dflt, + xlat_style); } tprint_array_index_end(); diff --git a/src/xlat.c b/src/xlat.c index 7caafb4b2..83d26d2df 100644 --- a/src/xlat.c +++ b/src/xlat.c @@ -59,17 +59,11 @@ xlat_bsearch_compare(const void *a, const void *b) } const char * -xlookup(const struct xlat *xlat, const uint64_t val) +xlookup(const struct xlat *x, const uint64_t val) { - static const struct xlat *x; - static size_t idx; + size_t idx = 0; const struct xlat_data *e; - if (xlat) { - x = xlat; - idx = 0; - } - if (!x || !x->data) return NULL; @@ -220,8 +214,6 @@ int printxvals_ex(const uint64_t val, const char *dflt, enum xlat_style style, const struct xlat *xlat, ...) { - static const struct xlat *last; - style = get_xlat_style(style); if (xlat_verbose(style) == XLAT_STYLE_RAW) { @@ -234,12 +226,7 @@ printxvals_ex(const uint64_t val, const char *dflt, enum xlat_style style, va_start(args, xlat); - if (!xlat) - xlat = last; - for (; xlat; xlat = va_arg(args, const struct xlat *)) { - last = xlat; - str = xlookup(xlat, val); if (str) { |