Skip to content

Commit 3b2303c

Browse files
committed
Coverity scan noted two blocks of
structurally dead code in two pretty much identical cases. _dwarf_which_loclists_context _dwarf_which_rnglists_context modified: src/lib/libdwarf/dwarf_loclists.c modified: src/lib/libdwarf/dwarf_rnglists.c Renoved the dead code and realigned the lines to avoid useless indentation.
1 parent fc51f91 commit 3b2303c

File tree

2 files changed

+32
-68
lines changed

2 files changed

+32
-68
lines changed

src/lib/libdwarf/dwarf_loclists.c

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,51 +1003,33 @@ _dwarf_which_loclists_context(Dwarf_Debug dbg,
10031003
rcx = array[i];
10041004
rcxoff = rcx->lc_header_offset;
10051005
rcxend = rcxoff + rcx->lc_length;
1006-
{
1007-
/* We look at the location of each loclist context
1008-
to find one with the offset we want */
1009-
for ( i = 0 ; i < count; ++i) {
1010-
rcx = array[i];
1011-
rcxoff = rcx->lc_header_offset;
1012-
rcxend = rcxoff +
1013-
rcx->lc_length;
1014-
rcxend = rcxoff +
1015-
rcx->lc_length;
1016-
if (chosen_offset < rcxoff){
1017-
continue;
1018-
}
1019-
if (chosen_offset < rcxend ){
1020-
*index = i;
1021-
return DW_DLV_OK;
1022-
}
1006+
/* We look at the location of each loclist context
1007+
to find one with the offset we want */
1008+
for ( i = 0 ; i < count; ++i) {
1009+
rcx = array[i];
1010+
rcxoff = rcx->lc_header_offset;
1011+
rcxend = rcxoff +
1012+
rcx->lc_length;
1013+
rcxend = rcxoff +
1014+
rcx->lc_length;
1015+
if (chosen_offset < rcxoff){
1016+
continue;
10231017
}
1024-
{
1025-
dwarfstring m;
1026-
1027-
dwarfstring_constructor(&m);
1028-
dwarfstring_append_printf_u(&m,
1029-
"DW_DLE_LOCLISTS_ERROR: loclist ran off end "
1030-
" finding target offset of"
1031-
" 0x%" DW_PR_XZEROS DW_PR_DUx ,chosen_offset);
1032-
dwarfstring_append(&m,
1033-
" Not found anywhere in .debug_loclists[.dwo] "
1034-
"data. Corrupted data?");
1035-
_dwarf_error_string(dbg,error,
1036-
DW_DLE_LOCLISTS_ERROR,
1037-
dwarfstring_string(&m));
1038-
dwarfstring_destructor(&m);
1039-
return DW_DLV_ERROR;
1018+
if (chosen_offset < rcxend ){
1019+
*index = i;
1020+
return DW_DLV_OK;
10401021
}
10411022
}
10421023
{
10431024
dwarfstring m;
10441025

10451026
dwarfstring_constructor(&m);
10461027
dwarfstring_append_printf_u(&m,
1047-
"DW_DLE_LOCLISTS_ERROR: loclist base of "
1028+
"DW_DLE_LOCLISTS_ERROR: loclist ran off end "
1029+
" finding target offset of"
10481030
" 0x%" DW_PR_XZEROS DW_PR_DUx ,chosen_offset);
10491031
dwarfstring_append(&m,
1050-
" was not found anywhere in .debug_loclists[.dwo] "
1032+
" Not found anywhere in .debug_loclists[.dwo] "
10511033
"data. Corrupted data?");
10521034
_dwarf_error_string(dbg,error,
10531035
DW_DLE_LOCLISTS_ERROR,

src/lib/libdwarf/dwarf_rnglists.c

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,49 +1107,31 @@ _dwarf_which_rnglists_context(Dwarf_Debug dbg,
11071107
rcxoff = rcx->rc_header_offset;
11081108
rcxend = rcxoff + rcx->rc_length;
11091109

1110-
{
1111-
/* We look at the location of each rnglist context
1112-
to find one with the offset we want */
1113-
for ( i = 0 ; i < count; ++i) {
1114-
rcx = array[i];
1115-
rcxoff = rcx->rc_header_offset;
1116-
rcxend = rcxoff +
1117-
rcx->rc_length;
1118-
if (chosen_offset < rcxoff){
1119-
continue;
1120-
}
1121-
if (chosen_offset < rcxend ){
1122-
*index = i;
1123-
return DW_DLV_OK;
1124-
}
1110+
/* We look at the location of each rnglist context
1111+
to find one with the offset we want */
1112+
for ( i = 0 ; i < count; ++i) {
1113+
rcx = array[i];
1114+
rcxoff = rcx->rc_header_offset;
1115+
rcxend = rcxoff +
1116+
rcx->rc_length;
1117+
if (chosen_offset < rcxoff){
1118+
continue;
11251119
}
1126-
{
1127-
dwarfstring m;
1128-
1129-
dwarfstring_constructor(&m);
1130-
dwarfstring_append_printf_u(&m,
1131-
"DW_DLE_RNGLISTS_ERROR: rnglist ran off end "
1132-
" finding target offset of"
1133-
" 0x%" DW_PR_XZEROS DW_PR_DUx ,chosen_offset);
1134-
dwarfstring_append(&m,
1135-
" Not found anywhere in .debug_rnglists[.dwo] "
1136-
"data. Corrupted data?");
1137-
_dwarf_error_string(dbg,error,
1138-
DW_DLE_RNGLISTS_ERROR,
1139-
dwarfstring_string(&m));
1140-
dwarfstring_destructor(&m);
1141-
return DW_DLV_ERROR;
1120+
if (chosen_offset < rcxend ){
1121+
*index = i;
1122+
return DW_DLV_OK;
11421123
}
11431124
}
11441125
{
11451126
dwarfstring m;
11461127

11471128
dwarfstring_constructor(&m);
11481129
dwarfstring_append_printf_u(&m,
1149-
"DW_DLE_RNGLISTS_ERROR: rnglist base of "
1130+
"DW_DLE_RNGLISTS_ERROR: rnglist ran off end "
1131+
" finding target offset of"
11501132
" 0x%" DW_PR_XZEROS DW_PR_DUx ,chosen_offset);
11511133
dwarfstring_append(&m,
1152-
" was not found anywhere in .debug_rnglists[.dwo] "
1134+
" Not found anywhere in .debug_rnglists[.dwo] "
11531135
"data. Corrupted data?");
11541136
_dwarf_error_string(dbg,error,
11551137
DW_DLE_RNGLISTS_ERROR,

0 commit comments

Comments
 (0)