Skip to content

Commit 0ad9548

Browse files
committed
Style fixes
1 parent 8268756 commit 0ad9548

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/patchelf.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ unsigned int ElfFile<ElfFileParamNames>::findSection3(const SectionName & sectio
641641
template<ElfFileParams>
642642
bool ElfFile<ElfFileParamNames>::haveReplacedSection(const SectionName & sectionName) const
643643
{
644-
return (replacedSections.find(sectionName) != replacedSections.end());
644+
return replacedSections.count(sectionName);
645645
}
646646

647647
template<ElfFileParams>
@@ -734,7 +734,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
734734
shdr.sh_addralign = orig_shdr.sh_addralign;
735735

736736
for (unsigned int j = 0; j < phdrs.size(); ++j)
737-
if (rdi(phdrs[j].p_type) == PT_NOTE && noted_phdrs.find(j) == noted_phdrs.end()) {
737+
if (rdi(phdrs[j].p_type) == PT_NOTE && !noted_phdrs.count(j)) {
738738
Elf_Off p_start = rdi(phdrs[j].p_offset);
739739
Elf_Off p_end = p_start + rdi(phdrs[j].p_filesz);
740740
Elf_Off s_start = rdi(orig_shdr.sh_offset);
@@ -781,8 +781,8 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
781781

782782
/* When normalizing note segments we will in the worst case be adding
783783
1 program header for each SHT_NOTE section. */
784-
unsigned int num_notes = std::count_if(shdrs.begin(), shdrs.end(), [this](Elf_Shdr shdr) { return rdi(shdr.sh_type) == SHT_NOTE; });
785-
;
784+
unsigned int num_notes = std::count_if(shdrs.begin(), shdrs.end(),
785+
[this](Elf_Shdr shdr) { return rdi(shdr.sh_type) == SHT_NOTE; });
786786

787787
/* Because we're adding a new section header, we're necessarily increasing
788788
the size of the program header table. This can cause the first section
@@ -864,7 +864,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
864864
unsigned int lastReplaced = 0;
865865
for (unsigned int i = 1; i < rdi(hdr->e_shnum); ++i) {
866866
std::string sectionName = getSectionName(shdrs[i]);
867-
if (replacedSections.find(sectionName) != replacedSections.end()) {
867+
if (replacedSections.count(sectionName)) {
868868
debug("using replaced section '%s'\n", sectionName.c_str());
869869
lastReplaced = i;
870870
}
@@ -896,7 +896,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
896896
lastReplaced = i - 1;
897897
break;
898898
}
899-
if (replacedSections.find(sectionName) == replacedSections.end()) {
899+
if (!replacedSections.count(sectionName)) {
900900
debug("replacing section '%s' which is in the way\n", sectionName.c_str());
901901
replaceSection(sectionName, rdi(shdr.sh_size));
902902
}
@@ -983,7 +983,8 @@ void ElfFile<ElfFileParamNames>::normalizeNoteSegments()
983983
one of them has to be replaced. */
984984

985985
/* We don't need to do anything if no note segments were replaced. */
986-
bool replaced_note = std::any_of(replacedSections.begin(), replacedSections.end(), [this](std::pair<const std::string, std::string> & i) { return rdi(findSection(i.first).sh_type) == SHT_NOTE; });
986+
bool replaced_note = std::any_of(replacedSections.begin(), replacedSections.end(),
987+
[this](std::pair<const std::string, std::string> & i) { return rdi(findSection(i.first).sh_type) == SHT_NOTE; });
987988
if (!replaced_note) return;
988989

989990
for (auto & phdr : phdrs) {
@@ -1470,7 +1471,7 @@ void ElfFile<ElfFileParamNames>::removeNeeded(const std::set<std::string> & libs
14701471
for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) {
14711472
if (rdi(dyn->d_tag) == DT_NEEDED) {
14721473
char * name = strTab + rdi(dyn->d_un.d_val);
1473-
if (libs.find(name) != libs.end()) {
1474+
if (libs.count(name)) {
14741475
debug("removing DT_NEEDED entry '%s'\n", name);
14751476
changed = true;
14761477
} else {
@@ -1589,7 +1590,8 @@ void ElfFile<ElfFileParamNames>::addNeeded(const std::set<std::string> & libs)
15891590
auto shdrDynStr = findSection(".dynstr");
15901591

15911592
/* add all new libs to the dynstr string table */
1592-
unsigned int length = std::count_if(libs.begin(), libs.end(), [](const std::string & lib) { return lib.size() + 1; });
1593+
unsigned int length = std::count_if(libs.begin(), libs.end(),
1594+
[](const std::string & lib) { return lib.size() + 1; });
15931595

15941596
std::string & newDynStr = replaceSection(".dynstr",
15951597
rdi(shdrDynStr.sh_size) + length + 1);
@@ -1703,7 +1705,7 @@ void ElfFile<ElfFileParamNames>::clearSymbolVersions(const std::set<std::string>
17031705
for (size_t i = 0; i < count; i++) {
17041706
auto dynsym = dynsyms[i];
17051707
auto name = strTab + rdi(dynsym.st_name);
1706-
if (syms.find(name) != syms.end()) {
1708+
if (syms.count(name)) {
17071709
debug("clearing symbol version for %s\n", name);
17081710
wri(versyms[i], 1);
17091711
}

0 commit comments

Comments
 (0)