strace/0175-src-xlat-remove-remnan...

59 lines
1.7 KiB
Diff
Raw Normal View History

Fix post-rebase issues - Add 0175-src-xlat-remove-remnants-of-unnecessary-idx-usage-in.patch (v5.18-5-g2bf0696 "src/xlat: remove remnants of unnecessary idx usage in xlookup") - Add 0176-strauss-tips-whitespace-and-phrasing-cleanups.patch (v5.18-7-ge604d7b "strauss: tips whitespace and phrasing cleanups") - Add 0177-strauss-fix-off-by-one-error-in-strauss-array-access.patch (v5.18-8-g968789d "strauss: fix off-by-one error in strauss array access") - Add 0178-util-add-offs-sanity-check-to-print_clock_t.patch (v5.18-9-g6d3e97e "util: add offs sanity check to print_clock_t") - Add 0179-secontext-print-context-of-Unix-socket-s-sun_path-fi.patch (v5.18-13-g960e78f "secontext: print context of Unix socket's sun_path field") - Add 0180-pathtrace-util-do-not-print-deleted-as-part-of-the-p.patch (v5.18-18-g676979f "pathtrace, util: do not print " (deleted)" as part of the path") - Add 0181-secontext-fix-expected-SELinux-context-check-for-unl.patch )v5.18-19-g3f0e534 "secontext: fix expected SELinux context check for unlinked FDs") - Add 0182-tests-bpf-fix-sloppy-low-FD-number-usage.patch (v5.18-21-g5338636 "tests/bpf: fix sloppy low FD number usage") * 0175-src-xlat-remove-remnants-of-unnecessary-idx-usage-in.patch: New patch. * 0176-strauss-tips-whitespace-and-phrasing-cleanups.patch: Likewise. * 0177-strauss-fix-off-by-one-error-in-strauss-array-access.patch: Likewise. * 0178-util-add-offs-sanity-check-to-print_clock_t.patch: Likewise. * 0179-secontext-print-context-of-Unix-socket-s-sun_path-fi.patch: Likewise. * 0180-pathtrace-util-do-not-print-deleted-as-part-of-the-p.patch: Likewise. * 0181-secontext-fix-expected-SELinux-context-check-for-unl.patch: Likewise. * 0182-tests-bpf-fix-sloppy-low-FD-number-usage.patch: Likewise. * strace.spec (Release): Bump to 2. (Patch175, Patch176, Patch177, Patch178, Patch179, Patch180, Patch181, Patch182): Add. (%prep): Apply them. (%changelog): New record about 5.18-2. Resolves: #2087693 Resolves: #2103068 Resolves: #2103032 Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2022-07-13 11:07:07 +00:00
From 2bf069698a384ff2bc62d2a10544d49d766b4d7f Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Mon, 27 Jun 2022 18:00:17 +0200
Subject: [PATCH] src/xlat: remove remnants of unnecessary idx usage in xlookup
As there is no idx saving between calls anymore, there's no need to use
(and update) idx in the XT_SORTED case. Reported by clang as a dead store:
Error: CLANG_WARNING:
strace-5.18/src/xlat.c:84:4: warning[deadcode.DeadStores]: Value stored to 'idx' is never read
* src/xlat.c (xlookup): Remove idx declaration; declare idx inside
of the for loop in the XT_NORMAL case; do not offset x->data and x->size
by offs in the XT_SORTED case and do not update idx upon successful
lookup.
Complements: v5.15~164 "xlat: no longer interpret NULL xlat as continuation"
---
src/xlat.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
Index: strace-5.18/src/xlat.c
===================================================================
--- strace-5.18.orig/src/xlat.c 2022-07-12 17:11:52.660927011 +0200
+++ strace-5.18/src/xlat.c 2022-07-12 17:16:18.116794139 +0200
@@ -61,7 +61,6 @@
const char *
xlookup(const struct xlat *x, const uint64_t val)
{
- size_t idx = 0;
const struct xlat_data *e;
if (!x || !x->data)
@@ -69,21 +68,18 @@
switch (x->type) {
case XT_NORMAL:
- for (; idx < x->size; idx++)
+ for (size_t idx = 0; idx < x->size; idx++)
if (x->data[idx].val == val)
return x->data[idx].str;
break;
case XT_SORTED:
e = bsearch((const void *) &val,
- x->data + idx,
- x->size - idx,
+ x->data, x->size,
sizeof(x->data[0]),
xlat_bsearch_compare);
- if (e) {
- idx = e - x->data;
+ if (e)
return e->str;
- }
break;
case XT_INDEXED: