Skip to content

Commit 2ff808e

Browse files
ptxed: fix potential error mixup
In the inner decoding loop, we use status to indicate errors and turn them into -pte_internal in case we break out of the decode loop without an error. The only exception to this is obtaining the decoder offset, where we use errcode. If we ever had an error, there, it would get overwritten by -pte_internal. Fix it. Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
1 parent d6009e7 commit 2ff808e

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

ptxed/src/ptxed.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,10 +1580,8 @@ static void decode_insn(struct ptxed_decoder *decoder,
15801580
}
15811581

15821582
if (options->print_offset || options->check) {
1583-
int errcode;
1584-
1585-
errcode = pt_insn_get_offset(ptdec, &offset);
1586-
if (errcode < 0)
1583+
status = pt_insn_get_offset(ptdec, &offset);
1584+
if (status < 0)
15871585
break;
15881586
}
15891587

@@ -1620,10 +1618,6 @@ static void decode_insn(struct ptxed_decoder *decoder,
16201618
check_insn(&insn, offset);
16211619
}
16221620

1623-
/* We shouldn't break out of the loop without an error. */
1624-
if (!status)
1625-
status = -pte_internal;
1626-
16271621
/* We're done when we reach the end of the trace stream. */
16281622
if (status == -pte_eos)
16291623
break;
@@ -1989,10 +1983,8 @@ static void decode_block(struct ptxed_decoder *decoder,
19891983
}
19901984

19911985
if (options->print_offset || options->check) {
1992-
int errcode;
1993-
1994-
errcode = pt_blk_get_offset(ptdec, &offset);
1995-
if (errcode < 0)
1986+
status = pt_blk_get_offset(ptdec, &offset);
1987+
if (status < 0)
19961988
break;
19971989
}
19981990

@@ -2032,10 +2024,6 @@ static void decode_block(struct ptxed_decoder *decoder,
20322024
check_block(&block, iscache, offset);
20332025
}
20342026

2035-
/* We shouldn't break out of the loop without an error. */
2036-
if (!status)
2037-
status = -pte_internal;
2038-
20392027
/* We're done when we reach the end of the trace stream. */
20402028
if (status == -pte_eos)
20412029
break;

0 commit comments

Comments
 (0)