More refactoring reported by SonarLint

This commit is contained in:
Serge Lamikhov-Center 2022-09-16 20:47:15 +03:00
parent b996977925
commit b57b08409b
4 changed files with 32 additions and 28 deletions

View File

@ -43,7 +43,7 @@ template <class S> class modinfo_section_accessor_template
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool bool
get_attribute( Elf_Word no, std::string& field, std::string& value ) const get_attribute( Elf_Word no, const std::string& field, const std::string& value ) const
{ {
if ( no < content.size() ) { if ( no < content.size() ) {
field = content[no].first; field = content[no].first;

View File

@ -356,8 +356,10 @@ template <class S> class symbol_section_accessor_template
( (T)1 << ( hash % ( 8 * sizeof( T ) ) ) ) | ( (T)1 << ( hash % ( 8 * sizeof( T ) ) ) ) |
( (T)1 << ( ( hash >> bloom_shift ) % ( 8 * sizeof( T ) ) ) ); ( (T)1 << ( ( hash >> bloom_shift ) % ( 8 * sizeof( T ) ) ) );
if ( ( convertor( bloom_filter[bloom_index] ) & bloom_bits ) == if ( ( convertor( bloom_filter[bloom_index] ) & bloom_bits ) !=
bloom_bits ) { bloom_bits )
return ret;
uint32_t bucket = hash % nbuckets; uint32_t bucket = hash % nbuckets;
auto* buckets = auto* buckets =
(uint32_t*)( hash_section->get_data() + 4 * sizeof( uint32_t ) + (uint32_t*)( hash_section->get_data() + 4 * sizeof( uint32_t ) +
@ -371,10 +373,11 @@ template <class S> class symbol_section_accessor_template
uint32_t chain_index = convertor( buckets[bucket] ) - symoffset; uint32_t chain_index = convertor( buckets[bucket] ) - symoffset;
uint32_t chain_hash = convertor( chains[chain_index] ); uint32_t chain_hash = convertor( chains[chain_index] );
std::string symname; std::string symname;
while ( true ) { while ( true ) {
if ( ( chain_hash >> 1 ) == ( hash >> 1 ) && if ( ( chain_hash >> 1 ) == ( hash >> 1 ) &&
get_symbol( chain_index + symoffset, symname, value, get_symbol( chain_index + symoffset, symname, value, size,
size, bind, type, section_index, other ) && bind, type, section_index, other ) &&
name == symname ) { name == symname ) {
ret = true; ret = true;
break; break;
@ -385,7 +388,6 @@ template <class S> class symbol_section_accessor_template
chain_hash = convertor( chains[++chain_index] ); chain_hash = convertor( chains[++chain_index] );
} }
} }
}
return ret; return ret;
} }

View File

@ -209,7 +209,8 @@ class address_translator
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
inline uint32_t elf_hash( const unsigned char* name ) inline uint32_t elf_hash( const unsigned char* name )
{ {
uint32_t h = 0, g = 0; uint32_t h = 0;
uint32_t g = 0;
while ( *name != '\0' ) { while ( *name != '\0' ) {
h = ( h << 4 ) + *name++; h = ( h << 4 ) + *name++;
g = h & 0xf0000000; g = h & 0xf0000000;

View File

@ -30,7 +30,8 @@ template <class S> class versym_section_accessor_template
{ {
public: public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
versym_section_accessor_template( S* section ) : versym_section( section ) explicit versym_section_accessor_template( S* section )
: versym_section( section )
{ {
if ( section ) { if ( section ) {
entries_num = decltype( entries_num )( section->get_size() / entries_num = decltype( entries_num )( section->get_size() /