Skip to content

Commit b5b59ca

Browse files
committed
Avoid dropping const qualifier
1 parent 889350d commit b5b59ca

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AM_CXXFLAGS = -Wall -std=c++17 -D_FILE_OFFSET_BITS=64
1+
AM_CXXFLAGS = -Wall -Wcast-qual -std=c++17 -D_FILE_OFFSET_BITS=64
22

33
if WITH_ASAN
44
AM_CXXFLAGS += -fsanitize=address -fsanitize-address-use-after-scope

src/patchelf.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
621621
debug("rewriting section '%s' from offset 0x%x (size %d) to offset 0x%x (size %d)\n",
622622
sectionName.c_str(), rdi(shdr.sh_offset), rdi(shdr.sh_size), curOff, i->second.size());
623623

624-
memcpy(fileContents->data() + curOff, (unsigned char *) i->second.c_str(),
624+
memcpy(fileContents->data() + curOff, i->second.c_str(),
625625
i->second.size());
626626

627627
/* Update the section header for this section. */
@@ -1316,7 +1316,7 @@ void ElfFile<ElfFileParamNames>::modifySoname(sonameMode op, const std::string &
13161316
std::string & newDynamic = replaceSection(".dynamic", rdi(shdrDynamic.sh_size) + sizeof(Elf_Dyn));
13171317

13181318
unsigned int idx = 0;
1319-
for (; rdi(((Elf_Dyn *) newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++);
1319+
for (; rdi(reinterpret_cast<const Elf_Dyn *>(newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++);
13201320
debug("DT_NULL index is %d\n", idx);
13211321

13221322
/* Shift all entries down by one. */
@@ -1551,7 +1551,7 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
15511551
rdi(shdrDynamic.sh_size) + sizeof(Elf_Dyn));
15521552

15531553
unsigned int idx = 0;
1554-
for ( ; rdi(((Elf_Dyn *) newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
1554+
for ( ; rdi(reinterpret_cast<const Elf_Dyn *>(newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
15551555
debug("DT_NULL index is %d\n", idx);
15561556

15571557
/* Shift all entries down by one. */
@@ -1753,7 +1753,7 @@ void ElfFile<ElfFileParamNames>::addNeeded(const std::set<std::string> & libs)
17531753
rdi(shdrDynamic.sh_size) + sizeof(Elf_Dyn) * libs.size());
17541754

17551755
unsigned int idx = 0;
1756-
for ( ; rdi(((Elf_Dyn *) newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
1756+
for ( ; rdi(reinterpret_cast<const Elf_Dyn *>(newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
17571757
debug("DT_NULL index is %d\n", idx);
17581758

17591759
/* Shift all entries down by the number of new entries. */
@@ -1815,7 +1815,7 @@ void ElfFile<ElfFileParamNames>::noDefaultLib()
18151815
rdi(shdrDynamic.sh_size) + sizeof(Elf_Dyn));
18161816

18171817
unsigned int idx = 0;
1818-
for ( ; rdi(((Elf_Dyn *) newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
1818+
for ( ; rdi(reinterpret_cast<const Elf_Dyn *>(newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
18191819
debug("DT_NULL index is %d\n", idx);
18201820

18211821
/* Shift all entries down by one. */
@@ -1848,7 +1848,7 @@ void ElfFile<ElfFileParamNames>::addDebugTag()
18481848
rdi(shdrDynamic.sh_size) + sizeof(Elf_Dyn));
18491849

18501850
unsigned int idx = 0;
1851-
for ( ; rdi(((Elf_Dyn *) newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
1851+
for ( ; rdi(reinterpret_cast<const Elf_Dyn *>(newDynamic.c_str())[idx].d_tag) != DT_NULL; idx++) ;
18521852
debug("DT_NULL index is %d\n", idx);
18531853

18541854
/* Shift all entries down by one. */

0 commit comments

Comments
 (0)