|
|
b48781 |
From 2bf069698a384ff2bc62d2a10544d49d766b4d7f Mon Sep 17 00:00:00 2001
|
|
|
b48781 |
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
|
b48781 |
Date: Mon, 27 Jun 2022 18:00:17 +0200
|
|
|
b48781 |
Subject: [PATCH] src/xlat: remove remnants of unnecessary idx usage in xlookup
|
|
|
b48781 |
|
|
|
b48781 |
As there is no idx saving between calls anymore, there's no need to use
|
|
|
b48781 |
(and update) idx in the XT_SORTED case. Reported by clang as a dead store:
|
|
|
b48781 |
|
|
|
b48781 |
Error: CLANG_WARNING:
|
|
|
b48781 |
strace-5.18/src/xlat.c:84:4: warning[deadcode.DeadStores]: Value stored to 'idx' is never read
|
|
|
b48781 |
|
|
|
b48781 |
* src/xlat.c (xlookup): Remove idx declaration; declare idx inside
|
|
|
b48781 |
of the for loop in the XT_NORMAL case; do not offset x->data and x->size
|
|
|
b48781 |
by offs in the XT_SORTED case and do not update idx upon successful
|
|
|
b48781 |
lookup.
|
|
|
b48781 |
|
|
|
b48781 |
Complements: v5.15~164 "xlat: no longer interpret NULL xlat as continuation"
|
|
|
b48781 |
---
|
|
|
b48781 |
src/xlat.c | 10 +++-------
|
|
|
b48781 |
1 file changed, 3 insertions(+), 7 deletions(-)
|
|
|
b48781 |
|
|
|
b48781 |
Index: strace-5.18/src/xlat.c
|
|
|
b48781 |
===================================================================
|
|
|
b48781 |
--- strace-5.18.orig/src/xlat.c 2022-07-12 17:11:52.660927011 +0200
|
|
|
b48781 |
+++ strace-5.18/src/xlat.c 2022-07-12 17:16:18.116794139 +0200
|
|
|
b48781 |
@@ -61,7 +61,6 @@
|
|
|
b48781 |
const char *
|
|
|
b48781 |
xlookup(const struct xlat *x, const uint64_t val)
|
|
|
b48781 |
{
|
|
|
b48781 |
- size_t idx = 0;
|
|
|
b48781 |
const struct xlat_data *e;
|
|
|
b48781 |
|
|
|
b48781 |
if (!x || !x->data)
|
|
|
b48781 |
@@ -69,21 +68,18 @@
|
|
|
b48781 |
|
|
|
b48781 |
switch (x->type) {
|
|
|
b48781 |
case XT_NORMAL:
|
|
|
b48781 |
- for (; idx < x->size; idx++)
|
|
|
b48781 |
+ for (size_t idx = 0; idx < x->size; idx++)
|
|
|
b48781 |
if (x->data[idx].val == val)
|
|
|
b48781 |
return x->data[idx].str;
|
|
|
b48781 |
break;
|
|
|
b48781 |
|
|
|
b48781 |
case XT_SORTED:
|
|
|
b48781 |
e = bsearch((const void *) &val,
|
|
|
b48781 |
- x->data + idx,
|
|
|
b48781 |
- x->size - idx,
|
|
|
b48781 |
+ x->data, x->size,
|
|
|
b48781 |
sizeof(x->data[0]),
|
|
|
b48781 |
xlat_bsearch_compare);
|
|
|
b48781 |
- if (e) {
|
|
|
b48781 |
- idx = e - x->data;
|
|
|
b48781 |
+ if (e)
|
|
|
b48781 |
return e->str;
|
|
|
b48781 |
- }
|
|
|
b48781 |
break;
|
|
|
b48781 |
|
|
|
b48781 |
case XT_INDEXED:
|