Blame SOURCES/0175-src-xlat-remove-remnants-of-unnecessary-idx-usage-in.patch

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