Reduce complexity of 'if' nesting

This commit is contained in:
Serge Lamikhov-Center 2022-06-11 05:59:51 +00:00 committed by GitHub
parent f1c7d420e4
commit cfa213d646
2 changed files with 12 additions and 12 deletions

View File

@ -97,5 +97,6 @@
] ]
}, },
"gtest-adapter.debugConfig": "Run ELFIO Tests", "gtest-adapter.debugConfig": "Run ELFIO Tests",
"gtest-adapter.supportLocation": true "gtest-adapter.supportLocation": true,
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json"
} }

View File

@ -300,18 +300,17 @@ class elfio
for ( int j = i+1; j < sections.size(); ++j ) { for ( int j = i+1; j < sections.size(); ++j ) {
const section* a = sections[i]; const section* a = sections[i];
const section* b = sections[j]; const section* b = sections[j];
if ( ((a->get_type() & SHT_NOBITS) == 0) if ( ( ( a->get_type() & SHT_NOBITS) == 0 )
&& ((b->get_type() & SHT_NOBITS) == 0) && ( ( b->get_type() & SHT_NOBITS) == 0 )
&& (a->get_size() > 0) && ( a->get_size() > 0 )
&& (b->get_size() > 0) && ( b->get_size() > 0 )
&& (a->get_offset() > 0) && ( a->get_offset() > 0 )
&& (b->get_offset() > 0)) { && ( b->get_offset() > 0 )
if ( is_offset_in_section( a->get_offset(), b ) && ( is_offset_in_section( a->get_offset(), b )
|| is_offset_in_section( a->get_offset()+a->get_size()-1, b ) || is_offset_in_section( a->get_offset()+a->get_size()-1, b )
|| is_offset_in_section( b->get_offset(), a ) || is_offset_in_section( b->get_offset(), a )
|| is_offset_in_section( b->get_offset()+b->get_size()-1, a )) { || is_offset_in_section( b->get_offset()+b->get_size()-1, a ) ) ) {
errors += "Sections " + a->get_name() + " and " + b->get_name() + " overlap in file\n"; errors += "Sections " + a->get_name() + " and " + b->get_name() + " overlap in file\n";
}
} }
} }
} }